Quantcast
Viewing all articles
Browse latest Browse all 3131

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;           
section.Paragraphs.Add(t);
pdf.Save("c:\someFileName.pdf");
Document d = new Document("c:\someFileName.pdf");
d.Pages.Delete(d.Pages.Count);
d.Save();

Why does this not work?

Viewing all articles
Browse latest Browse all 3131

Trending Articles