Hi there,
i still try to combine pdf files (all includes bookmarks created using a OutlineLevel in migraDoc) to a single file.
I followed your post
http://forum.pdfsharp.net/viewtopic.php?f=2&t=2304 and took a copy of the first file and add then all other pages to it.
But the single pdf file includes at least only the bookmark of the first pdf file (which i copied at begin).
It seems that using the option 'PdfReader.Open(pdfTempPath, PdfDocumentOpenMode.Import))' looses the bookmarks from that files.
Here's the code I'm using:
Code:
List<string> tempPDFFilePathes = new List<string>(Directory.GetFiles("D:\PDFsharp\PDFfiles\"));
string fullFilePathOfSinglePdfFile = "D:\PDFsharp\PDFfiles\CompletePDFFile";
//we must! take a copy of first pdf to get all bookmarks imported! we can't create a new document
File.Copy(tempPDFFilePathes[0], fullFilePathOfSinglePdfFile, true);
//after we copied it, remove it from tempArray!
tempPDFFilePathes.RemoveAt(0);
// Open an existing document for editing and loop through its pages
PdfDocument doc = PdfReader.Open(fullFilePathOfSinglePdfFile);
foreach (string pdfTempPath in tempPDFFilePathes)
{
cts.ThrowIfCancellationRequested(); //abort if cancel requested!
//in 'using' to free the imported pdfDoc after reading it!
using (PdfDocument inputDocument = PdfReader.Open(pdfTempPath, PdfDocumentOpenMode.Import))
{
foreach (PdfPage page in inputDocument.Pages)
{
cts.ThrowIfCancellationRequested(); //abort if cancel requested!
doc.AddPage(page);
}
inputDocument.Dispose();
}
}
I tried to attached the temp pfd files and the combined pdf file but get the error 'The file is too big, maximum allowed size is 256 KiB.'
I uploaded it to my server, please download it from there...its valid three days
https://www.inpro.de/sendfile/?get=xszXQTHope you can help..