Migradoc, pdfsharp Paragraph without related bookmarks

I don’t know how to get rid of bookmarks that are automatically generated when a paragraph is added:

Paragraph inicio = document.LastSection.AddParagraph(); inicio.Style = "Heading1"; inicio.AddSpace(110); inicio.AddText("Factura nº"); inicio.AddText(facturaPat.FacturaN + "/" + DateTime.Now.Year); inicio.Format.SpaceAfter = Unit.FromCentimeter(2); inicio.Format.SpaceBefore = Unit.FromCentimeter(0.7); 

Style:

 style = document.Styles["Heading1"]; style.Font.Name = "Arial"; style.Font.Size = 10.5; style.Font.Bold = true; style.Font.Color = Colors.Black; style.ParagraphFormat.PageBreakBefore = false; 

"Doc" I use:

 Document document = new Document(); ... PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding); pdfRenderer.Document = document; // Layout and render document to PDF pdfRenderer.RenderDocument(); 

If someone could tell me what I can do to create the desired content without a bookmark when opening a pdf file, it will be great (I did not find a solution to this problem).

Thanks¡¡

+6
source share
1 answer

Bookmarks are created for paragraphs that have an OutlineLevel set (i.e., predefined heading styles).
If you create your own styles, they will not be automatically bookmarked.

Or you can clear OutlineLevel for individual paragraphs or for all heading styles.

Here is an example of code that creates a bookmark for a paragraph:

 paragraph = sectionToc.AddParagraph(); paragraph.Format.OutlineLevel = OutlineLevel.Level2; 

Set OutlineLevel to BodyText to avoid bookmarks for headers:

 paragraph = sectionToc.AddParagraph(); paragraph.Format.OutlineLevel = OutlineLevel.BodyText; 

Better create a new style (for example, "Heading1WithoutBookmark") and set OutlineLevel for this style (so as not to set it for each individual paragraph).

+6
source

Source: https://habr.com/ru/post/904813/


All Articles