Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Jan 22, 2018 12:46 pm

Hello,

I'm using your Spire.PDF dll to print a sale cupom to a termic printer. Unfortunately, I've found a margin top problem and I tried to correct it using the following code:

Code: Select all
 
PdfDocument doc = new PdfDocument();
                doc.LoadFromFile(pdfFileName);

                PdfDocument doc1 = new PdfDocument();
                PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
                PdfMargins margins = new PdfMargins(unitCvtr.ConvertUnits((float)m_dMarginLeft, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point),
                                                    unitCvtr.ConvertUnits((float)m_dMarginTop, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point),
                                                    unitCvtr.ConvertUnits((float)m_dMarginRight, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point),
                                                    unitCvtr.ConvertUnits((float)m_dMarginBottom, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point));
               
                foreach (PdfPageBase page in doc.Pages)
                {
                    SizeF size = page.Size;
                    Log(string.Format("size: {0} x {1}", size.Width, size.Height));
                    PdfPageBase p = doc1.Pages.Add(new SizeF(size.Width + 1, size.Height + 1), margins);
                    page.CreateTemplate().Draw(p, 0, 0);
                }
               
                doc1.CompressionLevel = PdfCompressionLevel.None;

                doc1.PrinterName = szPrinter;
                doc1.PrintFromPage = 1;
                doc1.PrintToPage = 1;
                doc1.PageScaling = PdfPrintPageScaling.ActualSize;

                doc1.PrintDocument.Print();


With this code it returns a blank page when printing... What's wrong??

When I print to a virtual printer (Microsoft Print to PDF) it prints just fine. This problem only occurs with a termic rollout 80 x 420 mm printer.

Thank you in advance

fabiopires
 
Posts: 5
Joined: Thu May 11, 2017 4:09 pm

Mon Jan 22, 2018 5:04 pm

Solved.

fabiopires
 
Posts: 5
Joined: Thu May 11, 2017 4:09 pm

Tue Jan 23, 2018 1:34 am

Hello,

Thanks for your feedback. If you encounter any other question, please contact us.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.PDF