PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Sep 29, 2021 2:57 am

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Apr 21, 2016 7:05 pm 

Joined: Thu Apr 21, 2016 6:37 pm
Posts: 1
I use PDFSharp to combine multiple PDF's into a single one. Some of our PDF's have iref's, so I updated to 1.5 beta3b. Our irefs work now (yay!) but the fillable fields in other PDF's no longer pass through unchanged -- their shape is there, but their fill-ability is gone.

I've attached the sample-pdfs.zip, which contains the input file used, the good 1.32 output PDF, and the bad 1.5 beta3b output PDF.

Here's my code used to generate the outputs:

public void Test(string fileCsv) {
   var files = fileCsv.Split(',');
   var mainDoc = new PdfDocument();
   foreach (var file in files) {
      var fullPath = Path.Combine(@"..\..\Pdfs", file);
      var toAppend = PdfReader.Open(fullPath, PdfDocumentOpenMode.Import);
      foreach (PdfPage page in toAppend.Pages) {
   mainDoc.Save(@"..\..\Pdfs\combine-" + fileCsv);

If you can point me in the right general direction on the github source, with a bit of narrative of what may have changed, I'd be glad to see what I can do with it. Or if we can hire you for a few hours to fix it, that might be an option, too.


sample-pdfs.zip [28.16 KiB]
Downloaded 547 times
Reply with quote  
PostPosted: Mon Nov 28, 2016 5:09 pm 

Joined: Tue Nov 15, 2016 3:58 pm
Posts: 8
Hey, not sure if this has been addressed, but annotations are missing from the bad pdf. It looks like the annotations are not being copied over. I have not looked into the reason why this may be.

        PdfPage ImportExternalPage(PdfPage importPage)
            if (importPage.Owner._openMode != PdfDocumentOpenMode.Import)
                throw new InvalidOperationException("A PDF document must be opened with PdfDocumentOpenMode.Import to import pages from it.");

            PdfPage page = new PdfPage(_document);

            // ReSharper disable AccessToStaticMemberViaDerivedType for a better code readability.
            CloneElement(page, importPage, PdfPage.Keys.Resources, false);
            CloneElement(page, importPage, PdfPage.Keys.Contents, false);
            CloneElement(page, importPage, PdfPage.Keys.MediaBox, true);
            CloneElement(page, importPage, PdfPage.Keys.CropBox, true);
            CloneElement(page, importPage, PdfPage.Keys.Rotate, true);
            CloneElement(page, importPage, PdfPage.Keys.BleedBox, true);
            CloneElement(page, importPage, PdfPage.Keys.TrimBox, true);
            CloneElement(page, importPage, PdfPage.Keys.ArtBox, true);
#if true
            // Do not deep copy annotations.
            //CloneElement(page, importPage, PdfPage.Keys.Annots, false);
            // Deep copy annotations.
            CloneElement(page, importPage, PdfPage.Keys.Annots, true);
            // ReSharper restore AccessToStaticMemberViaDerivedType
            // TODO more elements?
            return page;

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

All times are UTC

Who is online

Users browsing this forum: No registered users and 4 guests

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