PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Feb 26, 2020 12:29 am

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Sep 16, 2009 7:54 pm 

Joined: Wed Sep 16, 2009 7:43 pm
Posts: 1
If a PdfDocument is loaded and never modified (or it is, depending on what you do), saving it will throw an InvalidOperationException when it shouldn't.

PdfDocument.DoSave immediately checks to see if there are pages within the document:
if (this.pages == null || this.pages.Count == 0)
  throw new InvalidOperationException("Cannot save a PDF document with no pages.");

This looks valid, but if the Pages property is never accessed prior to this, pages will still be null.

Pages property:
    public PdfPages Pages
        if (this.pages == null)
          this.pages = Catalog.Pages;
        return this.pages;

Though I'm not certain how you wish to solve it, a quick fix would be to make the DoSave method check Pages instead of pages.

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group