pdf.output() issue
StefanIancu opened this issue ยท 3 comments
Hi,
I want to send the output to a specific location/file. I tried the following and I'm always getting the destination input error:
-pdf.output("name.pdf", "F")
-pdf.output("name.pdf", "path/path/path")
-pdf.ouput("name.pdf", "folder_name")
I tried multiple combinations and I get the destination error or the pdf is sent to the destination I am currently (in the Terminal).
Am I doing something wrong here?
Thank you.
Hi @StefanIancu!
pyfpdf
is not maintained anymore, have you tried using fpdf2
?
https://pyfpdf.github.io/fpdf2/
See also: #207
fpdf2
can be installed with pip install fpdf2
You may want to uninstall pyfpdf
first, to avoid any import conflict.
On the homepage of fpdf2
documentation website, you'll find an exexample on how to save a PDF document to a file:
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font('helvetica', size=12)
pdf.cell(txt="hello world")
pdf.output("hello_world.pdf")
The argument provided to pdf.output()
can also be an absolute file path:
pdf.output("/tmp/hello_world.pdf") # on Linux
pdf.output("C:\\Temp\\hello_world.pdf") # on Windows
Hi Lucas,
I am actually using fpdf2, I tried your solution and it worked!
I didn't know that I should insert the absolute path even though I checked the documentation several times. I think that I was reading the documentation for the wrong module. Tried to apply the rule from pyfpdf to fpdf2.
Thank you so much for this!!!
Glad I could help you! ๐