PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

PdfOutline throwing unknown exception
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1488
Page 1 of 1

Author:  Milch [ Thu Dec 30, 2010 5:57 pm ]
Post subject:  PdfOutline throwing unknown exception

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");
               
            }

Author:  Remis [ Mon Jan 03, 2011 7:34 pm ]
Post subject:  Re: PdfOutline throwing unknown exception

Write down the exception if you want any reply.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/