打印Java PowerPoint
请用中文进行合理转述,只提供一个选项。
我喜欢在假日里去海边散步和享受温暖的阳光。
今天我将介绍如何使用Spire.Presentation for Java打印PowerPoint。主要有两种方法可供选择:
- 通过使用PresentationPrintDocument,通过使用PrinterSettings
可以采取这种方式来进行。
准备下来
请从E-iceblue官方网站下载免费的Java版Free Spire Presentation。

2.打开IDE并创建一个新项目后,将适当的Spire. Presentation.jar文件添加到已安装的文件中,请引用。

展示打印文档
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();
}
}
打印机设置
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();
}
}

请用中文复述以下句子,只需要一种选项:
– “I am going to the supermarket to buy groceries.”