using JAVA Aspose pdf kit we are printing the pdf file to printer (silent printing).
document is getting printed in printer . but formatting is not proper .
but some of the sentenced are repeated which are overlapping with other words. below is the code used. we have license for pdf kit . Please help us ASAP.
private void createDynamicPDFDocument(String printerName) throws Exception{
InputStream licenseStream = getClass().getResourceAsStream("/Aspose.Pdf.Kit.lic");
com.aspose.pdf.kit.License license = new com.aspose.pdf.kit.License();
license.setLicense(licenseStream);
PdfViewer pdfviewer = new PdfViewer();
//open a Pdf file.
pdfviewer.openPdfFile(“Duplicate1099B_2012 20130320 ID 1156597_old.pdf”);
//decode the pdf page.
// pdfviewer.decodePage(currentPage);
//set the Pdf file page parameters, the first 1 = 100%, the second 1 is the Pdf page number.
pdfviewer.setPdfPageParameters(1, 1);
//initialize the Pdf show.
// displayScrollPane =
pdfviewer.showPdf();
//If you want to print the Pdf file, the follow code is an example. The SimplePdfViewer shows the usage in detail.
//sets the default print scale - false.
pdfviewer.enableScalePrint(false);
//gets a printjob object.
PrinterJob printJob = PrinterJob.getPrinterJob();
//gets the default page.
Paper paper = new Paper();
paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
PageFormat pf = printJob.defaultPage();
//sets the Paper object for this PageFormat.
pf.setPaper(paper);
//allows user to edit settings and select printing
printJob.setPrintable(pdfviewer, pf);
PrintService[] printServices = PrinterJob.lookupPrintServices();
for (int count = 0; count < printServices.length; ++count) {
if (printerName.equalsIgnoreCase(printServices[count].getName())) {
printJob.setPrintService(printServices[count]);
break;
}
}
//creates the printDialog.
/boolean printFile = printJob.printDialog();
if (printFile)
{/
printJob.print();
//}
//close the Pdf file.
pdfviewer.closePdfFile();
}
Hi Rathika,
Thanks for your response. this is happening for all the pdf.
source pdf is attached
Hi Rathika,
it worked with latest pdf kit jar.
Thank you so much .
but another problem , we have printer which is duplex, wanted to print document one side
I tried this option, in the above code. but didn’t worked.
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
attributes.add(Sides.ONE_SIDED);
//creates the printDialog.
/boolean printFile = printJob.printDialog();
if (printFile)
{/
printJob.print(attributes);
//}
Hi Rathika,
I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as PDFKITJAVA-33306. We
will investigate this issue in details and will keep you updated on the status
of a correction. <o:p></o:p>
We apologize for your inconvenience.
Thanks Nayyer. will you update this forum, once the fix made.
Hi Rathika,
Thanks for your inquiry. I'm afraid, we can't provide you the ETA for this issue at the moment. As we have recently noticed the issue and it's pending for analysis in the queue. After completion of analysis phase we would be in position to share some ETA. We will keep you updated regarding issue progress via this forum thread.
Thanks for your patience and cooperation.
Best Regards,
Hi there,
Sorry for the inconvenience faced. I've managed to observe the heading text printing issue with sample document. For further investigation, I've logged an issue in our issue tracking system as PDFKITJAVA-33308 and also linked your request to it. We will keep you update via this thread regarding the issue status.
Please feel free to contact us for any further assistance.
Best Regards