之前我们介绍了如何使用 PresentationPrintDocument 打印 PowerPoint 文档, 该文将介绍如何使用PrinterSettings 类打印PowerPoint 文
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();
}
}