Spire.Presentation for Java supports to print the presentation slides in Java applications. This article will show you how to print PowerPoint documents from the following aspects:
- Print all presentation slides with default printer
- Select some slides from the PowerPoint document to print
Print PowerPoint document to a default printer and print all the presentation slides.
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"; //Create a ppt document and load file Presentation presentation = new Presentation(); presentation.loadFromFile(inputFile); //Print all the presentation slides with default printer PresentationPrintDocument document = new PresentationPrintDocument(presentation); document.print(); presentation.dispose(); } }
Select some discontinuous slides from the PowerPoint document to print
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"; //Create a ppt document and load file Presentation presentation = new Presentation(); presentation.loadFromFile(inputFile); PresentationPrintDocument document = new PresentationPrintDocument(presentation); //Select the slides to print document.selectSlidesForPrint("1", "2-6"); document.print(); presentation.dispose(); } }