pythonpdfrml

Python - trml2pdf generating a blank PDF


I use trml2pdf library in Python, but even when I use the examples, I get a blank PDF file. I run it as follows: trml2pdf.py ex5.rml > out.pdf

When I open the file in Acrobat it is blank/empty. But when I analyse the contents in text editor, I see the following.

Generated PDF:

%PDF-1.4

%“Œ‹ž ReportLab Generated PDF document http://www.reportlab.com

% 'BasicFonts': class PDFDictionary 

1 0 obj

% The standard fonts dictionary

<< /F1 2 0 R

 /F2 3 0 R

 /F3 4 0 R >>

Example PDF:

%PDF-1.3
%“Œ‹ž ReportLab Generated PDF document http://www.reportlab.com
% 'BasicFonts': class PDFDictionary 
1 0 obj
% The standard fonts dictionary
<< /F1 2 0 R
 /F2 3 0 R
 /F3 4 0 R
 /F4 5 0 R
 /F5 6 0 R >>

What am I doing wrong? Why am I getting blank lines in the output?

Thanks!

Here's basic RML that also returns blank PDF:

<!DOCTYPE document SYSTEM "rml_1_0.dtd">
<document filename="example_1.pdf">
<stylesheet>
</stylesheet>
<pageDrawing>
     <drawCentredString x="4.1in" y="5.8in">
       Hello World.
 </drawCentredString>
</pageDrawing>
</document>

Solution

  • I've been using z3c.rml in many web apps for last 6-8 months and never faced any major issue. rml2pdf command from this package was able to generate the PDF for the rml you have shared.

    You should give it a try.

    #Install z3c.rml
    [sudo] pip install z3c.rml
    
    # create a new rml document
    vim example.rml
    
    # rum rml2pdf command to convert this rml to pdf
    rml2pdf example.rml
    
    # You should have desired PDF file now