mca*_*tur 6 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);
Run Code Online (Sandbox Code Playgroud)
风格是:
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;
Run Code Online (Sandbox Code Playgroud)
我正在使用的"Doc":
Document document = new Document();
...
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);
pdfRenderer.Document = document;
// Layout and render document to PDF
pdfRenderer.RenderDocument();
Run Code Online (Sandbox Code Playgroud)
如果有人能告诉我如何在pdf打开时没有书签的情况下生成所需的内容,那将会很棒(我找不到解决此问题的方法).
谢谢
为具有OutlineLevel集的段落(即预定义的标题样式)创建书签.
如果您创建自己的样式,它们将不会自动创建书签条目.
或者,您可以清除各个段落或所有标题样式的OutlineLevel.
以下是为段落创建书签的示例代码:
paragraph = sectionToc.AddParagraph();
paragraph.Format.OutlineLevel = OutlineLevel.Level2;
Run Code Online (Sandbox Code Playgroud)
将OutlineLevel设置为BodyText以避免标题的书签:
paragraph = sectionToc.AddParagraph();
paragraph.Format.OutlineLevel = OutlineLevel.BodyText;
Run Code Online (Sandbox Code Playgroud)
更好地创建一个新样式(例如"Heading1WithoutBookmark")并为此样式设置OutlineLevel(以避免为每个段落设置它).