Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF: insert a line of text into an existing PDF file

Tags:

bash

php

pdf

I have a PDF file and I wish to add on the footer of all pages (except the first two) a line of plain text (not a logo or something alike).

Did anyone has an example of how this can be done (in any language)?

Update: The original PDF was made with Scribus and I have total control of it. So if it easier to make a find&replace operation, that's fine too.

like image 560
Roger Avatar asked Oct 09 '22 18:10

Roger


1 Answers

If "the footer" is defined by a position (i.e. specified in millimeters for example), you can just use your favorite language (TeX, PHP, FPDF, Postscript, ...) to render a PDF containing the two lines and then overlay this PDF on top of your existing PDF using pdftk.

If you want to apply the overlay only to the first two pages, you have to use a temporary file like this:

pdftk input.pdf stamp overlay.pdf output temp.pdf
pdftk A=input.pdf B=temp.pdf cat A1-2 B3-end output result.pdf
like image 194
AndreKR Avatar answered Oct 13 '22 10:10

AndreKR