PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jul 15, 2024 10:41 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: Tue Jun 12, 2012 1:21 pm 
Offline

Joined: Tue Jun 12, 2012 1:18 pm
Posts: 1
Hi,

I want to create a combined pdf of multiple single pdf files. After merging these single pdf files I want to add some text at the top of first pdf page like a heading.

How can I do this?

This is how I merge the files:

Code:
      Console.WriteLine("Merging started.....");
      PdfDocument outputPDFDocument = new PdfDocument();
      foreach (string pdfFile in pdfFiles)
      {
         PdfDocument inputPDFDocument = PdfReader.Open(pdfFile, PdfDocumentOpenMode.Import);
         outputPDFDocument.Version = inputPDFDocument.Version;
         
         foreach (PdfPage page in inputPDFDocument.Pages)
         {
            outputPDFDocument.AddPage(page);
         }
      }
      outputPDFDocument.Save(outputFilePath);
      Console.WriteLine("Merging Completed");


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 13, 2012 9:22 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!

I'm not sure about the best way, but I know two ways that will surely work:

  1. Do it like the PDFsharp sample Two Pages on One does (only modified to One Page on One)
  2. After saving the file (as you do now), you can open it for modification and add the text to the pages (see the Watermarks sample that comes with PDFsharp)

Method 2 keeps the pages as they are. With method 1 you have to pay attention to different page sizes in the source files - but you also have the chance to scale all pages to a single format (e.g. DIN A4) which could be more user-friendly than a file with several different page formats.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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