Spire.PDF 12.9.18 现已正式发布。该版本支持以流式布局模式添加内容来创建 PDF,并调整了创建注释集合的方法。此外,还成功修复了一些在复制页面、创建表单字段和导入 FDF 时出现的问题。详情请查阅以下内容。
新功能:
- 新增支持以流式布局模式添加内容来创建 PDF。(注:目前只支持创建,不支持对已有文档的加载修改)
- 将创建注释集合的方式从 PdfPageBase.AnnotationsV2 调整为 PdfAnnotationCollection.Create(page)。
// 创建 pdf 文档
PdfDocument pdf = new PdfDocument();
// 创建 PdfContentBuilder
PdfContentBuilder builder = new PdfContentBuilder(pdf);
// 添加第一节
var s1 = builder.AddSection();
s1.AddHeading1("Section One");
s1.AddParagraph("First flowing paragraph.");
// 添加第二节
var s2 = builder.AddSection();
s2.AddHeading1("Section Two");
s2.AddParagraph("Second flowing paragraph.");
// 添加第三节(只含段落)
var s3 = builder.AddSection();
s3.AddParagraph("Third section, only a paragraph.");
// 添加第四节,包含标题和导航条目
var s4 = builder.AddSection();
var h1 = s4.AddHeading(1, "Alpha Chapter");
var h2 = s4.AddHeading(2, "Beta Section");
var h3 = s4.AddHeading(3, "Gamma Subsection");
h1.AsNavigationEntry("Alpha Chapter", 1);
h2.AsNavigationEntry("Beta Section", 2);
h3.AsNavigationEntry("Gamma Subsection", 3);
s4.AddParagraph("Body copy under the headings.");
// 构建文档
var result = builder.Build();
// 保存文档
String outputFile = "Bug_1_MultipleSections.pdf";
pdf.SaveToFile(outputFile);
pdf.Close();
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
RectangleF rect = new RectangleF(140, 689, 80, 1);
PdfLineAnnotation lineAnnotation = new PdfLineAnnotation(page, rect, new PointF(140, 690), new PointF(220, 690));
lineAnnotation.Contents = "This is the first line annotation";
//新方式
PdfAnnotationCollection anmotationCollection = PdfAnnotationCollection.Create(page);
anmotationCollection.Add(lineAnnotation);
//原方式
//page.AnnotationsV2.Add(lineAnnotation);
问题修复:
- 修复了使用 InsertPage 复制页面时,表单字段丢失的问题。
- 修复了生成的标签结构 PDF 文档无法完全通过 PDF/UA (ISO 14289-1) 验证的问题。
- 修复了加载 FDF 时,抛出“NullReferenceException”的问题。
- 修复了获取图片的坐标和尺寸不正确的问题。
- 修复了创建表单域时,出现域名重复的问题。
获取Spire.PDF 12.9.18,请点击:







