Spire.PDF for Python 10.8.1 已经正式发布。新版本支持将 imageInfo[i].Image 返回为 byte[] 类型。此外,查找高亮文本,高亮位置不准确的问题也被成功修复。详情请阅读下面的内容。
新功能:
- 支持将 imageInfo[i].Image 返回为 byte[] 类型。
- 同步了 PdfTextReplaceOptions 类。
- 同步了 TextStates 属性到 PdfTextFragment 接口。
- 支持了数字签名功能。
byteResult = imageInfo[i].Image.ToArray()
fileName = outputFile_1 + "Bug_6888_{0:d}.png".format(i)
with open(fileName,'wb') as f:
f.write(byteResult)
pdf=PdfDocument()
pdf.LoadFromFile(inputFile)
page = pdf.Pages[0]
textreplacer = PdfTextReplacer(page)
options = PdfTextReplaceOptions()
options.ReplaceType = ReplaceActionType.WholeWord
textreplacer.Options = options
textreplacer.ReplaceAllText("荷塘", "池塘")
pdf.SaveToFile(outputFile)
pdf = PdfDocument()
pdf.LoadFromFile(inputFile)
inder = PdfTextFinder(pdf.Pages[0])
fragments = finder.Find("PDF")
sb = []
for fragment in fragments:
sb.append(fragment.TextStates[0].FontName)
sb.append(fragment.TextStates[0].FontFamily)
sb.append(str(round(fragment.TextStates[0].FontSize,2)))
File.AppendAllText(outputFile,sb)
pdf.Close()
# Load a Pdf document from disk
doc = PdfDocument()
doc.LoadFromFile(inputFile)
# Create a signature maker with the PDF document and PFX file
signatureMaker = PdfOrdinarySignatureMaker(doc, inputFile_pfx, "e-iceblue")
# Configure the signature properties
signature = signatureMaker.Signature
signature.Name = "Gary"
signature.ContactInfo = "028-81705109"
signature.Location = "Chengdu"
signature.Reason = "The certificate of this document"
# Create a signature appearance
appearance = PdfSignatureAppearance(signature)
appearance.NameLabel = "Signer: "
appearance.ContactInfoLabel = "ContactInfo: "
appearance.LocationLabel = "Location: "
appearance.ReasonLabel = "Reaseon: "
appearance.SignatureImage = PdfImage.FromFile(inputImage)
appearance.GraphicMode = GraphicMode.SignImageAndSignDetail
appearance.SignImageLayout = SignImageLayout.none
# Apply the signature to the PDF document
signatureMaker.MakeSignature("Signer:", doc.Pages.get_Item(0), 90.0, 550.0, 270.0, 90.0, appearance)
# Save the document
doc.SaveToFile(outputFile)
问题修复:
- 修复了查找高亮文本,高亮位置不准确的问题。
获取 Spire.PDF for Python 10.8.1 请点击: