romanlv / trml2pdf Goto Github PK
View Code? Open in Web Editor NEWopen source implementation for RML language (markup language for PDF generation)
License: GNU Lesser General Public License v2.1
open source implementation for RML language (markup language for PDF generation)
License: GNU Lesser General Public License v2.1
As Python2 EOL this is required.
Hello, I have tested the following report.rml
on Python3:
<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="example_2.pdf">
<template>
<pageTemplate id="main">
<frame id="first" x1="72" y1="72" width="451" height="698"/>
</pageTemplate>
</template>
<stylesheet>
</stylesheet>
<!-- The story starts below this comment -->
<story>
<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>
</story>
</document>
I am using Python3 and the script I use is as follows:
from trml2pdf import parseString
i = open('report.rml', 'r+')
x = i.read()
y = parseString(x)
i.close()
output = open('report.pdf', 'wb')
output.write(y)
output.close()
Well, I run the script above it renders as below. As you can see, the break lines are printed verbatim.
If I replace the original text by including accents like the word Resolução
then this word gets printed as Resolu\xc3\xa7\xc3\xa3o
. Anyone could help me solve this problem?
Thanks in advance!
Issue for future branch merging.
The PR #12 has some details about changes we made early this year. Please, review it when you have time. I would recommend to evaluate commit by commit. If not all PR is necessary then at least some commits will be, I guess. master...interlegis:master
Issue for future branch merging.
Issue for future branch merging.
PS. boxstyle tag included
looks like travis tests are not supported/do not work any more. replaced with github actions?
I want to display dynamic content on each page header:
<drawString x="18cm" y="18cm"><getName id="foo"/></drawString>
(in the pageGraphics-section)
It just displays nothing.
Hi,
I am able to install via pip and have, but whenever I try to import it it gives me the following error:
>>> import trml2pdf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/eribeiro/.virtualenvs/sapl/lib/python3.4/site-packages/trml2pdf/__init__.py", line 18, in <module>
from trml2pdf import parseString
ImportError: cannot import name 'parseString'
Then I changed __ini__.py
, including a dot as below:
from .trml2pdf import parseString
Then the error was:
>>> import trml2pdf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/eribeiro/.virtualenvs/sapl/lib/python3.4/site-packages/trml2pdf/trml2pdf.py", line 265
raise ValueError, "Not enough space"
^
SyntaxError: invalid syntax
Looks like the lib is not in sync with the python3 changes, right?
Getting warning
Warning: flowable not yet implemented: pto !
how can we do it for pto
I've implemented a tiny example with Django in order to test trml2pdf using the template system. Here you can checkout a minimal working example. I'm using Python 3.4.3 and Win7 64 bits.
Generated PDF contains raw string in the paragraph (see actual pdf here):
b'\n Unicode aqu\xc3\xad.\n y aqu\xc3\xad.\n Hello Mar\xc3\xada\n '
and expected should be (not sure about blanks and newlines):
Unicode aquí
y aquí.
Hello María
View class is implemented as follows:
class PDFView(View):
template_name = 'rml/template.rml'
def get_template_name(self):
if self.template_name is None:
raise ImproperlyConfigured('%s requires either a definition of '
'template_name or an implementation of '
'get_template_name()'
% self.__class__.__name__)
return self.template_name
def get_context_data(self, **kwargs):
return {'filename': 'report.pdf',
'user': 'María'}
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
context.setdefault('filename', 'report.pdf')
rml = render_to_string(self.get_template_name(), context) # Type of 'rml' is django.utils.safestring.SafeText
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = ('filename="report.pdf"')
response.write(trml2pdf.parseString(rml))
return response
The tag <pageCount />
seems to be not supported yet. <pageNumber />
works properly
Here a code example.
<drawCentredString x="10cm" y="0.8cm">Page <pageNumber /> of <pageCount /> </drawCentredString>
Is it my fault? Do you know other solutions to show the total number of pages?
thx in advance
trml2pdf.py
uses text_type from six
that transforms the text in unicode
then passes xml
to python minidom, on python 2 the parses is not able to handle unicode string, so it breaks the renderer if the xml contains non-ascii data
minidom on py2 needs decoded bytestream, so _rml_flowable._textual
should return plain rc
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.