Skip to main content

Read the latest Real Python tutorials

Project description

signpdf2

  • This package is used to insert a signature image (png) into a pdf at a specified location using python.

  • We use units instead of pixel. Units are pdf-standard units (1/72 inch).

  • You may have your input files stored on your system or on cloud with a GET url to them.

    • Following example shows how you can insert a signature in a pdf (stored locally or available through a GET url)
    • Then save the signed pdf locally or make a PUT request to a PUT url
  • pdf_utilities.py files is not used anywhere in this package. It's just provided as an accessory.

Github

https://github.com/aseem-hegshetye/signpdf

Installation

Install with pip:

pip install signpdf2

Example

"""
:param sign_w: signature width in units
:param sign_h: signature height in units
:param pdf_file:  name and path of pdf file on local system
:param signature_file: name and path of signature image file
:param page_num: page number of pdf to sign. Index starts at 0
:param offset_x: offset units horizontally from left
:param offset_y: offset units vertically from bottom
:param sign_date: Bool. If true, then add current timestamp below
            signature
"""
from signpdf2.file_utilities import GetFileFromUrl, WritePdfToDisk, WritePdfToUrl
from signpdf2.sign_pdf import SignPdf

put_url = 'xyz/xyz'
pdfurl = 'https:/xyz.pdf'
sign_url = 'https://xyz.png'
output_file_name = 'signed_pdf.pdf'

pdf_file_name = GetFileFromUrl().get_file_from_url(pdfurl)
signature_file_name = GetFileFromUrl().get_file_from_url(sign_url)

sign_pdf = SignPdf(
  sign_w=100,
  sign_h=60,
  page_num=0,
  offset_x=400,
  offset_y=200,
  pdf_file=pdf_file_name,
  signature_file=signature_file_name
)
pdf_writer = sign_pdf.sign_pdf()
WritePdfToUrl().write_pdf_to_url(pdf_writer, put_url)
WritePdfToDisk().write_pdf_to_disk(pdf_writer, output_file_name)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

signpdf2-3.0.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

signpdf2-3.0.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file signpdf2-3.0.0.tar.gz.

File metadata

  • Download URL: signpdf2-3.0.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for signpdf2-3.0.0.tar.gz
Algorithm Hash digest
SHA256 1fc71d4107d576e66c725f59977e5dba0205d2152e4ca5f0a6d9097f60a6364e
MD5 6f01aabd709e82ad0b7179e1ea652a4a
BLAKE2b-256 bd0361a413e7f02cae10815a4175d29070260626d4a6f0a27ab6159472cb8b3d

See more details on using hashes here.

File details

Details for the file signpdf2-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: signpdf2-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for signpdf2-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb04948e623b2ce624f602f746c683a4ac4d493b09f00381d7c1f7f1cca66c58
MD5 170caa5c0d5e853b2c867d758bf78e43
BLAKE2b-256 c7e4b3df56e03e0f7e9df990056939f69900b75057bc575caec1f650455585f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page