简体   繁体   中英

Replacing plain text with iText

We are currently migrating from Aspose.PDF to iText . After migrating all legacy Aspose code only the replacing of plain text in an existing PDF is left and after reading several tutorials and the examples page on http://itextsupport.com/ I still don't get how to replace a text in PDF.

To make it more specific:

There is a base PDF which contains text and parts of this text shall be replaced or removed. Not only visually but as well on a meta-level. In Aspose there is something called PdfContentEditor which achieve exactly this. For me it is not important if the actual PDF is modified or if a new PDF based on the base PDF and the modification is created.

Anyone out there who did this already with iText?

That's not possible. Why?

  • pdf documents contain only the instructions needed to render the document in a viewer. (eg "go to position 10, 20, render character 'Z')
  • there is no higher level information (such as "this text belongs in one line", "these lines make up one paragraph")

Suppose you wanted to replace the word "alpha" with "the first item". Then you would expect all items in the same line to reflow. But (see earlier), the document simply doesn't have the information to know what belongs on the same line. Nor is it trivial to determine what elements belong together.

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