2

I have a pdf file (pdf sample) with some strings as a placeholder. These strings have the following syntax <box:*> I want to develop a C# application that, using iTextSharp, searches for all occurrences within the document (I would like the entire contents of the tag) and for each of these also get the location (X,Y) in the document.

Is this possible? Can you provide me source code?

Thanks, Luigi.

Damon
  • 3,004
  • 7
  • 24
  • 28
Gigi
  • 315
  • 7
  • 23
  • 1
    Meanwhile a parser package also has been added to iText(Sharp) which can be used for searching the PDF content. You will have to extend the `*ExtractionStrategies` included in the library, though, to return text with coordinates, not merely text. I assume, though, that you do not merely want to find those texts but also (calling them *placeholders*) **replace** them. This will be a far greater challenge unless your PDFs are very simple and you don't expect anything like reflowing of the existing text. BTW, in general you should use form fields as place holders. – mkl Sep 10 '13 at 09:25
  • Thanks for the reply. I did not think to replace the placeholders. In fact, these will be hidden. What I need is their position (X,Y) and their content. (eg: from this placeholder: `` I want to retrieve: `Cliente\w10.2\h2\l-0.2\t0.4` and its location). Could you provide me the code to extend the `ExtractionStrategies` to return text with coordinates. Thanks. – Gigi Sep 10 '13 at 10:00
  • 1
    I don't have ready code at my hand. The pointers in the following answers might help, though: http://stackoverflow.com/questions/12875766/itextsharp-find-coordinates-of-specific-text-in-pdf/12876331#12876331 - http://stackoverflow.com/questions/13632541/get-the-exact-stringposition-in-pdf/13642486#13642486 - http://stackoverflow.com/questions/13714605/retrieve-the-respective-coordinates-of-all-words-on-the-page-with-itextsharp/13719947#13719947 --- but even for merely hiding, form fields would be the much better technique: They are trivial to find, read, and remove. – mkl Sep 10 '13 at 10:09

1 Answers1

0

Looks like it's possible.

John Bubriski wrote in his Blog about a situation like this.

Community
  • 1
  • 1