Luckily I had two great FLOSS tools to help: PDFtk and LibreOffice. The heavy lifting is done with pdftk and its multistamp operation. In my case, I had a 9-page PDF with signature lines on page 3 and page 9, so this is what I did:
- Determine the pages and locations on each page where you need to add text (in this case, a signature) (you can also add images). I went ahead and printed out the two pages I needed and used a ruler, but you can eyeball it to start, because you're likely to need to iterate anyway.
- Create a Writer document in Libreoffice. You can typically use libreoffice --writer to do this.
- Generate enough page breaks to match the number of pages in the PDF file. If you have a LOT of pages, you might consider using pdftk to break up your PDF into individual pages, and process each page separately. That exercise is left to the reader.
- On each page that needs, e.g., a signature line: create a table with two columns and two rows. Size the row height of the top (or bottom) row to get the other row in place. Then size the left (or right) column width to get the right cell into place. Make sure you uncheck "fit contents" so the row doesn't auto-resize.
- If you need more elements on the page, add more tables. You can put tables inside tables if you need to. Or, you can use frames or other elements to put text on the page.
- Don't forget to put your text and/or image into the correct cell!
- Save the Libreoffice document as a PDF.
- Use pdftk {PDF to sign} multistamp {PDF of signature(s)} output {Signed PDF} to sign the PDF. The output will have the name you gave to {Signed PDF}.
- Pretty likely, this won't work the first time. So go back to step #4 and adjust your row and column sizes, or frame positions, or whatever, and try again. I think it took me 3 iterations.
You might also take a look at stamptk in case that meets your needs! Keep in mind, though, that stamptk is a proprietary program, not FLOSS.
0 comments:
Post a Comment