We're pleased to announce the release of Spire.PDF for Python 12.1.3. This version supports customizing signature appearance and retrieving font style information of extracted text. Additionally, several issues that arose during the processing of PDF files have also been resolved. More details are listed below.
Here is a list of changes made in this release
| Category | ID | Description |
| New feature | SPIREPDF-7558 | Completed compatibility support for Mac M-series chips (ARM64 architecture) |
| New feature | SPIREPDF-7000 SPIREPDF-7698 | Added support for customizing signature appearance via the PdfCustomAppearance class.
class MyPdfCustomAppearance(IPdfSignatureAppearance):
def __init__(self):
pass
def Generate(self, g: PdfCanvas):
x = 0.0
y = 0.0
fontSize = 10.0
font = PdfTrueTypeFont("SimSun", fontSize, PdfFontStyle.Regular, True)
lineHeight = fontSize
image = PdfImage.FromFile(inputImage)
g.DrawImage(image, x, y)
x = float(image.Width)
g.DrawString("Signer: Gary", font, PdfBrushes.get_Red(), PointF(x, y))
y += lineHeight + 5
g.DrawString("Phone: +86 12345678", font, PdfBrushes.get_Black(), PointF(x, y))
y += lineHeight + 5
g.DrawString("Address: Sichuan Province, China", font, PdfBrushes.get_Black(), PointF(x, y))
doc = PdfDocument()
doc.LoadFromFile(inputFile)
signatureMaker = PdfOrdinarySignatureMaker(doc, inputFile_pfx, "e-iceblue")
my_appearance = MyPdfCustomAppearance()
customAppearance = PdfCustomAppearance(my_appearance)
signatureMaker.MakeSignature("Signer", doc.Pages.get_Item(0), 90.0, 550.0, 270.0, 640.0, customAppearance)
doc.SaveToFile(outputFile)
|
| New feature | SPIREPDF-7053 | Added support for retrieving font style information of extracted text.
# Load document from disk
doc = PdfDocument()
doc. LoadFromFile(inputFile)
# Define a rectangle
rctg = RectangleF (0.0, 0.0, 200.0, 300.0)
pdfPageBase = doc.Pages.get_Item (0)
finder = PdfTextFinder(pdfPageBase)
finder.Options.Parameter = TextFindParameter.none
finder.Options.Area = rctg
# Find text in the rectangle
findouts = finder.FindAllText()
sb=[]
for fragment in findouts:
sb.append (fragment.Text)
sb.append (fragment.TextStates[0].FontName)
sb.append(str(round(fragment.TextStates[0].FontSize,2)))
result ="result.txt"
|
| Bug | SPIREPDF-6659 | Fixed an issue where text replacement produced incorrect results. |
| Bug | SPIREPDF-7483 | Fixed an issue that the “ffi_prep_cif_var failed” error occurred when running certain Python features on macOS. |
| Bug | SPIREPDF-7819 SPIREPDF-7821 SPIREPDF-7822 | Fixed an issue where content copied from a PDF/A-2B compliant document (converted from PDF) was incorrect. |
| Bug | SPIREPDF-7864 | Fixed an issue where setting a color during text replacement did not take effect as expected. |
Click the link to download Spire.PDF for Python 12.1.3: