通过 Python 处理 PDF 格式的邮票

使用 Python API 使用 Aspose.PDF 进行冲压。

如何使用 Python via .NET 库将图章添加到 PDF

为了将文本图章转换为 PDF 文件,我们将使用 Aspose.PDF for .NET API,这是一款适用于 python-net 平台的功能丰富、强大且易于使用的文档处理 API。打开 NuGet 软件包管理器,搜索 Aspose.pdf 然后安装。你也可以使用软件包管理器控制台中的以下命令。

Python Package Manager Console

pip install aspose-pdf

将图章添加到 PDF 文档 Python


你需要 Aspose.PDF for .NET 在你的环境中试用代码。

1.使用 “文档” 实例加载 PDF。 1.使用 Document.Info 属性获取文档信息。 1.访问并显示不同的 Document.Info 属性。

将图章添加到 PDF-Python。

    # Open document
    pdfDocument = new Document(dataDir+ "AddTextStamp.pdf")
    # Create text stamp
    textStamp = TextStamp("Sample Stamp")
    # Set whether stamp is background
    textStamp.Background = True
    # Set origin
    textStamp.XIndent = 100
    textStamp.YIndent = 100
    # Rotate stamp
    textStamp.Rotate = Rotation.on90
    # Set text properties
    textStamp.TextState.Font = FontRepository.FindFont("Arial")
    textStamp.TextState.FontSize = 14
    textStamp.TextState.FontStyle = FontStyles.Bold
    textStamp.TextState.FontStyle = FontStyles.Italic
    textStamp.TextState.ForegroundColor = System.Drawing.Color.Aqua
    # Add stamp to particular page
    pdfDocument.Pages[1].AddStamp(textStamp)

    dataDir = dataDir + "AddTextStamp_out.pdf"
    # Save output document
    pdfDocument.Save(dataDir)