PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:25 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Combine two documents
PostPosted: Thu Oct 27, 2016 2:40 pm 
Offline

Joined: Thu Oct 27, 2016 2:24 pm
Posts: 1
Hi everyone,

I'm trying to combine two PDF documents using PDFSharp 1.50 beta 3:
Code:
using ( PdfDocument outputDocument = new PdfDocument() )
      {
        foreach ( string file in new[] { "1.pdf", "2.pdf" } )
        {
          using ( PdfDocument inputDocument = PdfReader.Open( file, PdfDocumentOpenMode.Import ) )
          {
            int count = inputDocument.PageCount;
            outputDocument.Version = inputDocument.Version;
            for ( int idx = 0; idx < count; idx++ )
            {
              PdfPage page = inputDocument.Pages[ idx ];
              outputDocument.AddPage( page );
            }
          }
        }

        outputDocument.Save( "out.pdf" );
      }


and output don't have values (first, last names, etc.). If someone had the same problem, could you please share example how to fix it?

Files are available here:
1.pdf - https://dl.dropboxusercontent.com/u/156 ... harp/1.pdf
2.pdf - https://dl.dropboxusercontent.com/u/156 ... harp/2.pdf
out.pdf - https://dl.dropboxusercontent.com/u/156 ... rp/out.pdf


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 27, 2016 5:13 pm 
Offline

Joined: Tue Aug 02, 2016 9:56 am
Posts: 40
Location: Amsterdam, The Netherlands
For each document, you'll also have to copy the interactive form (AcroForm) fields to the output document.

I don't know anything about those, but a first stab at this might be something along the lines of:
Code:
    outputDocument.AcroForm.Fields.Add(inputDocument.AcroForm.Fields);
Except that the form fields in the two input documents are going to have the same name, so you will have to think up something to resolve that conflict. Maybe PdfSharp has support for that; I don't know.

_________________
Gerben Vos
Developer


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 13, 2016 2:01 am 
Offline

Joined: Wed Oct 19, 2016 9:14 am
Posts: 7
Location: Australia
I have a similar situation but as my form fields are only in the first file, I open that on in Modify mode, then add pages.

And then Save(newOuputName)

_________________
Thanks

Rob


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 154 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