Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf.output() issue #213

Closed
StefanIancu opened this issue Jun 8, 2023 · 3 comments
Closed

pdf.output() issue #213

StefanIancu opened this issue Jun 8, 2023 · 3 comments

Comments

@StefanIancu
Copy link

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.

@Lucas-C
Copy link

Lucas-C commented Jun 9, 2023

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

@StefanIancu
Copy link
Author

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!!!

@Lucas-C
Copy link

Lucas-C commented Jun 12, 2023

Glad I could help you! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants