[reportlab-users] inserting image in dynamic .prep file without saving image first
David
ldl08 at gmx.net
Tue Sep 2 19:08:25 EDT 2014
Dear Robin,
thank you for guiding me in the right direction. Seeking to take the
next steps, I tried to create a basic rml file following your
instructions (currently no preppy):
<para style="textstyle1">
<illustration height="200" width="150">
<image file="" x="0" y="0">
<inlineData filters="ascii85
gzip">Gaob at B35f%hoFCm>=?Gi.rhAp;,b;f,==7C>I_7M'on0oMCEGjZHTBh:!;#n7qH68DOY<?C0#"@bDN`&TDSYY
[...]
</inlineData>
</image>
</illustration>
</para>
Now, running
$ python trigger.py test_032_images_adapted.rml
runs without an error message and creates a PDF (attached). However, it
does not insert a graphic, just some text from the binary code.
Without any error messages I am at a loss as to where to look for the
problem. I assume my rml file to be faulty, but do not know how to
proceed from here.
I would greatly appreciate your insights and support!
Cheers,
David
On 29/08/14 11:16, Robin Becker wrote:
> On 29/08/2014 01:00, David wrote:
>> Dear list,
>>
>> following this recipe ( http://stackoverflow.com/a/19160507 ), I am
>> trying to emulate the "not saving an image on the hard disk" approach
>> for z3c and preppy in an dynamic .prep file.
>>
>> I fail and hope for your wisdom.
>>
>> Two questions:
>>
>
>
>
>> a) what object type does z3c.rml expect for images?
> I'm not exactly sure what's meant here: rml contains only text so unless
> z3c.rml provides plugin flowables or graphics theres only text available.
>
>
>> b) How would you suggest do I approach the goal of not saving images on
>> my hard drive yet inserting them in a pdf via z3c?
>>
> in modern rml you can use an inlineData tag inside an image tag. Our
> tests include this
>
> <illustration height="200" width="150">
> <image file="" x="0" y="0">
> <inlineData filters="ascii85
> gzip">Gaob at B35f%hoFCm>=?Gi.rhAp;,b;f,==7C>I_7M'on0oMCEGjZHTBh:!;#n7qH68DOY<?C0#"@bDN`&TDSYY(['=on[krFIEqTY4eZ:-1s\Q7i!$o?_#G/]#R#]D?n`E!JO#o*(^pV(_\!0-QBi:!M+"%6BJ^W[_-jNM*"IbEj0c;&#m>j?NXh1BeCE+"e'ldtf-c\O"pP9dL5
>
> .............
> [U.b0P5FS5q at Ae$iXUOQR?/_]6\uD;_Wi*G.Y<&_n\uUU-5QCdGa-HhT~></inlineData>
>
> </image>
> </illustration>
>
> so in your prep file you can just create the image as bytes and convert
> to a readable form using various compressions and encodings. The dtd
> says this
>
>
> <!ELEMENT image (inlineData?)>
> <!ATTLIST image
> file CDATA #REQUIRED
> x CDATA #REQUIRED
> y CDATA #REQUIRED
> width CDATA #IMPLIED
> height CDATA #IMPLIED
> inline CDATA #IMPLIED
> transparency_mask CDATA "auto"
> preserveAspectRatio (yes | no | 0 | 1) #IMPLIED
> showBoundary (yes | no | 0 | 1) #IMPLIED
> anchor (n|ne|e|se|s|sw|w|nw|c) #IMPLIED
> pdfBoxType (MediaBox | CropBox| TrimBox | BleedBox | ArtBox) #IMPLIED
> required (yes | no | 0 | 1 | true | false) "true"
> alt_file CDATA #IMPLIED
> type (pdf|bitmap) #IMPLIED
>>
> <!ELEMENT inlineData (#PCDATA)>
> <!--inlineData filters is a space separated list of filters which are
> applied in order
> allowed filters are
> base64 | ascii85 | bzip2 | gzip
> -->
> <!ATTLIST inlineData
> filters CDATA #REQUIRED
> >
> <!ELEMENT setFont EMPTY>
> <!ATTLIST setFont
> name CDATA #REQUIRED
> size CDATA #REQUIRED
> leading CDATA #IMPLIED
>>
>
>
>> Thanks for your guidance and creativity!
>>
>> David
> ....
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140903/639de196/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trigger.py
Type: text/x-python
Size: 459 bytes
Desc: not available
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140903/639de196/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_032_images_adapted.pdf
Type: application/pdf
Size: 24819 bytes
Desc: not available
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140903/639de196/attachment-0001.pdf>
More information about the reportlab-users
mailing list