Spire.PDF for Python 11.12.1 现已正式发布,本次更新带来了多项新功能,包括为数字签名添加时间戳、配置 PDF 转 Excel 时的多种布局选项、以及在 PDF 转 Markdown 时忽略图像。同时,本版本还修复了两个已知问题。更多详情如下。
新功能:
- 支持为数字签名添加时间戳。
- 支持转换PDF到Excel时配置文本布局选项。
- 支持转换PDF到Excel时配置行布局选项。
- 支持转换PDF到Excel配置表格布局选项。
- 支持配置OFD转换选项。
- 支持转换PDF到Markdown时配置忽略图片选项。
- 支持转换PDF到SVG时,配置SVG文件的宽度和高度。
doc = PdfDocument ()
doc. LoadFromFile (inputFile)
# Create a digital signature
signature = Security_PdfSignature (doc, doc.Pages.get_Item(0), inputFile_pfx,"08100601", "signature")
signature.SignDetailsFont = PdfFont(PdfFontFamily.Courier,8.0)
# Set the bounds of the signature box
signature.Bounds = RectangleF(PointF(90.0, 550.0), SizeF (180.0, 90.0))
# Configure signature appearance and details
signature.NameLabel = "Digitally signed by:Gary"
signature.LocationInfoLabel ="Location:"
signature.LocationInfo = "CN"
signature.ReasonLabel = "Reaseon:"
signature.Reason = "Ensure authenticity"
signature.ContactInfoLabel = "Contact Number:"
signature.ContactInfo = "028-81705109"
# Set document permissions
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges.value
# Set graphic mode for the signature
signature.GraphicsMode = Security_GraphicMode.SignImageAndSignDetail
# Set the signature image
signature.SignImageSource = PdfImage.FromFile(inputImage)
#When setting “none", the Image and Detail are distributed on both sides, when setting “Stretch", the image extends to the entire signatu
signature.SignImageLayout = SignImageLayout.none
url = "https://freetsa.org/tsr"
signature.ConfigureTimestamp(url)
signature.ConfigureHttpOCSP (None, None)
signature.Certificated = True
doc.SaveToFile(outputFile)
doc.Close()
pdf = PdfDocument()
pdf.LoadFromFile(inputFile)
textOption = XlsxTextLayoutOptions(True, False, False)
pdf.ConvertOptions.SetPdfToXlsxOptions(textOption)
pdf.SaveToFile(outputFile, FileFormat.XLSX)
pdf.Dispose()
pdf = PdfDocument()
pdf.LoadFromFile(inputFile)
lineOption = XlsxLineLayoutOptions(False,False,False,False)
pdf.ConvertOptions.SetPdfToXlsxOptions(lineOption)
pdf.SaveToFile(outputFile, FileFormat.XLSX)
pdf.Dispose()
# Load the PDF document from the specified input file path
pdf.LoadFromFile(inputFile)
# Set the XlsxSpecialTableLayoutOptions as the conversion options for PDF to XLSX conversion
options = XlsxSpecialTableLayoutOptions(False, False, False)
# Save the PDF document as an Excel file using the specified format and options
pdf.SaveToFile(outputFile, FileFormat.XLSX)
pdf = PdfDocument ()
pdf. LoadFromFile (inputFile)
ofdOptions = OfdOptions()
ofdOptions.UseTempFileStorage = True
pdf.ConvertOptions.SetPdfToOfdOptions(ofdOptions)
pdf.SaveToFile(outputFile,FileFormat.OFD)
# Create an instance of PdfToMarkdownConverter with the input PDF file
converter = PdfToMarkdownConverter(inputFile)
# Configure the converter to skip processing images in the PDF
converter.MarkdownOptions.IgnoreImage = True
# Convert the PDF content to Markdown format and save to the output file
converter.ConvertToMarkdown(outputFile)
converter = PdfToSvgConverter(inputFile)
converter.SvgOptions.ScaleX = 1.0
converter.SvgOptions.ScaleY = 1.0
converter.Convert(outputFile)
问题修复:
- 修复了转换PDF到PPTX,表格边框丢失的问题。
- 修复了设置PdfGird的单元格边框,程序抛异常的问题。
获取 Spire.PDF for Python 11.12.1 请点击:







