I am working on a Rails application (Rails 3.1) and have the ability to upload a PDF file. The PDF file can then be downloaded by other users once they have logged in.
What I would really like to do is append the username of the current logged in user to the bottom of every one of the PDF pages. So at the bottom of every page in the PDF would be something like:
Downloaded from ww.mysite.com by Mr U. Name
I know how to make rails output a pdf from a view (as per a few tutorials), but I have never had to alter a PDF that has already been uploaded.
Side note: the PDF files are going to be outputs from Powerpoint and/or Keynote – so each page is a ‘slide’.
The pure ruby solutions are non-existent, but I’ve been doing the same kind of manipulation (adding print marks to an existing PDF) with a python script, using pyPdf and pycairo.
You can find it on Github, the bulk of the code is in draw-outline.py and outline.py.
I can extract a quick tutorial and post it here if you’re interested by this solution.
Update
I’ve extracted a quick script to add text to every page of an arbitrary PDF, it’s quick and dirty but it should do the job.
Usage:
Code: