Spire.PDF 9.7.0 已发布。该版本添加了放大率对适合高度的支持,还支持创建含结构化表的标签 PDF 文件。本次更新还增强了 PDF 到 PDF/A3A 和 PDF/A1B 的转换。此外,一些已知问题也被成功修复,如打印 PDF 时印章旋转变形的问题。详情请阅读以下内容。
新功能:
- 添加了放大率对适合高度的支持。
- 支持创建含结构化表的标签PDF文件。
PdfDocument myPdf = new PdfDocument("test.pdf");
PdfPageBase page = myPdf .Pages[0];
PdfDestination dest = new PdfDestination(page, new PointF(-40f, -40f));
dest.Mode = PdfDestinationMode.FitV;
PdfGoToAction gotoaction = new PdfGoToAction(dest);
myPdf.AfterOpenAction = gotoaction;
myPdf.ViewerPreferences.PageMode = PdfPageMode.UseOutlines;
myPdf.SaveToFile("FitBH.pdf");
myPdf.Close();
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, new PdfMargins(20));
page.SetTabOrder(TabOrder.Structure);
PdfTaggedContent taggedContent = new PdfTaggedContent(doc);
taggedContent.SetLanguage("en-US");
taggedContent.SetTitle("test");
taggedContent.SetPdfUA1Identification();
PdfTrueTypeFont font = new PdfTrueTypeFont(new System.Drawing.Font("Times New Roman", 14), true);
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
PdfStructureElement document = taggedContent.StructureTreeRoot.AppendChildElement(PdfStandardStructTypes.Document);
PdfStructureElement heading1 = document.AppendChildElement(PdfStandardStructTypes.HeadingLevel1);
heading1.BeginMarkedContent(page);
string headingText = "What is a Tagged PDF?";
page.Canvas.DrawString(headingText, font, brush, new PointF(0, 0));
heading1.EndMarkedContent(page);
PdfStructureElement paragraph = document.AppendChildElement(PdfStandardStructTypes.Paragraph);
paragraph.BeginMarkedContent(page);
string paragraphText = ""Tagged PDF" doesn’t seem like a life-changing term. But for some, it is. For people who are " +
"blind or have low vision and use assistive technology (such as screen readers and connected Braille displays) to " +
"access information, an untagged PDF means they are missing out on information contained in the document because assistive " +
"technology cannot "read" untagged PDFs. Digital accessibility has opened up so many avenues to information that were once " +
"closed to people with visual disabilities, but PDFs often get left out of the equation.";
RectangleF rect = new RectangleF(0, 30, page.Canvas.ClientSize.Width, page.Canvas.ClientSize.Height);
page.Canvas.DrawString(paragraphText, font, brush, rect);
paragraph.EndMarkedContent(page);
PdfStructureElement figure = document.AppendChildElement(PdfStandardStructTypes.Figure);
figure.BeginMarkedContent(page);
PdfImage image = PdfImage.FromFile(TestUtil.DataPath + "ImgFiles/Bug_3938.png");
page.Canvas.DrawImage(image, new PointF(0, 150));
figure.EndMarkedContent(page);
PdfStructureElement table = document.AppendChildElement(PdfStandardStructTypes.Table);
PdfTable pdfTable = new PdfTable();
pdfTable.Style.DefaultStyle.Font = font;
System.Data.DataTable dataTable = new System.Data.DataTable();
dataTable.Columns.Add("Name");
dataTable.Columns.Add("Age");
dataTable.Columns.Add("Sex");
dataTable.Rows.Add(new string[] { "John", "22", "Male" });
dataTable.Rows.Add(new string[] { "Katty", "25", "Female" });
pdfTable.DataSource = dataTable;
pdfTable.Style.ShowHeader = true;
pdfTable.StructureElement = table;
pdfTable.Draw(page.Canvas, new PointF(0, 280), 300f);
doc.SaveToFile("1.pdf");
doc.Dispose();
问题修复:
- 修复了转换PDF到PDFA3A时程序抛出System.NullReferenceException异常的问题。
- 修复了转换PDF到PDFA1B内容不正确的问题。
- 修复了转换PDF到图片和打印PDF时字体改变的问题。
- 修复了提取页面文本时程序抛出System.NullReferenceException异常的问题。
- 修复了打印PDF时印章旋转变形的问题。
获取 Spire.PDF 9.7.0请点击: