通過 Python 在 PDF 中使用圖章

使用 Python API 使用阿波斯.PDF衝壓。

如何使用 Python via .NET 庫將圖章添加到 PDF

為了將文本戳記處理成PDF檔,我們將使用[Aspose.PDF用於.NET](https://products.aspose.com/pdf/net)API,這是一個功能豐富,功能強大且易於使用的文檔操作API,適用於 python-net 平臺。打開 [NuGet](https://www.nuget.org/packages/aspose.pdf) 包管理器,搜索“.PDF”並安裝。您也可以從程式包管理器主控台使用以下命令。

Python Package Manager Console

pip install aspose-pdf

將圖章添加到 PDF 文件 Python


您需要 [Aspose.PDF用於.NET]https://releases.aspose.com/pdf/net) 來嘗試環境中的代碼。

  1. 載入包含文件實例的 PDF。
  2. 使用 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)