2011-12-31 28 views
6

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; 

的“医生”我使用:

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

如果有人可以告诉我,我能做些什么来产生不公顷所需内容在PDF打开时对付书签,这将非常棒(我没有发现这个问题的解决方案)。

Thanks¡¡

回答

6

书签是对于具有OutlineLevel集(即预定义的标题样式)的段落创建。
如果您创建自己的样式,他们将不会自动创建书签条目。

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

这里是一个段落创建了一个书签示例代码:

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

设置OutlineLevel到BODYTEXT避免书签标题:

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

更好地创造一个新的风格(如“Heading1WithoutBookmark “)并为此样式设置OutlineLevel(以避免为每个段落设置它)。

+0

谢谢你你完全解决了我的问题。 – mcartur 2012-01-01 12:42:16