1

I have an issue: I need to upload some PDF template with data and then change it. For example, in PDF file is string:

NAME:

I need get position of this string and insert some text (username etc.) after it.

Is it possible ?

Update

The PDF isn't encrypted. Text is embedded as text.

Jonas Heidelberg
  • 4,844
  • 1
  • 26
  • 41
user959436
  • 13
  • 1
  • 3

2 Answers2

0

If the PDF isn't encrypted (no master/client password), and the text is embedded as text and not as a rendered image, you can just do some basic string search/replace on it - PDFs are essentially Postscript code, and you can treat that as plain text for the most part.

Jonas Heidelberg
  • 4,844
  • 1
  • 26
  • 41
Marc B
  • 348,685
  • 41
  • 398
  • 480
0

This is not trivial and not possible with 100% reliability inside a PDF file because you may have to re-render the layout (to accommodate for elements moving, lines breaking etc.)

If you need to change some static form fields, you may be able to work with simple search+replace operations. For anything more complex, see e.g. this question of mine for some background and possible solutions: PHP PDF template library with PDF output?

Community
  • 1
  • 1
Pekka
  • 431,103
  • 135
  • 960
  • 1,075