The Ultimate Java PDF Library SDK

Seamless PDF Integration for Java

Download Trial Purchase

PDF Print FAQ

Here is a list of general questions along with links to example source code. Please contact us if you have an additional question.

How do I find out what printers are accessible?

The PrinterJob class provides access to the printing system, allowing the user to list and select a printer using thecode snippet here

The PDF printout does not fit correctly onto the page

Java Printing allows the user to set a page size and a visible page size which JPedal will use for printing. This can be read using

The user can also define their own page sizes to give a best fit (this is what the SilentPrint.java example code does).

These values will be ignored if inappropriate for a specific printer, resulting in the image being clipped. So either, use the defaults of test for range of printers.

How do I select a PDF printer?

This codewill select the printer if it is available.

The printer can be set using JVM flags, list can be foundhere.

PDF Print Dialog Options

The commercial versions of JPedal include acustom PDF Print Dialogwith support for the options as Acrobat. It has lots of bells and whistles to provide scaling, rotation, and lots of other features for the user to select.

Setting scaling

To set scaling, JPedal has a method to pass in a constant fromorg.jpedal.objects.PrinterOptions. This must be set beforeprinting. This can be read from the printer dialog.

How do I print in monochrome?

This codeshows how to print to monochrome.

Auto rotate and centre option

Auto rotate and center option is off as a default but can be set as in thisexample.

 

Auto rotate or center options can also be set independently of each other using the following methods.

PDF Print view

JPedal can print only the part of the page currently displayed as inexample.

Use PDF size for Printer paper size

Paper size is used as the default but the PDF size can be set as in thisexample.

Setting PDF page size

PDF Page size in normally part of the Paper object and can be read from the PrinterJob object and altered. Values will not over-ride any hard-coded limits on the printer. Theorg.jpedal.examples.viewer.paper.PaperSizesclass contains multiple settings for different page layouts. Always usesetImageableArea()as well as the size. It can be set for printing as in thisexample.

The paper size can be set using JVM flags, more information can be foundhere.

PDF Page Orientation

JPedal automatically calculates the LANDSCAPE/PORTRAIT setting to use page on the PDF page size. We recommend youdo notset this manually.

Printing a range of pages

JPedal can print only the part of the PDF page currently displayed as well as just odd or even page. This is shown inexample code.

Reducing PDF printing size and speed

To improve this we have added some modes which speedup the process using Java’s font renderer wherever possible. This is enabled using these methodsorg/jpedal/PdfDecoder.html#setPrintPageMode(int)with valuesPdfDecoder.NOTEXTPRINT(normal mode – only needed to reset),PdfDecoder.TEXTGLYPHPRINT(intermediate mode – let Java create Glyphs if font matches),PdfDecoder.TEXTSTRINGPRINT(try and get Java to do all the work). We have found PCL printing especially can be very slow any benefits from these modes, but it will work on all printers.

Release3.79b16addsPdfDecoder.STANDARDTEXTSTRINGPRINTwhich will try to print all 14 standard fonts (ie Arial, Courier, Times New Roman) using standard Java fonts even if embedded. This may not work if the font has custom encoding.

Over-Printing (also works for screen display)

Draw additional objectsexplains how to draw your own objects ontop of the PDF printout (ie special Annotations, copyright notice).

Writing your own custom PDF print code

If you are writing your own custom code and try to print some pages before the PDF, the whole PDF will not print out. You may need to tell JPedal you have already printed some pages using the PdfDecoder methoduseLogicalPrintOffset(int pagesPrinted)

Printing PDF forms using custom code

The CustomFormPrint interface allows you to totally control the printing of the PDF form widgets, over-riding any or all. If you pass an instance of a custom inteface into JPedal, it will be called when printing occurs.

PDF Printing tutorials

The tutorials show you how to easily add Print PDF capabilities to your Java software and customise it with JPedal.
Print PDF
PDF Printing In Java. A simple tutorial to show how you can print PDF files with JPedal.

PDF Print Exampleslists the various printing examples available in JPedal.

IDRSolutions Limited 1999-2016