Further investigation revealed that PDF print works for some files and not for others. It doesn't matter whether it is used in a simple application or a RCP plugin. However using Adobe they print fine. I'm attaching four PDF files. The following is my observations:
File1.pdf - prints completely.
File2.pdf - prints images but prints scattered text
File3.pdf - Exception - detailedMessage = "160".
File 4.pdf - same as File2.pdf.
This is my code snippet taken from the pages of your documentation:
//create a PdfViewer class instance.
final PdfViewer pdfviewer = new PdfViewer();
try {
//open a Pdf file.
pdfviewer.openPdfFile(filepath);
//decode the pdf page.
pdfviewer.decodeAllPages();
//sets the default print scale - false.
pdfviewer.enableScalePrint(false);
//gets the default page.
final PageFormat pf = printJob.defaultPage();
//sets the Paper object for this PageFormat.
final Paper paper = new Paper();
//A4 bordless
paper.setSize(595, 842);
paper.setImageableArea(0, 0, 595, 842);
//sets the Paper object for this PageFormat.
pf.setPaper(paper);
//sets the start page for printing, and you can change it according to your request but make sure 1 =< startPage <= endPage <= pdfviewer.getPdfFilePageCount().
final int startPage = 1;
//sets the end page for printing, and you can change it according to your request but make sure 1 =< startPage <= endPage <= pdfviewer.getPdfFilePageCount().
final int endPage = pdfviewer.getPdfFilePageCount();
//sets the page range according to the user's decision.
pdfviewer.setPrintPageRange(startPage,endPage);
//sets the page format for each page between startPage and endPage.
for(int page = startPage; page <= endPage; page++)
pdfviewer.setPageFormat(page,pf);
//queries document for the number of pages and the PageFormat and Printable for each page held in the Pageable instance, document.
printJob.setPageable(pdfviewer);
printJob.print();
//close the Pdf file.
pdfviewer.closePdfFile();
} catch (final PdfViewerSecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (final PdfViewerFontException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (final PdfViewerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (final Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}