Migradoc,pdfsharp没有相关书签的段落

时间:2011-12-31 17:22:08

标签: bookmarks pdfsharp migradoc

我不知道如何摆脱添加段落时自动生成的书签:

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 = 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”:

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

如果有人能告诉我如何在pdf打开时没有书签的情况下生成所需的内容,那就太棒了(我找不到解决这个问题的方法)。

Thanks¡¡

1 个答案:

答案 0 :(得分:5)

为具有OutlineLevel设置的段落(即预定义的标题样式)创建书签 如果您创建自己的样式,它们将不会自动创建书签条目。

或者您可以清除各个段落或所有标题样式的OutlineLevel。

以下是为段落创建书签的示例代码:

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

将OutlineLevel设置为BodyText以避免标题的书签:

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

更好地创建新样式(例如“Heading1WithoutBookmark”)并为此样式设置OutlineLevel(以避免为每个段落设置它)。

相关问题