简体   繁体   中英

How to get text position in PDF using PHP, TCPDF & FPDI?

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.

如果未加密PDF(没有主密码/客户密码),并且文本作为文本而不是作为渲染的图像嵌入,则可以对它进行一些基本的字符串搜索/替换-PDF本质上是Postscript代码,并且您可以将其大部分视为纯文本。

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 eg this question of mine for some background and possible solutions: PHP PDF template library with PDF output?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM