Hi
I have a strange problem creating bookmarks using the OutlineLevel in MigraDoc. I'm using MigraDoc 1.50.5147, installed using nuget (Visual Studio 2019, latest updates). (I don't have PDFSharp installed separately in my project)
The code I use to make a bookmark is this ("text" is a long string"):
Code:
Paragraph paragraph = section.AddParagraph(text);
paragraph.Format.OutlineLevel = OutlineLevel.Level1;
paragraph.AddBookmark("bookmark test");
Things that work:
- the paragraph is added in the PDF, the string "text" is displayed correctly
- the outlinelevel is working (visible in Adobe Reader)
Things that don't work:
- instead of using "bookmark test" as bookmark, I see in Adobe Reader that MigraDoc is using a part of the beginning of string "text" to use as bookmark text.
Why is it not using "bookmark test"? How can I tell MigraDoc to use a specific string as bookmark string (visible in Adobe Reader)?
Which method to call for this? It seems AddBookmark() doesn't work.
In PDFSharp I used this code to add outlines (as written in the code example):
Code:
PdfOutline outline = document.Outlines.Add("Root", page, true, PdfOutlineStyle.Bold, XColors.Red);
If I want to use this code in MigraDoc, the error I get is:
Code:
Error CS1061 'Document' does not contain a definition for 'Outlines' and no accessible extension method 'Outlines' accepting a first argument of type 'Document' could be found (are you missing a using directive or an assembly reference?)
I'm using following "using" statements in my source code:
Code:
//MigraDoc
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
//PDFSharp
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Drawing.Layout;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
Can anybody help please? I can't find the solution for adding a new outline to a MigraDoc PDF file, by telling which string to use as outline text (visible in Adobe Reader)
Thanks in advance!
Jessica