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

Exception when adding a bookmark on an existing PDF
https://forum.pdfsharp.net/viewtopic.php?f=3&t=4265
Page 1 of 1

Author:  luispolaris [ Tue Jun 22, 2021 5:17 pm ]
Post subject:  Exception when adding a bookmark on an existing PDF

The following exception appears when I add a bookmark to an existing PDF (see the image) using PDFSharp-gdi version 1.50.5147

Here is the link to the PDF I am trying to add outlines:
https://we.tl/t-yVUeVKIG1h

Code:
using System;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Fonts;
using System.Diagnostics;

namespace Bookmarks
{
    class Program
    {
        static void Main(string[] args)
        {
         
            string file = "C:\\temp\\1\\A101.pdf";
            string accountNumber = "001234";

            using (PdfDocument doc = PdfReader.Open(file, PdfDocumentOpenMode.Modify))
            {
                PdfPage page = doc.Pages[0];
                doc.Outlines.Add(accountNumber, page);
                doc.Save(file);
            }

        }
    }
}


Attachments:
bookmarks.png
bookmarks.png [ 111.38 KiB | Viewed 263 times ]

Author:  rsoeung [ Thu Jun 24, 2021 7:44 am ]
Post subject:  Re: Exception when adding a bookmark on an existing PDF

Can't reproduce the exception with your code and pdf file. The name of the pdf file to download is different than what's in your code. Are these two the same file?

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