PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Oct 16, 2018 12:36 pm

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
 Post subject: Close() = evil
PostPosted: Mon Jan 16, 2012 2:23 pm 
Offline

Joined: Tue Jan 10, 2012 1:22 pm
Posts: 4
Hello,
Migrated from 1.21 to PDFSharp. Version - 1.31.1789.0 and got some surprises :).
One of them...

PdfDocument doc = new PdfDocument(groupedPdfName);
..
foreach (Guid customerId in customerInvoices.Keys)
{
//Opens created PDF file with all invoices for single customer
PdfDocument documentByCustomer = PdfReader.Open(filepath, PdfDocumentOpenMode.Import);

// Ads pages to document which contains invoice data from all customers
foreach (PdfPage page in documentByCustomer.Pages)
{
doc.AddPage(page);
}
documentByCustomer.Close(); //This throws an exception -> Can't save modified file.
documentByCustomer.Dispose(); // This doesn't throw anything.
...
}
foreach (PdfPage page in groupedDocument.Pages)
{
XGraphics gfx = XGraphics.FromPdfPage(page);
gfx.MFEH = PdfFontEmbedding.Always;
}
doc.Save(pdfPath);
doc.Close(); //Close throws "An item with the same key has already been added". Exception was thrown in Release mode.

Currently the only solution is not to use Close(). Fortunately it works without it. :)


Top
 Profile  
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