Python-trml2pdf生成空白PDF [英] Python - trml2pdf generating a blank PDF

查看:289
本文介绍了Python-trml2pdf生成空白PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Python中使用trml2pdf库,但是即使使用示例,我也会得到一个空白的PDF文件. 我按如下方式运行: trml2pdf.py ex5.rml> out.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

当我在Acrobat中打开文件时,该文件为空白/空. 但是,当我在文本编辑器中分析内容时,会看到以下内容.

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

生成的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 >>

示例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?

谢谢!

这里的基本RML也会返回空白的PDF:

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>

推荐答案

我一直在使用 z3c.rml 在过去6-8个月的许多网络应用中都从未遇到过任何重大问题.该软件包中的rml2pdf命令能够为您共享的rml生成PDF.

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.

您应该尝试一下.

#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

这篇关于Python-trml2pdf生成空白PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