I do not know how to get rid of the bookmarks that are automatically generated when I add a paragraph:
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);
The style is:
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;
The "Doc" I am using:
Document document = new Document();
...
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);
pdfRenderer.Document = document;
// Layout and render document to PDF
pdfRenderer.RenderDocument();
If anyone could tell me what can i do to generate the desired content without having bookmarks when the pdf opens, it will be great (I have found no solution to this issue).
Thanks¡¡
Bookmarks are created for paragraphs that have the OutlineLevel set (i.e. the predefined Heading styles).
If you create own styles, they won't have bookmark entries created automatically.
Or you can clear the OutlineLevel for individual paragraphs or for all Heading styles.
Here is sample code that creates a bookmark for a paragraph:
paragraph = sectionToc.AddParagraph();
paragraph.Format.OutlineLevel = OutlineLevel.Level2;
Set the OutlineLevel to BodyText to avoid bookmarks for headings:
paragraph = sectionToc.AddParagraph();
paragraph.Format.OutlineLevel = OutlineLevel.BodyText;
Better create a new style (e.g. "Heading1WithoutBookmark") and set the OutlineLevel for this style (to avoid setting it for every single paragraph).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With