Coder Social home page Coder Social logo

z3c.rml's Introduction

z3c.rml -- An alternative implementation of RML

Latest Version

Supported Python versions

Build Status

image

This is an alternative implementation of ReportLab's RML PDF generation XML format. Like the original implementation, it is based on ReportLab's reportlab library.

You can read all about z3c.rml and see many examples on how to use it, see the RML Reference

Install on pip:

pip install z3c.rml

z3c.rml is then available on the commandline as z3c.rml.:

$ z3c.rml --help
usage: rml2pdf [-h]
               xmlInputName [outputFileName] [outDir]
               [dtdDir]

Converts file in RML format into PDF file.

positional arguments:
  xmlInputName    RML file to be processed
  outputFileName  output PDF file name
  outDir          output directory
  dtdDir          directory with XML DTD (not yet supported)

optional arguments:
  -h, --help      show this help message and exit

Copyright (c) 2007 Zope Foundation and Contributors.

Save this file as file.rml:

<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="example_01.pdf">
 <template showBoundary="1"> <!--Debugging is now turned on, frame outlines -->
 <!--will appear on the page -->
 <pageTemplate id="main">
 <!-- two frames are defined here: -->
 <frame id="first" x1="100" y1="400" width="150" height="200"/>
 <frame id="second" x1="300" y1="400" width="150" height="200"/>
 </pageTemplate>
 </template>
 <stylesheet>
 <!-- still empty...-->
 </stylesheet>
 <story>
 <para>
 Welcome to RML.
 </para>
 </story>
</document>

Then run:

$ z3c.rml file.rml

The output will be example_01.pdf as defined in the document

Codewise you can do:

from z3c.rml import rml2pdf
rml2pdf.go('file.rml','file.pdf')

z3c.rml's People

Contributors

1letter avatar abdur-rahmaanj avatar agroszer avatar cyrusv avatar dataflake avatar ewang avatar jamadden avatar jordanvance avatar jugmac00 avatar kedder avatar kylemacfarlane avatar marcinn avatar menesis avatar mgedmin avatar niharikasingh avatar projekt01 avatar rapto avatar regebro avatar shudac avatar simonphilips avatar sjustas avatar strichter avatar toanant avatar wichert avatar zopyx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

z3c.rml's Issues

useCropMarks or cropMarks doesn't change pdf box dimensions

  <docinit useCropMarks="1">

This produces a document with visible crop marks and bleed. However inspecting the document in acrobat reveals that the all boxes have the same size. If I am not wrong, this code should make the make trimbox < mediabox by 36pt on all sides - 36pt is the default for this attribute.

Here's the test pdf, it can be inspected in acrobat by "Set Page Boxes" in toolset.

blockTableStyle used repeatedly plus td style causes index out of range in platypus

The following valid RML causes an exception in platypus.

<!DOCTYPE document SYSTEM "rml.dtd"> 
<document filename="bug-table-style.pdf">
    <pageInfo pageSize="A4" />
    <template showBoundary="0">
    <pageTemplate id="main">
        <frame id="first" x1="10mm" y1="15mm" width="190mm" height="272mm"/>
    </pageTemplate>
    </template>

<stylesheet>
    <blockTableStyle id="my-table-style">
    <blockFont name="Helvetica-Bold" size="6" start="0,0" stop="-1,-1"/>
    </blockTableStyle>
</stylesheet>

<story>
    <blockTable style="my-table-style" colWidths="50% 50%">
    <tr>
        <td>Item1</td>
        <td align="right">$1.00</td>
    </tr>
    <tr>
        <td>Item2</td>
        <td align="right">$2.00</td>
    </tr>
    </blockTable>
    <blockTable style="my-table-style" colWidths="50% 50%">
    <tr>
        <td>Item3</td>
        <td align="right">$3.00</td>
    </tr>
    </blockTable>
</story>

</document>

The exception is the following one:

    rml2pdf.go(self._inPath, self._outPath)
  File "/home/fvicente/tmp/z3c.rml-master/src/z3c/rml/rml2pdf.py", line 61, in go
    doc.process(outputFile)
  File "/home/fvicente/tmp/z3c.rml-master/src/z3c/rml/document.py", line 688, in process
    self.processSubDirectives(select=('template', 'story'))
  File "/home/fvicente/tmp/z3c.rml-master/src/z3c/rml/directive.py", line 118, in processSubDirectives
    directive.process()
  File "/home/fvicente/tmp/z3c.rml-master/src/z3c/rml/template.py", line 37, in process
    self.parent.flowables = super(Story, self).process()
  File "/home/fvicente/tmp/z3c.rml-master/src/z3c/rml/flowable.py", line 1542, in process
    self.processSubDirectives()
  File "/home/fvicente/tmp/z3c.rml-master/src/z3c/rml/directive.py", line 118, in processSubDirectives
    directive.process()
  File "/home/fvicente/tmp/z3c.rml-master/src/z3c/rml/flowable.py", line 695, in process
    table = self.klass(self.rows, style=self.style, **attrs)
  File "/home/fvicente/tmp/z3c.rml-master/src/reportlab/platypus/tables.py", line 285, in __init__
    self.setStyle(style)
  File "/home/fvicente/tmp/z3c.rml-master/src/reportlab/platypus/tables.py", line 1000, in setStyle
    self._addCommand(cmd)
  File "/home/fvicente/tmp/z3c.rml-master/src/reportlab/platypus/tables.py", line 1063, in _addCommand
    _setCellStyle(self._cellStyles, i, j, op, values)
  File "/home/fvicente/tmp/z3c.rml-master/src/reportlab/platypus/tables.py", line 1542, in _setCellStyle
    new = cellStyles[i][j]
IndexError: list index out of range

Doing some debugging shows that the align of the second td row in the first table is being transported to the second table that only has one row, causing platypus trying to access an invalid index in the matrix. If you do not use style on the second table, or if you remove the second align in the first table it works!!!

To fix the problem I've patched platypus module for checking the matrix boundaries, but probably the problem is in a higher level (at XML parsing maybe?).

