Giter Site home page Giter Site logo

trml2pdf's People

Contributors

daemondazz avatar edwardoliveira avatar isszul avatar japostoles avatar joeyates avatar misli avatar parachvte avatar romanlv avatar simonkagwi avatar tieugene avatar willson556 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trml2pdf's Issues

Template/Style not working properly in Python3

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.

screenshot from 2016-01-12 17 20 29

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!

A couple of bug fixes

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

re-enable PR checks

looks like travis tests are not supported/do not work any more. replaced with github actions?

drawString incompatible with getName

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.

It's not working on python3

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?

Raw string in pdf when used with Django SafeText

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

<pageCount /> is not rendered

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

unicode error with python2.7

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

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.