ทำงานกับแสตมป์ในรูปแบบ PDF ผ่าน Python

ปั๊มด้วย Aspose.PDF โดยใช้ Python API

วิธีการเพิ่มแสตมป์ลงใน PDF โดยใช้ไลบรารี Python via .NET

เพื่อที่จะทำงานร่วมกับแสตมป์ข้อความลงในไฟล์ PDF เราจะใช้ Aspose.PDF for .NET API ซึ่งเป็นคุณลักษณะที่อุดมไปด้วยที่มีประสิทธิภาพและใช้งานง่ายต่อการใช้การจัดการเอกสาร API สำหรับ python-net แพลตฟอร์มเปิดตัวจัดการแพคเกจ NuGet ค้นหาaspose.pdf และติดตั้งนอกจากนี้คุณยังอาจใช้คำสั่งต่อไปนี้จากคอนโซลการจัดการแพคเกจ

Python Package Manager Console

pip install aspose-pdf

เพิ่มแสตมป์ลงในเอกสาร PDF Python


คุณจำเป็นต้อง [Aspose.PDF forหลาม] https://releases.aspose.com/pdf/net) เพื่อลองรหัสในสภาพแวดล้อมของคุณ

1.โหลดไฟล์ PDF ที่มีอินสแตนซ์ของเอกสาร 1.รับ DocumentInfo ใช้คุณสมบัติ 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)