本文将介绍如何使用 spire.presentation for java提供的 presentationprintdocument 对象打印 powerpoint 文档:
- 使用默认打印机打印powerpoint 文档
- 选择打印部分powerpoint文档中的幻灯片,可以设置不连续打印
打印所有powerpoint 文档中的幻灯片
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.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.selectslidesforprint("1", "2-6");
document.print();
presentation.dispose();
}
}