PdfViewer.PrintDocument() prints large files

Hi,

We are using Aspose PDF.NET 6.1 on a client site. We are using it to print pdf documents using code like below. Our client is have an issue with the printer file sizes when printing multiple pdf’s and FTPing them to a print shop. Our previous Adobe solution is performing at about 1/10th the size of the 6.1 code.


What can I do to reduce the size of the printer files output when printing from the PdfViewer?


PdfViewer viewer2 = new PdfViewer();
viewer2.OpenPdfFile(filePath);
viewer2.AutoResize = true; //print the file with adjusted size
viewer2.PrintPageDialog = false;//do not produce the page number dialog when printing
viewer2.PrintDocument();
viewer2.ClosePdfFile();


Hoping this issue was fixed in a later release I downloaded version 9.2.1 and performed a similar test using:
PdfViewer viewer = new PdfViewer();
//Open input PDF file
viewer.BindPdf(filePath);
//Print PDF document
viewer.PrintDocument();
//Close PDF file
viewer.Close();

it is a 125 kb pdf. When printed through the PDFViewer, it is a 1326Kb file, and when printed from Adobe Reader 11, it is a 463 Kb file.


To setup the printer, I just…

Add a new local printer
Create a new port
type of port: Local Port
next
Enter port name:
c:\PrinterFile.prn
ok
Install Print Driver, HP → HP Color LaserJet 2800 Series PS
Printer Name: testsize
next
next
be sure to set as default printer

Hi Joshua,

Thanks for your inquiry. Please try to print the document as an image. It has reduced the print file size almost in half. Please check the following code snippet for this purpose. Hopefully, it will help you to resolve the issue.

//Create PdfViewer object
PdfViewer viewer = new PdfViewer();

//Open input PDF file
viewer.BindPdf(filePath);
// Print PDF document

viewer.PrintAsImage = true;

viewer.PrintDocument();
//Close PDF file
viewer.Close();

Best Regards,

Hi Tilal,

My numbers were off on the file size calculations due to not setting the license file correctly. When printing through PDFViewer in version 9.2, I see a 125kb pdf document increase to 7,936 kb for a default print and 4,688 kb when printing as an image, as you suggested. The document for this test has 14 pages, so that is 566 kb per page for a standard print.
Our tests, with version 6.1, are showing a 53 page and 614 kb pdf file growing to 41,591 kb when printed, so that is around 784 kb per page.

As you can imagine, our client is not happy about seeing their printer file sizes increase so drastically and are labeling this as a critical issue. Their process is to print around 200 pdf documents and send the printer files to a print shop after they are zipped. So what used to be around a 56 mb zip file that was sent to the print shop is now about a 3 Gig zip file.

Do you have any other options? Even if we upgrade to version 9.2 and use the print as image property, we are still looking at a 1.8 gig zip file.

Hi Joshua,

Thanks for sharing the details.

I have tested the scenario and have observed that when printing the PDF document to a newly added HP Color LaserJet 2800 Series PS printer, the size of the resultant document becomes 7962 KB. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-36999. We will investigate this issue in detail and will keep you updated on the status of a correction. We apologize for your inconvenience.

However, when printing the PDF file to Microsoft XPS Document Writer, the resultant file is 789 KB.

C#

//close PdfFileMend object

PdfViewer pdfViewer = new PdfViewer();

//Open input PDF file

pdfViewer.BindPdf("c:/pdftest/Eastman.pdf");

//Set PrinterSettings and PageSettings

System.Drawing.Printing.PrinterSettings printerSetttings = new System.Drawing.Printing.PrinterSettings();

printerSetttings.Copies = 1;

printerSetttings.PrinterName = "Microsoft XPS Document Writer";

//Set output file name and PrintToFile attribute

printerSetttings.PrintFileName = "C:\\pdftest\\Eastman_printoutput.xps";

printerSetttings.PrintToFile = true;

//Disable print page dialog

pdfViewer.PrintPageDialog = false;

//Pass printer settings object to the method

pdfViewer.PrintDocumentWithSettings(printerSetttings);

pdfViewer.Close();

Hi Joshua,

Thanks for your patience. We have further investigated the issue and would suggest use UseIntermidiateImage to optimize the output ps file. Please check the following code sample for the purpose. It will help you to accomplish the task.

// close PdfFileMend object
PdfViewer pdfViewer = new PdfViewer();

// Open input PDF file
pdfViewer.BindPdf("c:/pdftest/Eastman.pdf");

// Set PrinterSettings and PageSettings
System.Drawing.Printing.PrinterSettings printerSetttings = new System.Drawing.Printing.PrinterSettings();
printerSetttings.Copies = 1;

// Optimize the size of output ps file
pdfViewer.UseIntermidiateImage = true;

// Disable print page dialog
pdfViewer.PrintPageDialog = false;

// Pass printer settings object to the method
pdfViewer.PrintDocumentWithSettings(printerSetttings);
pdfViewer.ClosePdfFile();

Please feel free to contact us for any further assistance.

Best Regards,