News Category

Print

Print (1)

Printing PowerPoint presentations allows you to convert your digital slides into tangible documents that can be shared, distributed, or used for reference. Whether you need handouts for a meeting, materials for a presentation, or physical copies for archival purposes, printing PowerPoint presentations is a versatile way to turn content into physical objects.

In this article, you will learn how to print PowerPoint documents in Java using Spire.Presentation for Java.

Install Spire.Presentation for Java

First of all, you're required to add the Spire.Presentation.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.presentation</artifactId>
        <version>9.4.5</version>
    </dependency>
</dependencies>
    

Print PowerPoint with the Default Printer in Java

Printing a PowerPoint presentation is a straightforward process that can be done using the default printer with default printer settings on your computer.

To print a PowerPoint file with the default printer, follow these steps.

  • Create a Presentation object.
  • Load a PowerPoint file from a given file path.
  • Create a PresentationPrintDocument object based on the document.
  • Print the document with the default printer using print() method of the PresentationPrintDocument object.
  • Java
import com.spire.presentation.Presentation;
import com.spire.presentation.PresentationPrintDocument;

public class PrintWithDefaultPrinter {

    public static void main(String[] args) throws Exception {

        // Create a Presentation object
        Presentation presentation = new Presentation();

        // Load a PowerPoint file
        presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Input.pptx");

        // Create a PresentationPrintDocument object
        PresentationPrintDocument printDocument = new PresentationPrintDocument(presentation);

        // Print the document
        printDocument.print();

        // Dispose resources
        presentation.dispose();
        printDocument.dispose();
    }
}

Print PowerPoint with a Specified Printer in Java

If you want to print your PowerPoint presentation using a specific printer rather than the default one, you can easily do so by following these steps.

  • Create a Presentation object.
  • Load a PowerPoint file from a given file path.
  • Create a PrinterSettings object.
  • Specify the printer name using PrinterSettings.print() method.
  • Print the document using Presentation.print() method.
  • Java
import com.spire.presentation.Presentation;
import com.spire.presentation.printing.PrinterSettings;

public class PrintWithSpecifiedPrinter {

    public static void main(String[] args) throws Exception {

        // Create a Presentation object
        Presentation presentation = new Presentation();

        // Load a PowerPoint file
        presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Input.pptx");

        // Create a PrinterSettings object
        PrinterSettings printerSettings = new PrinterSettings();

        // Specify printer name
        printerSettings.setPrinterName("HP ColorLaserJet MFP M278-M281 PCL-6 (V4)");

        // Print the document
        presentation.print(printerSettings);

        // Dispose resources
        presentation.dispose();
    }
}

Print Multiple Slides on One Page in Java

Printing multiple slides on one page is a convenient way to optimize paper usage and create compact handouts or reference materials from your PowerPoint presentation.

The following are the steps to print multiple slides on one page using Java.

  • Create a Presentation object.
  • Load a PowerPoint file from a given file path.
  • Set the slide count per page for printing using Presentation.setSlideCountPerPageForPrint() method.
  • Print the document using Presentation.print() method.
  • Java
import com.spire.presentation.PageSlideCount;
import com.spire.presentation.Presentation;
import com.spire.presentation.printing.Duplex;
import com.spire.presentation.printing.PrinterSettings;

public class PrintMultipleSlidesOnOnePage {

    public static void main(String[] args) throws Exception {

        // Create a Presentation object
        Presentation presentation = new Presentation();

        // Load a PowerPoint file
        presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Input.pptx");

        // Set slide count per page for print
        presentation.setSlideCountPerPageForPrint(PageSlideCount.Two);

        // Create a PrinterSettings object
        PrinterSettings printerSettings = new PrinterSettings();

        // Print the document
        presentation.print(printerSettings);

        // Dispose resources
        presentation.dispose();
    }
}

Print PowerPoint in Grayscale in Java

By printing in grayscale, you can remove the color elements from your slides and obtain a monochromatic version of your presentation.

The following are the steps to print PowerPoint in grayscale using Java.

  • Create a Presentation object.
  • Load a PowerPoint file from a given file path.
  • Enable grayscale printing using Presentation.setGrayLevelForPrint() method
  • Print the document using Presentation.print() method.
  • Java
