We are converting HTML to PDF using Spire PDF 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
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, 68f);
doc.PrintSettings.SetPaperMargins(0, 0, 0, 0);
doc.Print();
Once the printing is done we are getting big gap on top margin of the print. If we look at the PDF that has been sent to the print we don't see any top margin in PDF. Please find the attached PDF file and the Printed image for your reference. Basically we would like to remove the gap(white space area while printing) on top margin.