Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Or will it be best to create each and every document from scratch every time?

For one, it depends on the complexity of the document.  With simple/short documents it's probably "best" to create them from scratch every time — in case you want to operate at the PDF level yourself (like you would when using PDF::API2), and not use some higher level layout package like latex.

As for working with PDF templates, you should be aware that PDF is not a language for laying out documents, but rather a language for low-level description/rendering of drawing instructions, like "print those glyphs or lines at position x,y".  In other words, it doesn't do automatic paragraph layout, text block wrapping, page breaks, etc.

Also, the format doesn't lend itself particularly well to being templated directly, as it typically contains compressed content streams (which you could only modify in uncompressed form), and because the PDF file holds an index table specifying the byte offset of every "object" in the file (not the document index you see in a PDF viewer, but an internal one). When you modify one object in size, all offsets of the objects that follow in the document will have to be adjusted accordingly.

In case you really want to do templating directly at the PDF level, I'd suggest you use pdftk in combination with a template in uncompressed form.  In this case, you could essentially use any text templating module (though it would of course require a reasonable understanding of how PDF works), and pdftk would then handle compressing the document and recomputing the internal object offsets.  I wouldn't recommend this approach, however, unless you are (or want to become) familiar with the guts of PDF, and are making only minor changes, like filling in a few names or addresses, etc.


In reply to Re: PDF::API2 Questions by Eliya
in thread PDF::API2 Questions by akwe-xavante

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-25 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found