Reputation: 175
I need to create pdf file with some LaTeX data. What I have:
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)
But I have the following error message:
File "temp.py", line 18, in <module> f.write(pdf) TypeError: argument 1 must be convertible to a buffer, not Data
Upvotes: 1
Views: 337
Reputation: 6412
pdf is not a string - you have to invoke one of its methods to save it:
pdf.save_to("/tmp/foo.pdf")
In general, it's a good idea to go into the interactive interpreter and paste in your program up to including the pdf = ... line. Then you can say help(pdf)
to find out what you can do with that object.
Upvotes: 1