[reportlab-users] Image from string instead of a disk file

Richard Shea rshea at thecubagroup.com
Tue Jun 3 17:58:46 EDT 2014


Can't you just create a set of Reportlab Image objects before creating
any documents and pass those in as parameters whenever
report_lab_script is called ?



Alternatively (and really in some ways equivalent just moving down an
abstraction layer) before you get going you could move your graphics
files off disk into memory mapped files ([1]http://pymotw.com/2/mmap/)
and instantiate image based on those.



If your four to nine graphics are different for each document neither
of these are much good (unless each graphic appears multiple times
within a document and even then I'm not sure that doesn't get optimised
away by the PDF standard) but either way I don't see how passing them
in as strings would help ?



I'm sure you have good reasons for suggesting strings but perhaps you
could explain a little more ?



regards



Richard.









On Wed, Jun 4, 2014, at 08:40 AM, Jack Wilkinson wrote:

This is one of those cases where better planning in the beginning might
have been a good idea.  But now we’re deep in production without
resources or time to go back and work out a better solution.

Our reporting mechanism looks something like:

main_program

                result = report_lab_script(some parameters)

                back to main program that processes the result

This works well for now.  But we expect to see the quantity of data
increase by major quantities.

The report_lab_script, depending on the parameters handed to it, may
open and use between four and nine images each time it gets called.
(It uses the “Image” routine.) That means a lot of file I/O for each
page or group of pages produced in each iteration.

I’m curious if there’s a way to read all of the images in the beginning
of the main_program into strings and then just pass those strings to
the report_lab_script so it doesn’t have to do the file I/O to read the
files every time.  However, “Image” seems to only take a filename.

Just grasping for straws before I end-up re-writing the world.

Appreciate any thoughts…

jack

Jack Wilkinson, Programmer

Services | VPay®

P: 972.367-6622

[2]jwilkinson at stoneeagle.com

[3]www.stoneeagle.com

[4]www.vpayusa.com

111 W. Spring Valley Rd., #100

Richardson, TX 75081

CONFIDENTIALITY NOTICE: This email, including any attachments, is for
the sole use of the intended recipient(s) and may contain confidential
and privileged information. Any unauthorized review, use, disclosure,
or distribution is prohibited. If you received this email and are not
the intended recipient, please inform the sender by email reply and
destroy all copies of the original message.

_______________________________________________

reportlab-users mailing list

[5]reportlab-users at lists2.reportlab.com

[6]http://two.pairlist.net/mailman/listinfo/reportlab-users

References

1. http://pymotw.com/2/mmap/
2. mailto:jwilkinson at stoneeagle.com
3. http://www.stoneeagle.com/
4. http://www.vpayusa.com/
5. mailto:reportlab-users at lists2.reportlab.com
6. http://two.pairlist.net/mailman/listinfo/reportlab-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140604/e8320f60/attachment-0001.html>


More information about the reportlab-users mailing list