Print Services

Table of Contents

Print Services

The Print Services example demonstrates how the PrintHelper class can be used to print PDF documents using Java Print Services. The example also shows how it is possible to select and modify available printers and their settings.

This example also shows how to change the default paper size which is handy for users living outside of North America. Here is a code snippet of how most print jobs are setup.

The source-code for this example is located at:

A primer on using Maven or Gradle build commands can be found here (Maven) and here (Gradle)

Document pdf = new Document();
pdf.setFile(filePath);

// create a new print helper with a specified paper size and print
// quality
PrintHelper printHelper = new PrintHelper(null, pdf.getPageTree(),
        0f, MediaSizeName.NA_LEGAL, PrintQuality.DRAFT);
// try and print pages 1 - 10, 1 copy, scale to fit paper.
printHelper.setupPrintService(selectedService, 0, 0, 1, true);
// print the document
printHelper.print();

The source-code for this example is located at http://anonsvn.icesoft.org/repo/icepdf/trunk/icepdf/examples/printservices/.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2017 ICEsoft Technologies Canada Corp.