Python aracılığıyla PDF olarak damgalar

PDF belgelerini Python via .NET ile damgalama. PDF belgelerini programlı olarak değiştirmek için Aspose.PDF kullanın

Python via .NET Kitaplığı Kullanarak PDF'ye Damga Ekleme

PDF dosyasına metin damgası eklemek için, güçlü ve kullanımı kolay bir API olan Aspose.PDF for Python via .NET kullanın. PyPI‘yi açın, aspose-pdf‘i arayın ve yükleyin. Alternatif olarak, şu komutu çalıştırın:

Console

pip install aspose-pdf

PDF Belgesine Damga Ekle Python


Kodu ortamınızda denemek için [Aspose.PDF for Python üzerinden .NET] https://releases.aspose.com/pdf/net) gerekir.

  1. PDF’yi bir Belge örneğiyle yükleyin.
  2. DocumentInfo özelliğini kullanarak DocumentInfo alın.
  3. Farklı Document.Info özelliklerine erişin ve görüntüleyin.

PDF'ye Damga Ekle - Python

import aspose.pdf as apdf

from os import path

path_infile = path.join(self.data_dir, infile)
path_outfile = path.join(self.data_dir, outfile)

document = apdf.Document(path_infile)

# Create text stamp
textStamp = apdf.TextStamp("Sample Stamp")
# Set whether stamp is background
textStamp.background = True
# Set origin
textStamp.x_indent = 100
textStamp.y_indent = 100
# Rotate stamp
textStamp.rotate = apdf.Rotation.ON90
# Set text properties
textStamp.text_state.font = apdf.text.FontRepository.find_font("Arial")
textStamp.text_state.font_size = 14
textStamp.text_state.font_style = apdf.text.FontStyles(apdf.text.FontStyles.BOLD | apdf.text.FontStyles.ITALIC)
textStamp.text_state.foreground_color = apdf.Color.aqua
# Add stamp to particular page
document.pages[1].add_stamp(textStamp)

# Save output document
document.save(path_outfile)