I'm new to borb and PDF manipulation. I'm trying to add a QR code (or any other image) to a PDF file, which I could do simply using the pypdf and reportlab libraries. But what I really need add the images as annotations (it would work using either borb or the other libraries I mentioned).
I tried searching for examples and reading the documentation of pypdf and borb in order to creating image annotations, but could not find a single example.
Of all the examples I saw, none of them (borb or pypdf) tells how to add images as annotations: I did find how to add lines, squares, free text, stamps, etc, but not images.
Is that even possible?
Can anyone provide an example in borb or pydfb/reportlab (or in any other library), please?
I might try to create an annotation "manually" if I knew the dictionary keys necessary to do so according to the PDF specification (which is quite complicated)...
Thanks in advance :)
I looked too and see no current facility in Borb, but
do double check PyPDF https://pypdf.readthedocs.io/en/stable/user/add-watermark.html
or better yet PyMuPDF as the feature below is using MuPDF core.Sorry currently that one is "SIGNATURE read only."This task is usually done in a GUI PDF Viewer/Editor as it often requires a "Hand and Eye" Co-ordination, for example here I have taken the image from upper right and am positioning a copy lower to the left.
Now it is possible to replicate that ability in a programmable way either
Newer X-Platform apps include coherent cpdf or https://pdfcpu.io/core/stamp
Note that when adding signature stamps as pure image, neither is classed as a comments annotation, one is simply considered part of the body objects and the other is imbedded along with the signature object as part of the signing process.
So adding custom image stamps is generally done as part of a GUI editor function, and whist allowed in a signed file, if done after the signing event it will compromise the signature validity by showing as a modification after signing.
You asked how such annotation is added to the PDF at a code level and for that example it is 4 extra objects. In effect this is a mini page definition as a stamp annotation. Here the page with its image is scaled as 20.25 itself but placed at a different scale within a Rect[131.35652 759.5236 207.29605 835.4632] thus roughly 76 points across and high.