omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    watermark pdf
    8
    16
    13819
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Phuket2
      Phuket2 last edited by

      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

      1 Reply Last reply Reply Quote 1
      • smath
        smath last edited by

        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.

        Phuket2 1 Reply Last reply Reply Quote 0
        • Phuket2
          Phuket2 @smath last edited by

          @smath , the watermark is to be added to every page of an existing pdf file

          1 Reply Last reply Reply Quote 0
          • Phuket2
            Phuket2 last edited by

            @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?

            1 Reply Last reply Reply Quote 0
            • JonB
              JonB last edited by

              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

              1 Reply Last reply Reply Quote 5
              • omz
                omz last edited by omz

                I can confirm that the approach in @JonB's link works in Pythonista. Simply replace pyPdf with PyPDF2 in the first import statement (note the different capitalization).

                1 Reply Last reply Reply Quote 3
                • Phuket2
                  Phuket2 last edited by

                  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

                  1 Reply Last reply Reply Quote 1
                  • MTcoder
                    MTcoder last edited by

                    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.

                    Phuket2 cvp 2 Replies Last reply Reply Quote 0
                    • Phuket2
                      Phuket2 @MTcoder last edited by

                      @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.

                      1 Reply Last reply Reply Quote 0
                      • cvp
                        cvp @MTcoder last edited by cvp

                        @MTcoder see in Modules& Templates/Standard Library (3.5)/sites-packages/PyPDF2

                        1 Reply Last reply Reply Quote 0
                        • omz
                          omz last edited by

                          help('modules') lists everything you can import.

                          1 Reply Last reply Reply Quote 0
                          • MTcoder
                            MTcoder last edited by

                            @Phuket2 @cvp @omz Thank you all. I've never seen a community that is as willing to help as this one. Maybe it's because we have such a splendid tool in our hands!

                            Phuket2 1 Reply Last reply Reply Quote 2
                            • Phuket2
                              Phuket2 @MTcoder last edited by

                              @MTcoder , I just learnt something also 😁

                              1 Reply Last reply Reply Quote 0
                              • cvp
                                cvp last edited by

                                The same for me. I knew where to search but I didn't know this list of modules.

                                1 Reply Last reply Reply Quote 1
                                • JonesSmith
                                  JonesSmith last edited by JonesSmith

                                  This post is deleted!
                                  1 Reply Last reply Reply Quote 0
                                  • Asherhat
                                    Asherhat last edited by

                                    This post is deleted!
                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post
                                    Powered by NodeBB Forums | Contributors