import com.spire.presentation.Presentation;
import com.spire.presentation.printing.PrinterSettings;

public class PrintInGrayScale {

    public static void main(String[] args) throws Exception {

        // Create a Presentation object
        Presentation presentation = new Presentation();

        // Load a PowerPoint file
        presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Input.pptx");

        // Enable grayscale printing mode
        presentation.setGrayLevelForPrint(true);

        // Create a PrinterSettings object
        PrinterSettings printerSettings = new PrinterSettings();

        // Print the document
        presentation.print(printerSettings);

        // Dispose resources
        presentation.dispose();
    }
}

Print PowerPoint on Both Sides of the Paper in Java

Printing PowerPoint slides on both sides of the paper can be a practical and eco-friendly option, as it reduces paper consumption and helps create more compact handouts or documents.

The steps to print a PowerPoint file on both sides of the pager are as follow.

  • Create a Presentation object.
  • Load a PowerPoint file from a given file path.
  • Create a PrinterSettings object.
  • Enable duplex printing mode using PrinterSettings.setDuplex() method.
  • Print the document using Presentation.print() method.
  • Java
import com.spire.presentation.Presentation;
import com.spire.presentation.printing.Duplex;
import com.spire.presentation.printing.PrinterSettings;

public class PrintInDuplexMode {

    public static void main(String[] args) throws Exception {

        // Create a Presentation object
        Presentation presentation = new Presentation();

        // Load a PowerPoint file
        presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Input.pptx");

        // Create a PrinterSettings object
        PrinterSettings printerSettings = new PrinterSettings();

        // Enable duplex printing mode
        printerSettings.setDuplex(Duplex.Default);

        // Print the document
        presentation.print(printerSettings);

        // Dispose resources
        presentation.dispose();
    }
}

Set Print Range when Printing PowerPoint in Java

By setting the print range in PowerPoint, you have control over which slides are printed, allowing you to customize your printouts according to your specific needs.

To specify a range of slides to be printed, follow the steps below.

  • Create a Presentation object.
  • Load a PowerPoint file from a given file path.
  • Create a PrinterSettings object.
  • Specify a range of slides to be printed using PrinterSettings.setFromPage() and PrinterSettings.setToPage() methods.
  • Print the document using Presentation.print() method.
  • Java
import com.spire.presentation.Presentation;
import com.spire.presentation.printing.PrintRange;
import com.spire.presentation.printing.PrinterSettings;

public class SetPrintRange {

    public static void main(String[] args) throws Exception {

        // Create a Presentation object
        Presentation presentation = new Presentation();

        // Load a PowerPoint file
        presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Input.pptx");

        // Create a PrinterSettings object
        PrinterSettings printerSettings = new PrinterSettings();

        // Specify a range of slides to be printed
        printerSettings.setPrintRange(PrintRange.SomePages);
        printerSettings.setFromPage(1);
        printerSettings.setToPage(4);

        // Print the document
        presentation.print(printerSettings);

        // Dispose resources
        presentation.dispose();
    }
}

Set Copies when Printing PowerPoint in Java

By setting the number of copies, you can easily specify how many duplicates of your slides you want to print.

To specify the number of copies to be printed, follow these steps.

  • Create a Presentation object.
  • Load a PowerPoint file from a given file path.
  • Create a PrinterSettings object.
  • Specify the number of copies to be printed using PrinterSettings.setCopies() method.
  • Print the document using Presentation.print() method.
  • Java
import com.spire.presentation.Presentation;
import com.spire.presentation.printing.PrinterSettings;

public class SetCopies {

    public static void main(String[] args) throws Exception {

        // Create a Presentation object
        Presentation presentation = new Presentation();

        // Load a PowerPoint file
        presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Test.pptx");

        // Create a PrinterSettings object
        PrinterSettings printerSettings = new PrinterSettings();

        // Specify the number of copies to be printed
        printerSettings.setCopies((short)2);

        // Print the document
        presentation.print(printerSettings);

        // Dispose resources
        presentation.dispose();
    }
}

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.