You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
I couldn't find any documentation on how to annotate/add images to a PDF, but was able to figure it out by reading the code. The following worked for me. Leaving here in case it helps anyone else.
from pdf_annotate import PdfAnnotator, Location, Appearance
# Load a PDF into the PdfAnnotator
annotator = PdfAnnotator('test.pdf')
# Calculate coordinates (open your image in ms word to figure out size in inches, and then multiple by 72 pixels per inch)
x1 = 305.28
y1 = 156.24
x2 = x1 + 282.24
y2 = y1 + 70.56
# Add image to the PDF
annotator.add_annotation(
'image',
Location(x1=x1, y1=y1, x2=x2, y2=y2, page=1),
Appearance(image='test.png')
)
# Save the annotated PDF
annotator.write('output.pdf')
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I couldn't find any documentation on how to annotate/add images to a PDF, but was able to figure it out by reading the code. The following worked for me. Leaving here in case it helps anyone else.
The text was updated successfully, but these errors were encountered: