in general i don't think it's possible to do in the easy way we all want to do it. from what i've seen of PDF, the layout is done by the creating application. by this i mean that whereas in Postscript somebody might have:

(This is the Title) centered-bold

a PDF file would have more something like:

x y moveto (This is the Title) show

my code is way off, but the idea is that the application determines the absolute position of the text to show, so even if you can read the PDF and unpack the text strings from whatever format they're in, if you change the text then you change the layout and your PDF is going to be all messed up.

Postscript tends more to having code in the file to handle the layout, and you pass a chunk of text to the code and it get's laid out as the program is run on the printer.so if you change a word in the middle of the paragraph it won't cause the line to run off the edge of the page. the absolute position isn't determined untill run-time.

this is based on looking at a bunch of PDF modules and always seeing things like put_text(x,y,text) which returns how many x's are left in the line. it seems that the PDF creator is responsible for things like wrapping/centering text.

does this make any sense?


In reply to Re: Replacing text in a PDF file by zengargoyle
in thread Replacing text in a PDF file by Basilides

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.