PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 28, 2024 8:14 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 Dec 30, 2010 5:57 pm 
Offline

Joined: Tue Dec 28, 2010 7:39 pm
Posts: 4
I am trying to combine pdf's into a single document and add bookmarks for the individual pages as they are added. My code works for combining the pdf's, however when I attempt to add a bookmark I get an exception. I am using the most basic PdfOutline constructor with a defaulted name just to try and get the thing running -- I keep getting an unknown exception when I create the book mark though. Does anyone have any idea why?

Code:
 foreach (DirectoryInfo D in MySubs)
            {
                currentFileTitle.Text = D.Name.ToString();
                processCounter.Text = counter.ToString() + " of " + MySubs.Length.ToString() + " files processed";

                // Get PDF's from directory
                string[] pdfs = GetFiles(D.FullName.ToString());
                if (pdfs.Length <= 0) break;

                // Create the output document
                PdfDocument outputDocument = new PdfDocument();
               
                // Iterate files
                foreach (string file in pdfs)
                {
                    // Open the document to import pages from it.
                    PdfDocument inputDocument = PdfReader.Open(file, PdfDocumentOpenMode.Import);

                    // Iterate pages
                    for (int idx = 0; idx < inputDocument.PageCount; idx++)
                    {
                        // Get the page from the external document...
                        PdfPage page = inputDocument.Pages[idx];

                        //Create outline (bookmark)
                        PdfOutline bookmark = outputDocument.Outlines.Add("test", page);
                       
                        // ...and add it to the output document.
                        outputDocument.AddPage(page);
                       
                    }
                }

                // Save the document...
                outputDocument.Save(toFilePath + "//" + D.Name + ".pdf");
               
            }


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 03, 2011 7:34 pm 
Offline

Joined: Wed Nov 11, 2009 9:40 am
Posts: 17
Write down the exception if you want any reply.

_________________
Regards,
Remigijus Pankevičius


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 23 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