Spire.PDF 10.11.7 已发布。本次更新新增支持返回 PdfTextMarkupAnnotationWidget 的区域数组值,同时增强了 XPS 和 SVG 到 PDF 以及 PDF 到图片和 Markdown 的转换功能。此外,许多已知问题也在该版本中成功修复,如验证签名不正确的问题。详情请阅读以下内容。
新功能:
- 支持返回 PdfTextMarkupAnnotationWidget 的区域数组值。
// Create a PdfDocument object
PdfDocument doc = new PdfDocument();
// Load a PDF file
doc.LoadFromFile(inputFile);
// Initialize a StringBuilder to store extracted text
StringWriter highlightedTextWriter = new StringWriter();
// Loop through each page in the document
foreach (PdfPageBase page in doc.Pages)
{
// Get all annotations on the page
PdfAnnotationCollection annotations = page.Annotations;
// Loop through the annotations
foreach (PdfAnnotation annotation in annotations)
{
// Check if the annotation is a highlight annotation
if (annotation is PdfTextMarkupAnnotationWidget highlightAnnotation)
{
if (highlightAnnotation.TextMarkupAnnotationType == PdfTextMarkupAnnotationType.Highlight)
{
PdfBrush brush = PdfBrushes.Red;
PdfPen pen = new PdfPen(brush, 1f);
for (int i = 0;i<highlightAnnotation.QuadPoints.Length;i += 2) {
page.Canvas.DrawLine(pen, highlightAnnotation.QuadPoints[i], highlightAnnotation.QuadPoints[i + 1]);
}
}
}
}
}
doc.SaveToFile(outputFile);
问题修复:
- 修复了 XPS 转 pdf,程序抛 "ArgumentException" 错误的问题。
- 修复了 SVG 转 PDF,内容显示不完整的问题。
- 修复了验证签名不正确的问题。
- 修复了 PDF 转图片,内容丢失的问题。
- 修复了 PDF 转 Markdown,程序抛 "ObjectDisposedException" 错误的问题。
- 修复了打印 PDF 文档,内容不正确的问题。
获取 Spire.PDF 10.11.7,请点击: