coherentgraphics / cpdf-binaries

PDF Command Line Tools binaries for Linux, Mac, Windows
GNU Affero General Public License v3.0
593 stars 42 forks source link

How to stamp a logo in a pdf file with python? #64

Closed andysix36 closed 2 years ago

andysix36 commented 2 years ago

I have a logo file and a pdf file. when I stamp this logo in the pdf file,Using command line Works. cpdf -stamp-under "[0001234@BA3608].pdf" -pos-left "742 0" "112233[P001].pdf" -o out1.pdf But I want to use python, it doesn't work. What's the problem?

import pycpdflib
import shutil, os

os.add_dll_directory(os.getcwd())
pycpdflib.loadDLL('.\libpycpdf.dll')

pdf_path = '112233[P001].pdf'
stamp_path = '[0001234@BA3608].pdf'
pdf = pycpdflib.fromFile(pdf_path, userpw='')
stamp = pycpdflib.fromFile(pdf_path, userpw='')
pycpdflib.stampExtended(pdf=pdf,
                        pdf2=stamp,
                        r=[1],
                        isover=True,
                        scale_stamp_to_fit=2,
                        pos=(1, 742.0, 0.0),
                        relative_to_cropbox=False)
pycpdflib.toFile(pdf,'out1.pdf', False, False)
johnwhitington commented 2 years ago

Closed in favour of https://github.com/coherentgraphics/python-libcpdf/issues/2