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
-
@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: # ...
-
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.
-
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!
-
@omz Congratulations! This custom action is really nicely done! Thanks.
-
This post is deleted! -
@NikkiSchwartzVB Did @omz's
PDF with page numbers
workflow do what you wanted? To me, it seemed like all the right stuff... -
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.
-
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. -
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.
-
@omz thanks again! It's overall fan friggin tastic. :)
I'll play with this soon