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 May 22, 2017 2:45 am

Hello,

Sorry for late reply as weekend. Unfortunately, I am afraid that now there is no a Setup that can be installed by the packet manager console as it is a temporary version, once the official version is released, we will let you know.
I do understand you, but it will be very difficult for to locate the reason if you can't provide the document, because every document has different structure or elements, even though we test lots of PDF documents. Thanks for your understand.
And there is no any problems in your codes.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon May 22, 2017 7:19 pm

It took several hours, but I've finally been able to reproduce the problem. It seems there is an issue if the PdfDocument is saved to a stream prior to printing. In my particular case I need to save it to the stream prior to printing because I save it to a BLOB in our database.

If you comment out the .SaveToStream(ms) below the code works fine. With the .SaveToStream(ms) it prints a blank page but the output.pdf looks fine.

I've uploaded the logo I'm using, but I don't think the particular logo makes any difference. In my testing with different logos they all experience the same problem.

Code: Select all
PdfDocument pdfDoc = new PdfDocument();
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
margin.Top = unitCvtr.ConvertUnits(0.25f, PdfGraphicsUnit.Inch, PdfGraphicsUnit.Point);
margin.Bottom = unitCvtr.ConvertUnits(0.1f, PdfGraphicsUnit.Inch, PdfGraphicsUnit.Point);
margin.Left = unitCvtr.ConvertUnits(0.1f, PdfGraphicsUnit.Inch, PdfGraphicsUnit.Point);
margin.Right = margin.Left;

PdfPageBase page = pdfDoc.Pages.Add(PdfPageSize.Letter, margin);
PdfImage labelLogo = PdfImage.FromFile("logo.png");
page.Canvas.DrawImage(labelLogo, new PointF(indent, 0));

MemoryStream ms = new MemoryStream();
pdfDoc.SaveToStream(ms);

pdfDoc.PrintFromPage = 1;
pdfDoc.PrintToPage = pdfDoc.Pages.Count;
pdfDoc.PrintDocument.DocumentName = "ThisIsATest";
pdfDoc.PrintDocument.Print();
pdfDoc.SaveToFile("output.pdf");

Bill.Schalck
 
Posts: 14
Joined: Fri Jul 15, 2016 2:35 pm

Tue May 23, 2017 6:36 am

Dear Bill.Schalck,

Thanks for your feedback.
I have noticed the issue and posted it to our Dev team. Once there is any progress, we will let you know.
As a temporary solution, we suggest printing the document before saving.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF