We have demonstrated how to use PresentationPrintDocument to print the presentation slides. This article will show you how to use PrinterSettings to print Presentation slides in Java applications.

import com.spire.ms.Printing.*;
import com.spire.presentation.*;
public class PrintPPT {

    public static void main(String[] args) throws Exception {
        //Load the sample document
        Presentation presentation = new Presentation();
        presentation.loadFromFile("Sample.pptx");

        //Use PrinterSettings object to print presentation slides
        PrinterSettings ps = new PrinterSettings();
        ps.setPrintRange(PrintRange.AllPages);
        //ps.setPrintToFile(true);

        //Print the slide with frame
        presentation.setSlideFrameForPrint(true);

        //Print the slide with Grayscale
        presentation.setGrayLevelForPrint(true);

        //Print 4 slides horizontal
        presentation.setSlideCountPerPageForPrint(PageSlideCount.Four);
        presentation.setOrderForPrint(Order.Horizontal);

        //Only select some slides to print
        presentation.SelectSlidesForPrint("1", "3");

        //Print the document
        presentation.print(ps);
        presentation.dispose();
    }
}
Published in Print
Wednesday, 21 August 2019 09:33

Java print a PowerPoint document

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();

        }
    }
Published in Print