Djangopython如何将文本转换为pd

2024-10-01 07:44:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在pythondjango中做一个项目,我想知道是否有任何内置库或类似的东西,可以将文本转换成pdf格式。类似于pyTeaser的东西,用于将图像转换为文本

提前谢谢


Tags: 项目图像文本pdf格式内置pythondjangopyteaser
3条回答

下载并尝试this。作者写道:

PyText2Pdf makes a 7-bit clean PDF file from any input file.

It reads from a named file, and writes the PDF file to a file specified by the user, otherwise to a file with '.pdf' appended to the input file.

您可以按以下说明运行它:

text2pdf.py rfc_3917.txt -S "Netflow RFC" -A "Quittek, et al." -K netflow,rfc,networking,ipfix -R "[Page\s+\d+]"

但请查看脚本内部以了解更多详细信息。在

指向其在Django中用法的链接是here,但部分过时,因为使用了旧的脚本。我在这里提供的链接是更新的。在

我已经使用django-webodt将OpenOffice模板(.odt)动态转换为PDF填充占位符的数据库模型。在

在测试.odt可以是。。。在

Hello {{ first_name }}

import webodt
template = webodt.ODFTemplate('test.odt')
context = dict(first_name="Mary")
document = template.render(Context(context))
from webodt.converters import converter
conv = converter()
pdf = conv.convert(document, format='pdf')

相关问题 更多 >