My fix in reportlab/platypus/tables.py:

            (op, (sc, sr), (ec, er)), values = cmd[:3] , cmd[3:]
            if sc < 0: sc = sc + self._ncols
            if ec < 0: ec = ec + self._ncols
            if sr < 0: sr = sr + self._nrows
            if er < 0: er = er + self._nrows
            # my 2 lines to fix the issue
            if er > self._nrows - 1: er = self._nrows - 1
            if ec > self._ncols - 1: ec = self._ncols - 1
            #
            for i in xrange(sr, er+1):
                for j in xrange(sc, ec+1):
                    _setCellStyle(self._cellStyles, i, j, op, values)

<td>colspan & rowspan

Hello, I read the reportlab document and found that contains the attributes of colspan and rowspan, but it seems that it cannot be used in the current project. Is it not supported?
Thanks Reply

Zope independency

How hard to make subj as zope-independent?
Without importing zope.interface etc zope.* in most of files.
An idea is to use subj in other applications outside zope world without zope.* footprints.

Barchart was ignored

Input file

<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="01.pdf">
 <template>
 <!--this section contains elements of the document -->
 <!--which are FIXED into position. -->
 <pageTemplate id="main">
 <frame id="first" x1="100" y1="400" width="150" height="200"/>
 </pageTemplate>
 </template>
 <stylesheet>
 <!--this section contains the STYLE information for -->
 <!--the document, but there isn't any yet. The tags still -->
 <!--have to be present, however, or the document won't compile.-->
 </stylesheet>
 <story>
 <!--this section contains the FLOWABLE elements of the -->
 <!--document. These elements will fill up the frames -->
 <!--defined in the <template> section above. -->
 <para>
 Welcome to RML!
 </para>
 <para>
 This is the "story". This is the part of the RML document where
 your text is placed.
 </para>
 <para>
 It should be enclosed in "para" and "/para" tags to turn it into
 paragraphs.
 </para>
 <barChart dx="2in" dy="7in" dwidth="6in" dheight="4in" x="0" y="0" width="5in"
 height="3in" barSpacing="7" groupSpacing="15">
 <bars>
 <bar fillColor="blue" strokeColor="red" strokeWidth="0.5"/>
 <bar fillColor="yellow" strokeColor="green" strokeWidth="1"/>
 </bars>
 <categoryAxis strokeColor="black" strokeWidth="1">
 <labels fontName="Helvetica" fontSize="20"/>
 <categoryNames>
 <name>Category 1</name>
 <name>Category 2</name>
 <name>Category 3</name>
 <name>Category 4</name>
 </categoryNames>
 </categoryAxis>
 <valueAxis valueMin="0" valueMax="150" valueStep="30" visibleTicks="true"
 visibleLabels="true" forceZero="true">
 <labels fontName="Helvetica"/>
 </valueAxis>
 <data>
 <series>100 110 120 130</series>
 <series> 70 80 85 90</series>
 </data>
</barChart>

 </story>
</document>

Error

Directive 'barChart' could not be processed and was ignored. (file input/barchart.xml, line 31)

Info

Py v: 3.8
Z3c.rml v: 4.1.1
Os: win7

Code for barchart.py

from z3c.rml import rml2pdf
# rml = open('input/01.xml','r').read()
filename = __file__.split('.')[0]
rml2pdf.go('input/{}.xml'.format(filename),'output/{}.pdf'.format(filename))

Output pdf

barchart.pdf

blockTableStyle not working:

python 3.7.5, z3c.rml 3.9.1 , flask 1.1.1;

test.zip

The BlockTable with style attribute will cause error๏ผš

Traceback (most recent call last):
  File "c:\users\adm\venv\lib\site-packages\flask\app.py", line 2463, in __call__
    return self.wsgi_app(environ, start_response)
  File "c:\users\adm\venv\lib\site-packages\flask\app.py", line 2449, in wsgi_app
    response = self.handle_exception(e)
  File "c:\users\adm\venv\lib\site-packages\flask\app.py", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "c:\users\adm\venv\lib\site-packages\flask\_compat.py", line 39, in reraise
    raise value
  File "c:\users\adm\venv\lib\site-packages\flask\app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "c:\users\adm\venv\lib\site-packages\flask\app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "c:\users\adm\venv\lib\site-packages\flask\app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "c:\users\adm\venv\lib\site-packages\flask\_compat.py", line 39, in reraise
    raise value
  File "c:\users\adm\venv\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "c:\users\adm\venv\lib\site-packages\flask\app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\adm\Desktop\test.py", line 15, in test
    datau= rml2pdf.go('test-pars.xml', outputFileName=buf)
  File "c:\users\adm\venv\lib\site-packages\z3c\rml\rml2pdf.py", line 73, in go
    doc.process(outputFile)
  File "c:\users\adm\venv\lib\site-packages\z3c\rml\document.py", line 721, in process
    self.doc.multiBuild(self.flowables, maxPasses=maxPasses)
  File "c:\users\adm\venv\lib\site-packages\reportlab\platypus\doctemplate.py", line 1143, in multiBuild
    self.build(tempStory, **buildKwds)
  File "c:\users\adm\venv\lib\site-packages\reportlab\platypus\doctemplate.py", line 1056, in build
    self.handle_flowable(flowables)
  File "c:\users\adm\venv\lib\site-packages\reportlab\platypus\doctemplate.py", line 912, in handle_flowable
    if frame.add(f, canv, trySplit=self.allowSplitting):
  File "c:\users\adm\venv\lib\site-packages\reportlab\platypus\frames.py", line 217, in _add
    flowable.drawOn(canv, self._x + self._leftExtraIndent, y, _sW=aW-w)
  File "c:\users\adm\venv\lib\site-packages\reportlab\platypus\flowables.py", line 114, in drawOn
    self._drawOn(canvas)
  File "c:\users\adm\venv\lib\site-packages\reportlab\platypus\flowables.py", line 95, in _drawOn
    self.draw()#this is the bit you overload
  File "c:\users\adm\venv\lib\site-packages\reportlab\platypus\tables.py", line 1482, in draw
    self._drawLines()
  File "c:\users\adm\venv\lib\site-packages\reportlab\platypus\tables.py", line 1116, in _drawLines
    self.canv.setDash(dash)
  File "c:\users\adm\venv\lib\site-packages\reportlab\pdfgen\canvas.py", line 1740, in setDash
    bad = [_ for _ in array if not isinstance(_,(int,float)) or _ < 0]
TypeError: 'object' object is not iterable

Issues properly rendering Burmese/Myanmar in PDFs

What I did:

Attempt to generate PDFs using Bermese text encoded in UTF-8. Specifically created a new virtual environment, installed z3c.rml, and generated a PDF using the rml2pdf command using the below script.

What I expect to happen:

The text to be rendered according to http://unicode.org/notes/tn11/UTN11_3.pdf, and hence to match what I see in an editor when constructing the rml (though, in practice, our text is dynamic).

What actually happened:

We're encountering some problems attempting to build PDFs using Burmese.ย  The problem doesn't seem restricted to a specific font, as at least NotoSansMyanmar (https://www.google.com/get/noto/#sans-mymr) and Padauk (https://fonts.google.com/specimen/Padauk) both have these issues.ย  Although independent characters seem to be represented correctly, some of the vowels and medials (and perhaps other items as well) seem to have some rendering issues.

The issue we originally ran into was that theย ย U+103C MYANMAR CONSONANT SIGN MEDIAL RA was misplaced, seeming to be placed following the consonant instead of decorating it, as per http://unicode.org/notes/tn11/UTN11_3.pdf (from which I pulled many examples).ย  As a simple example, the stringย "แ€€แ€ผ" (represented by code points U+1000 U+103c), would appear as two separate characters "แ€€ย แ€ผ" instead of being combined. If there was a character following that first "แ€€", "ย แ€ผ" would decorate that character instead.

An example rml document, showing this:

<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="burmese-noto-test.pdf">

  <docinit>
    <registerTTFont faceName="OpenSans" fileName="NotoSansMyanmar-Regular.ttf" />
  </docinit>

  <template>
    <pageTemplate id="main">
      <frame id="first" x1="72" y1="72" width="451" height="698"/>
    </pageTemplate>
  </template>

  <stylesheet>
    <paraStyle name="para" fontName="OpenSans"/>
    <paraStyle name="intended" leftIndent="0.5cm" fontName="OpenSans"/>
    <paraStyle name="h1"
      fontName="Courier-Bold"
      fontSize="12"
      spaceBefore = "0.5 cm"
      />
    <paraStyle name="h2"
      fontName="Courier"
      fontSize="10"
      spaceBefore = "0.5 cm"
      />
  </stylesheet>

  <story>
    <title>Test of Burmese: UTF-8</title>

    <para style="h1">Consonants (appear properly rendered)</para>
    <para style="para" spaceBefore="0.1cm">
      &#x1000;
      &#x1001;
      &#x1002;
      &#x1003;
      &#x1004;
      &#x1005;
      &#x1006;
      &#x1007;
      &#x1008;
      &#x1009;
      &#x100a;
      &#x100b;
      &#x100c;
      &#x100d;
      &#x100e;
      &#x100f;
    </para>
    <para style="para" spaceBefore="0.1cm">
      &#x1010;
      &#x1011;
      &#x1012;
      &#x1013;
      &#x1014;
      &#x1015;
      &#x1016;
      &#x1017;
      &#x1018;
      &#x1019;
      &#x101a;
      &#x101b;
      &#x101c;
      &#x101d;
      &#x101e;
      &#x101f;
    </para>
    <para style="para" spaceBefore="0.1cm">
      &#x1020;
      &#x1021;
    </para>

    <para style="h1">Independent Vowels (appear properly rendered)</para>
    <para style="para" spaceBefore="0.1cm">
      &#x1023;
      &#x1024;
      &#x1025;
      &#x1026;
      &#x1027;
      &#x1029;
      &#x102a;
    </para>
    <para style="para" spaceBefore="0.1cm">
      &#x1021;&#x102d;
      &#x1021;&#x102e;
      &#x1021;&#x102f;
      &#x1021;&#x1030;
      &#x1021;&#x1031;
      &#x1021;&#x1031;&#x102c;
      &#x1021;&#x1031;&#x102c;&#x103a;
    </para>

    <para style="h1">Medials (problems with second and third examples)</para>
    <para style="h2">Ex. 1</para>
    <para style="intended" spaceBefore="0.1cm">
      แ€–แ€ปแ€ฌแ€ธ
    </para>
    <para style="intended" spaceBefore="0.1cm">
      <!-- same as above, using code points -->
      &#x1016;&#x103b;&#x102c;&#x1038;
    </para>

    <para style="h2">Ex. 2</para>
    <para style="intended" spaceBefore="0.1cm">
      แ€€แ€ผแ€ฑแ€ธ
    </para>
    <para style="intended" spaceBefore="0.1cm">
      <!-- same as above, using code points -->
      &#x1000;&#x103C;&#x1031;&#x1038;
    </para>

    <para style="h2">Ex. 3</para>
    <para style="intended" spaceBefore="0.1cm">
      แ€™แ€ฝแ€ฑแ€ธ
    </para>
    <para style="intended" spaceBefore="0.1cm">
      <!-- same as above, using code points -->
      &#x1019;&#x103D;&#x1031;&#x1038;
    </para>

    <para style="h2">Ex. 4</para>
    <para style="intended" spaceBefore="0.1cm">
      แ€™แ€พแ€ฏ
    </para>
    <para style="intended" spaceBefore="0.1cm">
      <!-- same as above, using code points -->
      &#x1019;&#x103E;&#x102F;
    </para>

    <para style="h1">U+1031 -e vowel (seems problematic)</para>
    <para style="para" spaceBefore="0.1cm">
      แ€”แ€ฑ
    </para>
    <para style="para" spaceBefore="0.1cm">
      <!-- same as above, using code points -->
      &#x1014;&#x1031;
    </para>

    <para style="h1">Syllable Chaining (seems problematic)</para>
    <para style="para" spaceBefore="0.1cm">
      แ€•แ€แ€นแ€แ€ฌ
    </para>
    <para style="para" spaceBefore="0.1cm">
      <!-- same as above, using code points -->
      &#x1015;&#x1010;&#x1039;&#x1010;&#x102C;
    </para>


    <para style="h1">Other Examples</para>
    <para style="para" spaceBefore="0.5cm">
      แ€™แ€ผแ€”แ€บแ€™แ€ฌแ€กแ€€แ€นแ€แ€›แ€ฌ
    </para>
    <para style="para">
      <!-- same as above, using code points -->
      &#x1019;&#x103c;&#x1014;&#x103a;&#x1019;&#x102c;&#x1021;&#x1000;&#x1039;&#x1001;&#x101b;&#x102c;
    </para>

    <para style="para"  spaceBefore="0.5cm">
      แ€€แ€ญแ€ฏแ€…แ€ญแ€ฏแ€ธแ€€แ€ผแ€Šแ€บ
    </para>
    <para style="para">
      <!-- same as above, using code points -->
      &#x1000;&#x102d;&#x102f;&#x1005;&#x102d;&#x102f;&#x1038;&#x1000;&#x103c;&#x100a;&#x103a;
    </para>

    <para style="para" spaceBefore="0.5cm">
      แ€…แ€„แ€บแ€นแ€€แ€ผ
    </para>
    <para style="para">
      <!-- same as above, using code points -->
      &#x1005;&#x1004;&#x103A;&#x1039;&#x1000;&#x103C;&#x1036;
    </para>
  </story>
</document>

What version of Python and Zope/Addons I am using:

Python versions 2.7.17 or 3.7.5, both produced the same result.

For zope, this is a result of running pip list in the virtual env I set up for the test:

Package            Version
------------------ ---------
backports.tempfile 1.0
backports.weakref  1.0.post1
lxml               4.5.0
Pillow             7.1.1
pip                20.1b1
Pygments           2.6.1
PyPDF2             1.26.0
reportlab          3.5.42
setuptools         44.1.0
six                1.14.0
wheel              0.34.2
z3c.rml            3.10.0
zope.event         4.4
zope.interface     5.1.0
zope.schema        6.0.0

How to use custom fonts?

Hi,

when I use zc3.rml as a standalone command line tool, how would I configure it to use custom fonts?

Or are there special directories where I have to put my font files?

I am using Ubuntu 18.04.

Thank you very much!

Support Pillow v6 (module 'PIL.Image' has no attribute 'VERSION')

Actually i have following error:
Django==2.2.2
Pillow==6.0.0
z3c.rml==3.8.0

AttributeError: module 'PIL.Image' has no attribute 'VERSION'
identity=[ImageReader@0x7f0ab88065c0]
  File "django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "workflow/views/formats_views.py", line 76, in get
    pdf = rml2pdf.parseString(markup)
  File "/usr/local/lib/python3.6/dist-packages/z3c/rml/rml2pdf.py", line 39, in parseString
    doc.process(output)
  File "/usr/local/lib/python3.6/dist-packages/z3c/rml/document.py", line 721, in process
    self.doc.multiBuild(self.flowables, maxPasses=maxPasses)
  File "reportlab/platypus/doctemplate.py", line 1056, in multiBuild
    self.build(tempStory, **buildKwds)
  File "reportlab/platypus/doctemplate.py", line 966, in build
    self.clean_hanging()
  File "reportlab/platypus/doctemplate.py", line 554, in clean_hanging
    self.handle_flowable(self._hanging)
  File "reportlab/platypus/doctemplate.py", line 828, in handle_flowable
    f.apply(self)
  File "reportlab/platypus/doctemplate.py", line 146, in apply
    getattr(doc,arn)(*args)
  File "reportlab/platypus/doctemplate.py", line 579, in handle_pageBegin
    self.pageTemplate.onPage(self.canv,self)
  File "/usr/local/lib/python3.6/dist-packages/z3c/rml/template.py", line 155, in drawOnCanvas
    drawing.process()
  File "/usr/local/lib/python3.6/dist-packages/z3c/rml/directive.py", line 123, in process
    self.processSubDirectives()
  File "/usr/local/lib/python3.6/dist-packages/z3c/rml/directive.py", line 120, in processSubDirectives
    directive.process()
  File "/usr/local/lib/python3.6/dist-packages/z3c/rml/canvas.py", line 376, in process
    getattr(canvas, self.callable)(**kwargs)
  File "reportlab/pdfgen/canvas.py", line 924, in drawImage
    rawdata = image.getRGBData()
  File "reportlab/lib/utils.py", line 886, in getRGBData
    annotateException('\nidentity=%s'%self.identity())
  File "reportlab/lib/utils.py", line 1390, in annotateException
    rl_reraise(t,v,b)
  File "reportlab/lib/utils.py", line 144, in rl_reraise
    raise v
  File "reportlab/lib/utils.py", line 871, in getRGBData
    if Image.VERSION.startswith('1.1.7'): im.load()

Problem with evalString

In an element: //document/template/pageTemplate/pageGraphic/drawRightString I have following snippet:

Page - of -

This causes code to error in special.py file at do_eval function. I found out that the value argument passed to the do_eval function contains string: "2-1 of" which does not evaluate. If I remove "of" from XML snippet, everything works correctly and passed value is: "2-1" which evaluates OK.

Correct value passed to the do_eval function in special.py should be the one encapsulated in evalString tag pair, nothing beyond that.

Error with latest version of report lab and ParaParser

The latest version of reportlab has changed the ParaParser class to use a tag parameter that is not optional. In the module z3c.rml.paraparser line 144 needs to be changed from self._pop() to something with a parameter. On my side it works with self._pop('para') but not sure that is the correct change as I do not know the package very well.

Thanks

RML <drawing module> tag

Hi is the tag supported in RML ? e.g.

<drawing module="test_014_scatterplot" function="ScatterPlotDrawing">

This seems to get ignored when I try it - it works if I use the commercial library though.

UPDATE

OK I see there's the tag which seems to be what I need and I can get it to work using the "rml-examples-037-plugingraphic.rml" example. However, I'm struggling to make it work with anything else. Is there any chance you can provide a simple example of rendering a dynamically created pie chart into a document please.

Carl

Memory Leak in Image?

I have a document where I add a few hundred ~300Kb images using the Image tag. These are PNG images with dimensions 1920x1080.

When I run my document the memory usage goes off the charts. The following program an example image may demonstrate. On my machine the memory usage goes to 3+GB.
283kb_file
A similar program using platypus and reportlab Image directly barely registers at all.

# Test case that takes my machine to ~3 GB of RAM used to generate a 450kb PDF file

from z3c.rml import rml2pdf

images = []
for i in range(500):
    images.append('<img width="15cm" preserveAspectRatio="true" src="/path/to/283kb_file.jpg"></img>')

images = "\n".join(images)

content = f"""<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="Test.pdf" xmlns:doc="http://namespaces.zope.org/rml/doc">

    <stylesheet/>

    <template>
         <pageTemplate id="main" pagesize="(595,842)">
            <frame id="first" x1="2cm" y1="2cm" width="17cm" height="26cm"/>
         </pageTemplate>
    </template>

    <story>
        { images }
    </story>
</document>
"""


pdf = rml2pdf.parseString(content)

f = open("out.pdf","wb")
f.write(pdf.read())
f.close()

<para> within <td> doesn't use paraStyle

As with the commercial version long text isn't wrapped inside a block.
When using a block inside the the paraStyle is ignored, leading to another
font size than used within the table.

Is this package compatible with current Zope 2/4/5?

One of the apps I maintain (currently Zope 2, soon Zope 4) uses a "forked/vendored" version of https://github.com/romanlv/trml2pdf which I would like to replace with z3c.rml to make the transition to Zope 4 / Python 3 smoother.

Is this package compatible with Zope 2/4/5?

If yes, the meta data for PyPi should be updated:

Currently:
classifier keywords="zope3 rml reportlab pdf pagetemplate",

Link issue

This code works :

<link destination="PICTURE_18">
<para>18</para>
</link>
<link destination="PICTURE_19">
<para>19</para>
</link>

But this does not :

<para>
<link destination="PICTURE_18">18</link>
<link destination="PICTURE_19">19</link>
</para>

In other words, it doesn't seem possible to have multiple links on the same line. Did I miss something ? Or is there an other way to do that ?

Thanks in advance.

Transparent PNGs and GIFs have black background when using the image tag

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="imagetest.pdf">
  <pageDrawing>
    <image file="https://www.google.com/images/srpr/logo11w.png" x="1in" y="2in" height="1in" width="2in" preserveAspectRatio="1"/>
  </pageDrawing>
</document>

Produces
screen shot 2015-02-04 at 4 54 55 pm

The img tag works as expected. The problem is that I need to use the image tag in the pageGraphics section of the template.

Dynamic Table Height

Hi,

Frames have to have the height attribute by default, is there a way of specifying a dynamic height so that I can render a table with a dynamic number of rows?

Thanks,

<!-- Frame definition has to have height -->
<frame id="start" x1="1in" y1="6.69in" width="6.27in" height="3in"/>

String buffer

Unable to work with a string buffer:

...
t = get_template("template.rml")
c = Context(data)
rml = t.render(c).encode('utf8')

buffer = cStringIO.StringIO()
rml2pdf.go(rml, outputFileName=buffer)

buffer.reset()
pdf = buffer.read()

regiserFontFamily not working

The problem is that registerFontFamily directive is missing among factories for class DocInit in z3c/rml/document.py

Adding the line with that factory fixes the issue.

Table cell cannot be split on to pages

When text in table cell cannot be placed on one page script raise LayoutError.
Can you make table cell behaviour same as paragraph, so it can be split on between pages automatically?

SVG as vectorial graphics

SVG images are parsed and translated into rlg (reportlab graphics). It is a pity that the result is then rasterized instead of embedded in the PDF result. I have used a trivial plugin to achieve this result by pre-processing the rml file, but someone more experienced would find it easy to get this result "in the core". I would happily help in the coding and testing.

<para> tag causing list index out of range error

Hello,

After using rml2pdf for over a year, a problem with tags popped up in my code when I used it recently. Suddenly, I began getting a list index out of range error. After doing some debugging, I tracked it down to the tag.

Here's the error:

In [22]: rml2pdf.go(root_path + r'\Test File.rml', root_path + r'\Output.pdf')
Traceback (most recent call last):
  File "C:\Program Files\Anaconda3\lib\site-packages\reportlab\platypus\paraparser.py", line 3220, in parse
    self.feed(text)
  File "C:\Program Files\Anaconda3\lib\html\parser.py", line 111, in feed
    self.goahead(0)
  File "C:\Program Files\Anaconda3\lib\html\parser.py", line 165, in goahead
    self.handle_data(rawdata[i:j])
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\paraparser.py", line 244, in handle_data
    reportlab.platypus.paraparser.ParaParser.handle_data(self, data)
  File "C:\Program Files\Anaconda3\lib\site-packages\reportlab\platypus\paraparser.py", line 3122, in handle_data
    frag = copy.copy(self._stack[-1])
IndexError: list index out of range


During handling of the above exception, another exception occurred:
 Traceback (most recent call last):
  File "C:\Users\JCHARL~1\AppData\Local\Temp/ipykernel_74424/1767421038.py", line 1, in <module>
    rml2pdf.go(root_path + r'\Test File.rml', root_path + r'\Output.pdf')
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\rml2pdf.py", line 75, in go
    doc.process(outputFile)
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\document.py", line 736, in process
    self.processSubDirectives(select=('template', 'story'))
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\directive.py", line 121, in processSubDirectives
    directive.process()
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\template.py", line 46, in process
    self.parent.flowables = super().process()
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\flowable.py", line 1633, in process
    self.processSubDirectives()
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\directive.py", line 121, in processSubDirectives
    directive.process()
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\flowable.py", line 323, in process
    self.parent.flow.append(self.klass(**args))
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\paraparser.py", line 261, in __init__
    reportlab.platypus.paragraph.cleanBlockQuotedText, manager)
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\paraparser.py", line 273, in _setup
    style, frags, bulletTextFrags = _parser.parse(text, style)
  File "C:\Program Files\Anaconda3\lib\site-packages\reportlab\platypus\paraparser.py", line 3222, in parse
    annotateException('\nparagraph text %s caused exception' % ascii(text))
  File "C:\Program Files\Anaconda3\lib\site-packages\reportlab\lib\utils.py", line 1297, in annotateException
    rl_reraise(t,t(sep.join((_ for _ in (msg,str(v),postMsg) if _))),b)
  File "C:\Program Files\Anaconda3\lib\site-packages\reportlab\lib\utils.py", line 169, in rl_reraise
    raise v.with_traceback(b)
  File "C:\Program Files\Anaconda3\lib\site-packages\reportlab\platypus\paraparser.py", line 3220, in parse
    self.feed(text)
  File "C:\Program Files\Anaconda3\lib\html\parser.py", line 111, in feed
    self.goahead(0)
  File "C:\Program Files\Anaconda3\lib\html\parser.py", line 165, in goahead
    self.handle_data(rawdata[i:j])
  File "C:\Program Files\Anaconda3\lib\site-packages\z3c\rml\paraparser.py", line 244, in handle_data
    reportlab.platypus.paraparser.ParaParser.handle_data(self, data)
  File "C:\Program Files\Anaconda3\lib\site-packages\reportlab\platypus\paraparser.py", line 3122, in handle_data
    frag = copy.copy(self._stack[-1])
IndexError: 
 paragraph text '<para>Hello World!</title> <para>Foobar</para> </story></para>' caused exception list index out of range

Here's my code:

root_path = r'H:\Temp'
import sys; 
sys.path.insert(0, root_path);

import z3c.rml.tests
from z3c.rml import rml2pdf, attr

rml2pdf.go(root_path + r'\Test File.rml', root_path + r'\Output.pdf')

I'm using python 3.7.11, zrc.rml 4.16 and reportlab 3.6.1. I've attached a sample RML file for reproducing the error.

Test File.zip

Piechart Labels

Hi,

Is there a way to configure the font used for piechart labels. I've tried this, but it does not work:

 <pieChart
        dx="2in" dy="7in" dwidth="6in" dheight="4in"
         x="0"    y="0"    width="3in"  height="3in"
         doc:example="">
      <labels fontName="Helvetica" fontSize="50">
        <label>Hello</label>
        <label>b</label>
        <label>c</label>
        <label>d</label>
        <label>e</label>
        <label>f</label>
      </labels>
      <slices strokeWidth="0.5" doc:example="z3c.rml.chart.ISlices">
        <slice fillColor="darkcyan" />
        <slice fillColor="blueviolet" />
        <slice fillColor="blue" />
        <slice fillColor="cyan" popout="10"
               strokeWidth="2" strokeDashArray="2 2"
               doc:example="z3c.rml.chart.ISlice" />
        <slice fillColor="aquamarine" />
        <slice fillColor="cadetblue" />
        <slice fillColor="lightcoral" />
      </slices>
      <data doc:example="z3c.rml.chart.ISingleData1D">
        <series>10 20 30 40 50 60</series>
      </data>
    </pieChart>

imageAndFlowables breaks in place context

place can have imageAndFlowables as a child. This is a minimal document to try this:

<document filename="/dev/null">
   <pageDrawing>
    <place x="285" y="550" width="240" height="135">
      <imageAndFlowables imageName="rml/images/calendar.jpg">
        <para>This is a test</para>
      </imageAndFlowables>
    </place>
  </pageDrawing>
</document>

Trying to render that results in this:

wichert@kim ~/rml $ bin/rml2pdf x.rml
Traceback (most recent call last):
  File "bin/rml2pdf", line 9, in <module>
    load_entry_point('z3c.rml==2.5.0', 'console_scripts', 'rml2pdf')()
  File "/Users/wichert/rml/lib/python2.7/site-packages/z3c/rml/rml2pdf.py", line 67, in main
    go(*args)
  File "/Users/wichert/rml/lib/python2.7/site-packages/z3c/rml/rml2pdf.py", line 61, in go
    doc.process(outputFile)
  File "/Users/wichert/rml/lib/python2.7/site-packages/z3c/rml/document.py", line 712, in process
    self.processSubDirectives(select=('pageInfo', 'pageDrawing'))
  File "/Users/wichert/rml/lib/python2.7/site-packages/z3c/rml/directive.py", line 120, in processSubDirectives
    directive.process()
  File "/Users/wichert/rml/lib/python2.7/site-packages/z3c/rml/canvas.py", line 996, in process
    super(Drawing, self).process()
  File "/Users/wichert/rml/lib/python2.7/site-packages/z3c/rml/directive.py", line 123, in process
    self.processSubDirectives()
  File "/Users/wichert/rml/lib/python2.7/site-packages/z3c/rml/directive.py", line 120, in processSubDirectives
    directive.process()
  File "/Users/wichert/rml/lib/python2.7/site-packages/z3c/rml/canvas.py", line 415, in process
    flowWidth, flowHeight = flow.wrap(width, height)
  File "/Users/wichert/rml/lib/python2.7/site-packages/reportlab/platypus/flowables.py", line 1174, in wrap
    canv = self.canv
AttributeError: ImageAndFlowables instance has no attribute 'canv'

svg2rlg.py fails under Python3

I ran into a couple of cases where svg2rlg.Renderer.render fails with

object of type 'map' has no len()

Converting map objects to lists in about 5 places resolved the problem, e.g.:

points = map(parseLength, re.split('[ ,]+', points))

becomes

points = list(map(parseLength, re.split('[ ,]+', points)))

I can put together a pull request if you like.

index tag is not implemented?

<showIndex> is listed in the documentation, but apparently <index> doesn't work at all. It's also not in the list of missing features.

Make processing observable

Adding observable pattern to directives.RMLDirective, document.Document and maybe rml2pdf.parseString would be nice improvement allowing to monitor progress of documents generation process.

This may be achieved with pyobservable.

Can't get TTF fonts to work

Implementing TTF fonts isn't documented terribly well in Reportlab or z3c, so I took a couple of educated guesses. Not a single one worked.

I'm following a two-step approach with Reportlab 3.3.0 on Python 3.4.3:

  • Register the font:
pdfmetrics.registerFont(TTFont("Montserrat", "Montserrat-Regular.ttf"))
pdfmetrics.registerFont(TTFont("Montserrat-Bold", "Montserrat-Bold.ttf"))
  • Manually add mapping by calling reportlab.lib.fonts.addmapping
addMapping('Montserrat', 0, 0, 'Montserrat')
addMapping('Montserrat', 0, 1, 'Montserrat')
addMapping('Montserrat', 1, 0, 'Montserrat-Bold')
addMapping('Montserrat', 1, 1, 'Montserrat-Bold')
  • Declare the font name in the RML file.
<stylesheet>
<initialize>
<alias id="style.normal" value="style.Normal"/>
</initialize>
<paraStyle name="normal" fontName="Montserrat" fontSize="10" leading="15" />
</stylesheet>

I'm getting a generic error ("Can't map determine familiy/bold/italic") from Reportlab's pdfbase.ttfonts module (line 79) although I explicitly added mapping.

pageSize attribute of <template> tag

Hey,

I spent hours trying switch to "a4 landscape" page using z3c.rml and I finally found that IPageTemplate contains "pagesize" attribute definition instead of "pageSize". Take a look at https://github.com/zopefoundation/z3c.rml/blob/master/src/z3c/rml/template.py#L161

Ok, changing attr name fixes my problem, but:

Python 2.6

Is the latest version of z3c.rml (2.7.2) supposed to work with python 2.6?
(Required reporlab 3.0 library has no python 2.6 support).

It changes history it says "Updated code to work with ReportLab 3.x". But it does not mention that previous versions of Reportlab and python 2.6 are not supported.

Could you clarify it please?

ReportLab 2.7 incompatibilities

Buildout pulled in the recently released ReportLab 2.7 in one of my projects and there seems to be some incompatibilities.

The main problem is that _parser is no longer a global and so the Z3CParagraphParser monkey patch fails. _parser is now initialised in the _setup method of each individual Paragraph flowable. This should mean that a monkey patch isn't needed for 2.7 and instead it should be possible to just set z3c.rml.flowable.Paragraph.klass to a custom class, which would work for 2.6 as well anyway I imagine?

Tougher to fix is that there seems to be a major slow down with 2.7. A plain bin/test takes 10 seconds with 2.6 but 80 seconds with 2.7.

2.7 release notes: http://www.reportlab.com/software/documentation/relnotes/27/

Dynamically passing images to the RML

Is there a way to pass an image to the final PDF without using the disc? I generate a graph w/ matplotlib since z3c.rml doesn't have a way of generating a scatter plot through drawing (there is no support for drawing tag) and it seems there is no way to pass the generated file directly.

ReportLab 3.4.0 broke lookaheads (the stuff required for "Page X of Y")

ReportLab 3.4.0 has some paragraph width fixes but it also added some "caching" which checks if the width of a paragraph fragment has been calculated already. If the width has been calculated then the contents of the fragment aren't recalculated. See: https://bitbucket.org/rptlab/reportlab/diff/src/reportlab/platypus/paragraph.py?diff2=7c65c6e52b13&at=default#Lsrc/reportlab/platypus/paragraph.pyT449

This broke how I implemented getName which needs to be reevaluated on the second build pass.

I can't see a good way to fix this. Resetting the frags attribute on each pass leads to weird problems so either I'm missing some fragments or more stuff has been cached. Keeping a clean copy of the flowables results in the second pass being appended to the end of the document instead of overwriting the first pass.

I think the only solution is to stop using ReportLab's built in multiBuild and refactor z3c.rml to create two separate lists of flowables and build each one individually but share the manager. Only real problem with this is if you have lookaheads and use indexes it will require four passes instead of two. Maybe there's a simpler way but good luck understanding ReportLab's source.

svg2rlg seems not to be compatible with Python3

I get an error using svg2rlg, which seems to be associated with a Python 2-3 incompatibility. The function handleText attempts to use len and subscripts on a map returned from parsePos, which is allowed in Python 2 but not in 3.

What I did:

I tried to use rml2pdf.parseString on a RML file containing a SVG image

<imageAndFlowables imageName="{{ image_path('bad.svg') }}"  imageWidth="428" imageHeight="538"  imageSide="left">
</imageAndFlowables>

What I expect to happen:

The SVG should have been embedded in the PDF document

What actually happened:

