Hi,
I want print big PDF files. My test file is 180 pages, but I have and documents with 2000 pages.
I use following code:
PdfViewer viewer = new PdfViewer();
viewer.setAutoResize(true); // Print the file with adjusted size
viewer.setAutoRotate(true); // Print the file with adjusted rotation
PdfPrinterSettings printerSettings = new PdfPrinterSettings();
PrintPageSettings pageSettings = new PrintPageSettings();
viewer.setPrintPageDialog(isShowDialog);
viewer.setPrintAsImage(false);
viewer.setUseIntermidiateImage(false);
pageSettings.setPaperSize(new PrintPaperSize("A4", 794, 1123));
pageSettings.setMargins(new PrinterMargins(0, 0, 0, 0));
viewer.printLargePdf(locPath, pageSettings,printerSettings);
In my test it print about 185 sec. but windows show print in “printer queue” (and in system tray icon) only last 40 sec. First 145 sec I can understand that print is start only for high load of CPU. I need show printer icon (and can check “printer queue”) right after start print. How I can do it in Aspose?
Another problem with size of Job. Aspose (for resolution 150) give the size about 1.93 Gb.
Acrobat give (for the same file and printer) only 40Mb.
Is it possible to reduce size in Aspose?
Thanks,
Evgeny.
@aleksand
To address your concerns about printing large PDF files using Aspose, here are some suggestions:
-
Showing Printer Icon Immediately: The delay in showing the printer icon in the queue may be due to how the printing process is initiated. To ensure that the printer dialog appears right after starting the print job, you can use the PrintDialog
class. This allows you to display the print dialog before executing the print command. Here’s a code snippet to illustrate this:
var printDialog = new System.Windows.Forms.PrintDialog();
if (printDialog.ShowDialog() == DialogResult.OK)
{
// Convert PrinterSettings and PageSettings to Aspose.PDF counterparts
Aspose.Pdf.Printing.PrinterSettings ps = new Aspose.Pdf.Printing.PrinterSettings(printDialog.PrinterSettings);
Aspose.Pdf.Printing.PageSettings pgs = new Aspose.Pdf.Printing.PageSettings(printDialog.PrinterSettings.DefaultPageSettings);
// Print document using printer and page settings
viewer.PrintDocumentWithSettings(pgs, ps);
}
-
Reducing PDF Size: The large size of the PDF generated by Aspose compared to Acrobat can be addressed by adjusting the resolution and compression settings. You can try lowering the resolution or using different compression options when saving or printing the PDF. While specific APIs for size reduction are not detailed in the provided context, you may need to experiment with different settings or consult the Aspose documentation for more advanced options.
If you have more specific requirements or need additional help, feel free to ask!
Showing Printer Icon Immediately
I use Java. For show dialog I use following code (I hope it is like in your example):
java.awt.print.PrinterJob pj = java.awt.print.PrinterJob.getPrinterJob();
pj.printDialog(pr)
This code show dialog but after click print it do not start send data printer (no Printer Icon in windows system tray). It start do something inside Aspose. Only big time (for my example after 145 sec) it start send data to printer and windows show that printer start receive data in “printer queue” window of selected printer. I tried to use method “printDocumentWithSettings” but has the same result as for “printLargePdf”. My goal is click to button print in print dialog and after it I can see print icon in windows tray (right bottom corner of Windows 10). Open this icon and can show “printer queue” with my print task. How I can do it?
Reducing PDF Size :
Yes I know about resolution (and change it for some case) but I do test in DPI 150 (it is small value for print. As I remember common value for other applications 300 or more). I’m afraid to reduce it too much.
In this API link (PdfViewer | Aspose.PDF for Java API Reference) I found also setScaleFactor. I do not understand description: “Sets a floating point value that indicates scale factor.” What is mean? I also found the ability to change RenderingOptions. Can you write me which RenderingOptions can reduce size of print task?
Thanks,
Evgeny.
@aleksand
Would you please make sure to use the latest version of the API and if issue still persists, kindly share your sample PDF document along with the screenshot(s) of memory consumption? Please also share which JDK version are you using?