Java PowerPointを印刷
6696 ワード
今日はSpire.Presentation for Java でPowerPointを印刷する方法を紹介します。主に二つの方法があります。すなわち:
- PresentationPrintDocument を利用することで
- PrinterSettingsを利用することで
というほうに行うことができます。
下準備
1.E-iceblueの公式サイトからFree Spire. Presentation for Java無料版をダウンロードしてください。
2.IDEを起動して新規プロジェクトを作成してから、インストールされたファイルにあった相応しいSpire. Presentation.jarを参照に追加してください。
PresentationPrintDocument
import com.spire.presentation.Presentation;
import com.spire.presentation.PresentationPrintDocument;
public class PrintPPT {
public static void main(String[] args) throws Exception {
String inputFile = "Sample.pptx";
Presentation presentation = new Presentation();
presentation.loadFromFile(inputFile);
//すべてのスライドを印刷します。
PresentationPrintDocument document = new PresentationPrintDocument(presentation);
document.print();
presentation.dispose();
}
}
PrinterSettings
import com.spire.ms.Printing.*;
import com.spire.presentation.*;
public class PrintPPT {
public static void main(String[] args) throws Exception {
//ファイルをロードします。
Presentation presentation = new Presentation();
presentation.loadFromFile("Sample.pptx");
//PrinterSettingsで印刷します。
PrinterSettings ps = new PrinterSettings();
ps.setPrintRange(PrintRange.AllPages);
//ps.setPrintToFile(true);
//印刷時に枠をつけます。
presentation.setSlideFrameForPrint(true);
//灰色にします
presentation.setGrayLevelForPrint(true);
presentation.setSlideCountPerPageForPrint(PageSlideCount.Four);
//印刷の方法を設定します。
presentation.setOrderForPrint(Order.Horizontal);
//印刷したいスライドを選びます。
presentation.SelectSlidesForPrint("1", "3");
//印刷します。
presentation.print(ps);
presentation.dispose();
}
}
Author And Source
この問題について(Java PowerPointを印刷), 我々は、より多くの情報をここで見つけました https://qiita.com/iceblue/items/35d969f078d5e38d99e5著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .