Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
It appears that external objects (specifically, image files placed on the various pages) are not actually read until the pdf->save() call at the end.

I think PDF::Reuse was designed for fast pdf generation with data consumed as they come and pdf parts/portions written (and data disposed) as soon as they are ready. My impression from reading PDF::API2 sources was it also had that goal to write/forget parts no longer required, but it wasn't implemented in earnest. If your concern is that "a very few gigabytes" file would be kept in memory until finally saved -- then yes, it would (i.e. if you succeed).

If, OTOH, the only issue is with 10000 temp files scattered around -- it's only true for jpeg images, which are imported using their filenames. See this line and thereabouts. The private ' streamfile' key is nowhere to be found in modules to import other image formats. Reading same source file, pass a filehandle instead of filename, but note (line 42) tiny 512 bytes buffer as opposed to 4096 bytes, which would be used in your original test when all jpeg files are read "at the end".

Without SSCCE, I can't comment on GD being that much slow, but I'm surprised "decode jpeg -- scale -- encode jpeg (and that into memory, not disk file!)" can be be 100 times faster/slower.

In reply to Re: PDF::API2 external objects by vr
in thread PDF::API2 external objects by dd-b

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 or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2022-10-05 21:42 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (25 votes). Check out past polls.