我在 Python 中使用 trml2pdf 库,但即使在使用示例时,我也得到一个空白的 PDF 文件。 我按如下方式运行它: trml2pdf.py ex5.rml > 输出.pdf
当我在 Acrobat 中打开文件时,它是空白的。 但是当我在文本编辑器中分析内容时,我看到以下内容。
生成的 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 >>
我做错了什么?为什么我在输出中得到空行?
谢谢!
这是同样返回空白 PDF 的基本 RML:
<!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。
你应该试一试。
#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
