Spire.PDF for Python 12.9.4 现已正式发布。该版本新增了对多种 PDF 注释类型的支持,包括 Caret、Circle、Square、FileAttachment、Movie、Screen、RichMedia 和 Widget 注释,并新增了通过 PdfCode128ABarcode 接口绘制 Code 128 条形码的支持。同时修复了 PDF 附件、文本替换、文本提取以及文本位置等方面的问题。详情如下。
新功能:
- 新增对 CaretAnnotation 注释的支持。
- 新增对 CircleAnnotation 注释的支持。
- 新增对 SquareAnnotation 注释的支持。
- 新增对 FileAttachmentAnnotation 注释的支持。
- 新增对 MovieAnnotation 注释的支持。
- 新增对 ScreenAnnotation 注释的支持。
- 新增对 RichMediaAnnotation 注释的支持。
- 新增对 WidgetAnnotation 注释的支持。
- 新增 PdfCode128ABarcode 接口对 Code 128 条形码绘制的支持。
rect = RectangleF(100.0, 100.0, 10.0, 15.0)
annotation = PdfCaretAnnotation(page, rect)
annotation.Title = "CaretTest"
annotation.Contents = "A caret annotation with default (None) symbol."
annotation.Color = PdfRGBColor(0, 0, 255)
annotation.Border.Width = 1
annotation.Intent = "ParaCaret"
PdfAnnotationCollection.Create(page).Add(annotation)
annotation = PdfCircleAnnotation(page, rect)
annotation.Color = PdfRGBColor(128, 0, 128)
annotation.InteriorColor = PdfRGBColor(255, 255, 200)
annotation.Border.Width = 2
annotation.Border.Style = PdfBorderStyle.Solid
annotation.Border.Effect = PdfBorderEffect.Cloudy
annotation.Border.EffectIntensity = 2
PdfAnnotationCollection.Create(page).Add(annotation)
annotation = PdfSquareAnnotation(page, rect)
annotation.Color = PdfRGBColor(128, 0, 128)
annotation.InteriorColor = PdfRGBColor(255, 255, 200)
annotation.Border.Width = 2
annotation.Border.Style = PdfBorderStyle.Dashed
PdfAnnotationCollection.Create(page).Add(annotation)
fileSpecification = PdfFileSpecification("SalesReportChart.png", data)
annotation = PdfFileAttachmentAnnotation(page, bounds, fileSpecification)
annotation.Icon = PdfFileIcon.Graph
annotation.Color = PdfRGBColor(Color.get_Teal())
PdfAnnotationCollection.Create(page).Add(annotation)
annotation = PdfMovieAnnotation(page, rect, "sample.wmv")
annotation.Title = "My Movie Player"
annotation.Movie.Poster = False
annotation.Movie.Aspect = SizeF(16.0, 9.0)
PdfAnnotationCollection.Create(page).Add(annotation)
annotation = PdfScreenAnnotation(page, rect)
annotation.Title = "ScreenWithBorder"
annotation.Border.Width = 3.0
annotation.Border.Style = PdfBorderStyle.Dashed
PdfAnnotationCollection.Create(page).Add(annotation)
annotation = PdfRichMediaAnnotation(page, rect, content)
annotation.Content = PdfRichMediaContent()
annotation.Color = PdfRGBColor(Color.get_Green())
PdfAnnotationCollection.Create(page).Add(annotation)
doc.LoadFromFile("widget.pdf")
a = PdfAnnotationCollection.Create(page).get_Item(0)
a.Characteristics.BackgroundColor
a.Characteristics.BorderColor
a.Flatten()
message = '0123456789'
Code128 = PdfCode128ABarcode(message)
Code128.BarcodeToTextGapHeight = 1.0
Code128.TextDisplayLocation = TextLocation.Bottom
Code128.TextColor = PdfRGBColor(Color.get_Blue())
Code128.Draw(page, PointF(0.0, y))
问题修复:
- 修复了向 PDF 文档添加附件后附件无法打开的问题。
- 修复了文本替换失败的问题。
- 修复了提取文本时出现多余空格的问题。
- 修复了使用 PdfTextWidget 接口绘制文本后位置不正确的问题。
获取 Spire.PDF for Python 12.9.4 请点击:







