We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Removing last page from document results in error

I’m generating pdf files based on database info. I’m not clear why, but currently it appends a single blank page to the end of the completed document. I was hoping to just delete that final blank page, but when I try I get a “stream is not writeable” error.

Here’s how it’s coded right now:

var pdf = new Pdf();
var section = pdf.Sections.Add();
var marginInfo = new Aspose.Pdf.Generator.MarginInfo();
marginInfo.Top = topMargin;
marginInfo.Bottom = marginInfo.Left = marginInfo.Right = MarginOneInch;
section.PageInfo.Margin = marginInfo;
section.TextInfo.FontSize = 12;
section.TextInfo.LineSpacing = 1.5F;
Aspose.Pdf.Generator.Text t = new Text(stringBuilderContainingInfo.ToString());
t.IsHtmlTagSupported = true;
Document d = new Document(“c:\someFileName.pdf”);

Why does this not work?

Hi Scott,

We are sorry for the inconvenience caused. While testing the scenario with the latest version of Aspose.Pdf for .NET 9.4.0, we have managed to reproduce the reported issue and logged it in our bug tracking system as PDFNEWNET-37210 for further investigation and resolution. We will notify you via this thread as soon as it is resolved.

Please feel free to contact us for any further assistance.

Best Regards,

Hi Scott,

Adding more to Tilal’s comments, we will appreciated if you can please share the sample PDF files which you are using and we will definitely considering those scenarios during the resolution of this problem. Thanks for your cooperation and comprehension.

Apologies for the delay. Please find attached an example document created with the code described above.

Hi Scott,

Thanks for sharing your source document. Definitely it would help us to investigate the issue. We will notify you via this forum thread as soon as we made some significant progress towards issue resolution.

Thanks for your patience and cooperation.

Best Regards,

Hi Scott,

The development team has further investigated the issue reported earlier and in order to resolve this problem, we recommend using the new Document Object Model (DOM) of Aspose.Pdf namespace. Please try using the following code snippet to resolve the issue.


doc = new Aspose.Pdf.Document();<o:p></o:p>

//add a new page with text and change its page size-ignored

Page page = doc.Pages.Add();

Aspose.Pdf.MarginInfo marginInfo = new Aspose.Pdf.MarginInfo();

marginInfo.Top = 10;

marginInfo.Bottom = marginInfo.Left = marginInfo.Right = 72;

page.PageInfo.Margin = marginInfo;

TextFragment t = new TextFragment("Manufactured on a modern- efficient chassis line and a state of the art cab line using robotic processes and with unmatched confort features, we have made every investment to ensure that the Chief delivers on quality, durability and reliability. We are confident of making significant headway in the fast - growing ABC market - with the new Chief,\" said Robert Gross, TY, Chuck Spencer. Specifically engineered to meet evolving customer expectations in the areas of performance, comfort and realiability, the Chief promises to make our customers more profitable by offering them a tailor-made product solution to meet ther needs and certainly will be a game-changer for them,\" he said.");

t.TextState.FontSize = 12;

t.TextState.LineSpacing = 1.5F;



Aspose.Pdf.Document d = new Aspose.Pdf.Document(outFile);


string outFile = "c:/pdftest/37210.pdf";


Hi Scott,

In addition to above reply. Please note to support IsHtmlTagSupported feature for adding HTML string into PDF document using new generator(DOM), we have already logged a feature request as PDFNEWNET-35804 in out issue tracking system. Hopefully HTMLFragment class will be implement in upcoming release of Aspose.Pdf for .NET i.e. 9.5 for new generator. However we will notify you via this forum thread as soon as it is fixed and added into new release.

Please feel free to contact us for any further assistance.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-35804;PDFNEWNET-37210) have been fixed in Aspose.Pdf for .NET 9.5.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Scott,

Thanks for your patience. As stated above PDFNEWNET-35804 is also resolved and now you can add HTML string in new/existing document using new DOM approach. Please check following documentation link for the purpose. It will help you to accomplish your requirements.

Please feel free to contact us for any further assistance.

Best Regards,