The function raised exception, with the following traceback

  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/rml2pdf.py", line 41, in parseString
    doc.process(output)
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/document.py", line 736, in process
    self.processSubDirectives(select=('template', 'story'))
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/directive.py", line 121, in processSubDirectives
    directive.process()
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/template.py", line 46, in process
    self.parent.flowables = super().process()
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/flowable.py", line 1633, in process
    self.processSubDirectives()
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/directive.py", line 121, in processSubDirectives
    directive.process()
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/flowable.py", line 1058, in process
    args = dict(self.getAttributeValues(
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/directive.py", line 71, in getAttributeValues
    value = attr.bind(self).get()
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/attr.py", line 111, in get
    return self.fromUnicode(value)
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/attr.py", line 477, in fromUnicode
    return self._load_svg(value)
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/attr.py", line 512, in _load_svg
    svg = Renderer(value).render(svg)
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/svg2rlg.py", line 811, in render
    self.render(child, self.mainGroup)
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/svg2rlg.py", line 856, in render
    self.render(child, group)
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/svg2rlg.py", line 1070, in render
    handleText(node, subnode, subnode.text.strip())
  File "/tmp/pyenv1/lib/python3.9/site-packages/z3c/rml/svg2rlg.py", line 1031, in handleText
    if sum(map(len, (xs,ys,dxs,dys))) == 4:
TypeError: object of type 'map' has no len()

What version of Python and Zope/Addons I am using:

  • Linux (Debian 11)
  • Python 3.9.2
  • z3c.rml 4.2.0 (version 3.10.0 also fails)

registerTTFont does not work if no path specified

In the docinit section of an RML file, I usually declare the fonts in the following way
<registerTTFont faceName="Arial" fileName="Arial.ttf"/>
Arial.ttf is located somewhere in the /usr/share/fonts/truetype/ directory, and reportlab is able to find it, just by giving the name "Arial.ttf".

With current version of z3c.rml (3.3.0), however, it fails, as it cannot locate "file:////Arial.ttf". After investigating a bit, I modified document.py:

--- document.py.old 2016-04-04 11:57:24.000000000 +0200
+++ document.py 2016-09-16 23:31:39.841520461 +0200
@@ -122,10 +122,9 @@
                      u'be previously registered.'),
         required=True)

-    fileName = attr.File(
+    fileName = attr.String(
         title=u'File Name',
         description=u'File path of the of the TrueType font.',
-        doNotOpen=True,
         required=True)

 class RegisterTTFont(directive.RMLDirective):

Now it is working again for me.

The way the registerTTFont element is currently handled is clearly wrong, as reportlab has its own methods for finding fonts. z3c.rml should pass the raw value of the XML attribute fileName to reportlab instead of modifying it (except for the case with "[modulename]/path/...")

getName not working in tables

HI, we switched from z3c.rml 1.0.0 to 2.1.0 and some things stopped working. One of the things is that getName does not work inside a table anymore.

Are there any remaining blockers for Python 3 support?

A blocker with Python 3 for me was lack of ReportLab but that's solved now with ReportLab 3.0 which is meant to be API compatible.

What's needed to make z3c.rml compatible with Python 3 beyond making sure everything works with ReportLab 3.0?

I checked the immediate dependencies and they all seem OK except maybe svg2rlg which is ancient but probably easily fixable.

image tag does not work for anything other than JPG files

I am trying to use another PDF as background for a page. An example of doing that is in the reportlab product catalogue example:

<pageGraphics>  
    <image file="{{RML_DIR}}/flyer_background.pdf" x="0" y="0" width="595"   
height="842"/>  
</pageGraphics>

When I try to do that with z3c.rml I get an error:

  z3crml-venv/bin/rml2pdf(9)<module>()
-> load_entry_point('z3c.rml==2.5.0', 'console_scripts', 'rml2pdf')()
  z3crml-venv/lib/python2.7/site-packages/z3c/rml/rml2pdf.py(67)main()
-> go(*args)
  z3crml-venv/lib/python2.7/site-packages/z3c/rml/rml2pdf.py(61)go()
-> doc.process(outputFile)
  z3crml-venv/lib/python2.7/site-packages/z3c/rml/document.py(719)process()
-> self.doc.multiBuild(self.flowables, maxPasses=maxPasses)
  z3crml-venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py(970)multiBuild()
-> self.build(tempStory, **buildKwds)
  z3crml-venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py(887)build()
-> self.clean_hanging()
  z3crml-venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py(512)clean_hanging()
-> self.handle_flowable(self._hanging)
  z3crml-venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py(767)handle_flowable()
-> f.apply(self)
  z3crml-venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py(138)apply()
-> getattr(doc,arn)(*args)
  z3crml-venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py(537)handle_pageBegin()
-> self.pageTemplate.onPage(self.canv,self)
  z3crml-venv/lib/python2.7/site-packages/z3c/rml/template.py(143)drawOnCanvas()
-> drawing.process()
  z3crml-venv/lib/python2.7/site-packages/z3c/rml/directive.py(123)process()
-> self.processSubDirectives()
  z3crml-venv/lib/python2.7/site-packages/z3c/rml/directive.py(120)processSubDirectives()
-> directive.process()
  z3crml-venv/lib/python2.7/site-packages/z3c/rml/canvas.py(350)process()
-> kwargs = dict(self.getAttributeValues(attrMapping=self.attrMapping))
  z3crml-venv/lib/python2.7/site-packages/z3c/rml/directive.py(70)getAttributeValues()
-> value = attr.bind(self).get()
  z3crml-venv/lib/python2.7/site-packages/z3c/rml/attr.py(101)get()
-> return self.fromUnicode(value)
  z3crml-venv/lib/python2.7/site-packages/z3c/rml/attr.py(360)fromUnicode()
-> return reportlab.lib.utils.ImageReader(fileObj)
> z3crml-venv/lib/python2.7/site-packages/reportlab/lib/utils.py(751)__init__()
-> self._width,self._height,c=readJPEGInfo(self.fp)
  z3crml-venv/lib/python2.7/site-packages/reportlab/pdfbase/pdfutils.py(247)readJPEGInfo()
-> raise PDFError('JPEG must have 8 bits per component')

UTF-8 Encoding not fully supported

I'm generating a report, and my problem is that RML is not properly rendering the following characters:

ร“, ร

screen shot 2016-06-24 at 8 49 45 am

Any pointers on this issue?
Thanks

Setup

<?xml version="1.0" encoding="utf-8" standalone="no" ?>
  • Pyton 3
  • Django 1.9.6

*color="None"

I not checked all cases, but this color value exists in some original tests (e.g. 007, 008, 014, 028, 032).
And z3c.rml produces an error on it (I tested 007)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.