本篇文章将介绍通过Java程序打印PPT幻灯片的方法。包括打印幻灯片的所有页、打印幻灯片中的指定页面。
使用工具:Free Spire.Presentation for Java (免费版)
Jar文件获取及导入:
方法1:通过官网下载jar文件包。下载后,解压文件,并将lib文件夹下的Spire.Presentation.jar文件导入java程序。
Java示例代码
【示例1】静默打印PPT所有页面
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(); } }
【示例2】不连续打印部分幻灯片
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(); } }
(本文完)
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