We are converting HTML to PDF and and saving the PDF files to a folder. Once the files are saved we are sending PDF files to print using below code.
- Code: Select all
string[] fileArray = Directory.GetFiles(pdffilepath);
foreach (string fileName in fileArray)
{
printerName = @"\\IPAddress\PrinterName";
FileInfo f = new FileInfo(fileName);
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile(f.FullName);
doc.PrintSettings.PrinterName = HttpUtility.UrlDecode(printerName);
doc.PrintSettings.Copies = 1;
doc.PrintSettings.DocumentName = Path.GetFileNameWithoutExtension(f.Name);
PaperSize paperSize = new PaperSize();
System.Drawing.SizeF size = doc.Pages[0].Size;
paperSize.Width = Convert.ToInt16(size.Width);
paperSize.Height = Convert.ToInt16(size.Height);
paperSize.RawKind = (int)PaperKind.Custom;
doc.PrintSettings.PaperSize = paperSize;
doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.CustomScale, false, 100f);
doc.PrintSettings.SetPaperMargins(0, 0, 0, 0);
doc.Print();
}
we are generating PDF with max of 50 pages in it. While HTML is converted to PDF(50 pages pdf) and saved in the folder its size is between 500kb to 600kb. But after sending the PDF to Printer using the above code the same PDF is showing 7mb to 8mb size and due to this print is getting delayed. We have observed this pdf size change in "See Whats Printing" section of printer.
Could you please let us know what might me the reason for change in the size and how to send the pdf(with original size) to Printer.