Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Writing watermarks to PDF files
-
Guys, a friend just brought Pythonista. He wants to be able to add an image as a watermark to each page in a Pdf file. We got a lib called pdfrw which should be able to do it. But there was problems with the pdf header. I am not sure why, it's not something I normally do. We also created a pdf from within Pythonista, got the same error.
But I am assuming there is a mainstream lib or way to do this in Pythonista that's not obvious to me.
Any help appreciated
-
Are you wanting to add a watermark to an existing PDF, or make a new PDF with a watermark? If you're making a new document you might want to check out reportlab.
-
@smath , the watermark is to be added to every page of an existing pdf file
-
@omz, I was just looking in the App Store and through the related button see you have the PDF highlighter APP. From what I can read that app can not insert watermarks on PDFs. But given your knowledge of PDFs, is possible to be done with Pythonista? A friend has to travel with a laptop for this one thing. Even on the laptop it takes him sometime to do.
But if it can't be done, is it a technical issue, or an Adobe thing that's not accessible? -
see http://wa5pb.freeshell.org/motd/?p=769 for an example of creating a watermark with reportlab, then applying it using PyPDF ( or PyPDF2 in our case)
both reportlab and pypdf2 are included with pythonista
-
I can confirm that the approach in @JonB's link works in Pythonista. Simply replace
pyPdf
withPyPDF2
in the first import statement (note the different capitalization). -
Thanks so much guys, works. I tried a longer file and it failed. But was a product manual. Could be many reasons why it failed I guess. Just hoping it helps my friend. Will save him a ton of work from what I understand. Also will mean, when he travels he will no longer need to take his laptop. This was the only component of his work he could not do on his ipad.
So thanks again, a very practical use application for Pythonista -
I was so happy to find this reference to PyPDF2, and even happier to find it is included with Pythonista. Looks like just what I need.
But how, may I ask (and maybe it is just way too late at night and my brain is shot) did you all know that it was included? It's not listed in the Globule Module Index.
I did find the source in the included libraries. Is that the best place to be looking?
Thanks, all.
-
@MTcoder , as you can see I was told told about that lib. But you could look in the standard library dir or if you are just curious just try importing it.
There are a lot of libs included that are not documented.
If the lib you are after is not available as a batteries included or whatever you call it, if it's a pure Python lib, you can use Stash a community written tool to install it via pip.I am not sure if there is a easy way to have a script to list all these extra libs or not. Beyond my experience. I know it's not as simple as most listing the dir names in the standard library dir.
-
@MTcoder see in Modules& Templates/Standard Library (3.5)/sites-packages/PyPDF2
-
help('modules')
lists everything you can import. -
-
@MTcoder , I just learnt something also 😁
-
The same for me. I knew where to search but I didn't know this list of modules.
-
This post is deleted! -
This post is deleted!