Skip to content

Stamp is scaled #2221

@Mark0ne

Description

@Mark0ne

When using page.merge_page(wmPage, over=True) to apply a stamp, the stamp is scaled

Environment

Windows 10 x64, Python 3.10 x64

$ python -m platform
Windows-10-10.0.19045-SP0

$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==3.16.2, crypt_provider=('local_crypt_fallback', '0.0.0'), PIL=9.0.1

Code

from pypdf import PdfWriter, PdfReader, Transformation
from os import remove as fileDelete
import os.path

OUT_PATH = r"TMP_OUT.pdf" #Path
SRC_PAGE = r"PAGE.pdf"
WM_PAGE = r"PDF_WATERMARK.pdf"

if __name__=="__main__":
    pdfOut = PdfWriter() #Blank writer
    pdfOut.append(SRC_PAGE)
    
    wmPage = PdfReader(WM_PAGE).pages[0]
    for page in pdfOut.pages:
        page.merge_page(wmPage, over=True) #False (watermark does not seem to mirror.)

    if os.path.exists(OUT_PATH):
            fileDelete(OUT_PATH)
    pdfOut.write(OUT_PATH)
    pdfOut.close()

Problems

I've not fully diagnosed, but it looks like if the WM_PAGE is a different resolution (DPI) then it appears at a different scaling. This is perhaps less of an issue, but would appreciate some tips to correct it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions