Aspose.Pdf.Kit for Java - using print in a RCP plugin

My company recently purchased your product for printing PDFs programatically. My initial test of the product was using your BackgroundPrint sample and everything worked great. I then refactored this class to run in a RCP plugin. When trying to print the same files some print and others just print the images, no text or random text.


This message was posted using Page2Forum from Known Issues in Aspose.Pdf.Kit for Java - Aspose.Pdf.Kit for Java

Hi,

Sorry for replying you late. We are looking into this matter and will get back to you ASAP. We apologize for the delay and inconvenience.

Hi,

Could you please make sure that the problematic PDF files work fine with the simple print code? If it works fine in a normal application and causes problem with RCP plugin then please share the problematic PDF file(s) with us along with any further details regarding your environment and any thing which can help us reproduce the same issue at our end. We’ll investigate it in detail and update you accordingly.

We’re sorry for the inconvenience.
Regards,

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

}

Hi,

I have tested all the files at my end using the latest version - Aspose.Pdf.Kit for Java 3.6.0 - but only reproduced the issue with one file - file3.pdf; all other files worked fine at my end. I have logged the issue with file3.pdf as PDFKITJAVA-22253 in our issue tracking system. Our team will look into this issue and you’ll be updated via this forum thread once it is resolved.

Moreover, please download the latest version and try at your end. I hope it will resolve the issues will other files. If you still find any problems, please do let us know.

We’re sorry for the inconvenience.
Regards,

Apparently there is some issue here because I get similar results with 3.6. Similar in that instead of scattered text I get no text at all. If I don’t see any text does that mean I don’t have the appropriate font or the print utility can’t find the font?

Hi,

I’m not quite sure at the moment what might be causing this issue at your end. Could you please share some details regarding your working environment - OS, System Specs, Java Version etc.?
We’ll test the issue again using your particular scenario and try to reproduce it. It is only when we’re able to reproduce the issue over here that we’ll be able to understand the cause and help you resolve the issue.

We’re sorry for the inconvenience and appreciate your cooperation.
Regards,

System:

Microsoft Windows XP Professional Version 2002 Service Pack 3

Computer:

Intel Core 2 Duo CPU E8400 @ 3.0GHz

2.99Ghz 3.25GB of RAM

Java:

1.6.0_17

JAI:

1.1.2

FYI. I tried converting the PDF to a TIFF using PdfConverter. The TIFF file printed but I would prefer not to do it this way.

Hi,

We’ll further test this issue on Windows XP with your described specifications and let you know with the results the earliest possible.

We’re sorry for the inconvenience.
Regards,

Hi,

We have again tested this issue at our end using your particular scenario, but couldn’t reproduce this issue. Could you please share which printer you used to print these files? Have you tried on a different printer? Can you please also try printing to “Microsoft XPS Document Writer” and share the results with us?

We’re sorry for the inconvenience and looking forward to help you out.
Regards,
<span style=“font-size: 10pt; font-family: “Tahoma”,“sans-serif”; color: black;”>

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan