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.


    Adding a page header to PDF output

    Editorial
    3
    15
    15934
    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.
    • omz
      omz last edited by

      @ccc For some reason, PdfFileReader.pages doesn't seem to work properly. Possible workaround:

      fg_reader = PyPDF2.PdfFileReader(fg_file)
      fg_pages = [fg_reader.getPage(i) for i in range(fg_reader.getNumPages())]
      for page in fg_pages:
          # ...
      
      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        I've taken @ccc's basic approach, and turned it into a complete workflow:

        http://www.editorial-workflows.com/workflow/5807752689483776/zRswEIOv3yY

        The core of this is a custom (Python) action that takes a PDF (generated by the standard "HTML to PDF" action), and adds header/footer text on every page. The text can include regular workflow variables (client name, date...) and page numbers – {p} is automatically replaced by the current page number, and {n} is replaced by the total number of pages.

        A couple of other things, like font size, margins etc. are also easily configurable by editing the workflow.

        1 Reply Last reply Reply Quote 2
        • NikkiSchwartzVB
          NikkiSchwartzVB last edited by

          Yes, please! And thank you?

          I had assumed this was a lost cause.

          It'll take me a few days to check this out and implement it.

          I'm planning on trying to simplify some of the workflow I've created on the directory as well... In an effort to contribute to the community, FWIW.

          The workflows I've put together to write this report have worked well. Albeit with some bugs, but that is to be expected.

          Thank you all, again, so much!

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

            @omz Congratulations! This custom action is really nicely done! Thanks.

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

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

                @NikkiSchwartzVB Did @omz's PDF with page numbers workflow do what you wanted? To me, it seemed like all the right stuff...

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

                  I had a chance to play with it last night. It's fantastic.

                  There is a weird character that shows up at the end of the header text, a black box. But it's not a deal breaker.

                  Otherwise, it's perfect.

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

                    weird character that shows up at the end of the header text, a black box

                    My bet is that is a carriage return (\n) at the end of your header text.
                    If your header text ends in a variable then be sure to .rstrip() the text before putting it into that variable.
                    In any case, make sure that the last character in the header text field is not \n.

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

                      I've updated the workflow to remove leading and trailing line breaks from header/footer text, as they are indeed rendered as a black box (multiple lines are not supported at all, sorry).

                      Depending on how you generate the header text, it might also be easy to avoid having it end with a line break.

                      NikkiSchwartzVB 1 Reply Last reply Reply Quote 1
                      • NikkiSchwartzVB
                        NikkiSchwartzVB @omz last edited by

                        @omz thanks again! It's overall fan friggin tastic. :)

                        I'll play with this soon

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Powered by NodeBB Forums | Contributors