之前我们介绍了如何使用 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();
}
}