Data::Dumper was only my first quick and dirty solution; I noticed that its output contains lots of stuff, and in places there is often something like

#(250.00, 650.00) This is some pdftext

The text in coordinates is presumably the position on the page. With some assumptions (font size is always 10-12, box width can also constrained/guessed meaningfully), I could put a hyperlink there, which would approximately be at the right position.

Afterwards, manual editing could remove the URL or change it. This would still be much quicker than setting all the URLs manually from scratch. I would also happily switch to a different tool that accomplishes dumping text and position to a text file. For instance, we have acrobat 8 here but I haven't tried its javascript API. A table of

### page ### position x,y ### matched text ####

would suffice for a while. I could use this as input for my script.

I still don't know what to do with text that wraps around on the page, though. These hyperlinks would be incomplete and hence invalid.


In reply to Re^2: PDF::API2 to search for text in PDF file by knbknb
in thread PDF::API2 to search for text and place hyperlinks in PDF file by knbknb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.