如何在Python中创建PDF文件并放置LaTeX数据?
我需要创建一些乳胶数据的pdf文件。 我所拥有的:如何在Python中创建PDF文件并放置LaTeX数据?,python,pdf,latex,Python,Pdf,Latex,我需要创建一些乳胶数据的pdf文件。 我所拥有的: min_latex = (r"\documentclass{article}" r"\begin{document}" r"Hello, world!" r"\end{document}") from latex import build_pdf # this builds a pdf-file inside a temporary directory pdf = build_pdf(m
min_latex = (r"\documentclass{article}"
r"\begin{document}"
r"Hello, world!"
r"\end{document}")
from latex import build_pdf
# this builds a pdf-file inside a temporary directory
pdf = build_pdf(min_latex)
# look at the first few bytes of the header
print bytes(pdf)[:10]
with open('temp.pdf', 'wb+') as f:
f.write(pdf)
但我有以下错误消息:
File "temp.py", line 18, in <module> f.write(pdf) TypeError: argument 1 must be convertible to a buffer, not Data
文件“temp.py”,第18行,在f.write(pdf)TypeError中:参数1必须转换为缓冲区,而不是数据
pdf不是字符串-您必须调用其中一个方法来保存它:
pdf.save_to("/tmp/foo.pdf")
一般来说,最好进入交互式解释器并粘贴到程序中,直到包含pdf=。。。线路。然后你可以说
help(pdf)
来找出你可以对该对象做什么。解释错误,给我们日志/错误消息…@Kartoch这里有错误:回溯(最近一次调用):文件“temp.py”,第18行,f.write(pdf)类型错误:参数1必须转换为缓冲区,而不是数据谢谢你的小提示!太棒了。