-1
I made a program in Python that at the end generates a PDF with the following data:
from reportlab.pdfgen import canvas
pdf = canvas.Canvas("vendas_produtos.pdf")
pdf.setFont("Times-Bold", 14)
pdf.drawString(200, 800, "Produtos vendidos:")
pdf.setFont("Times-Bold", 10)
pdf.drawString(10, 750, "ID")
pdf.drawString(60, 750, "Descrição")
pdf.drawString(230, 750, "Preço")
pdf.drawString(310, 750, "Dia")
pdf.drawString(340, 750, "Mês")
pdf.drawString(370, 750, "Quant.")
pdf.drawString(420, 750, "L. u.(%)")
pdf.drawString(470, 750, "L. u.(R$)")
pdf.drawString(520, 750, "L. Tot.(R$)")
pdf.drawString(400, 800, "Lucro Total:")
pdf.drawString(470, 800, f"{moeda(lucro_total)}")
for i in range(0, len(gerar_pdf_dados)):
y += 50
pdf.drawString(10, 750 - y, str(gerar_pdf_dados[i][0]))
pdf.drawString(60, 750 - y, str(gerar_pdf_dados[i][1]))
pdf.drawString(230, 750 - y, str(gerar_pdf_dados[i][2]))
pdf.drawString(310, 750 - y, str(gerar_pdf_dados[i][3]))
pdf.drawString(340, 750 - y, str(gerar_pdf_dados[i][4]))
pdf.drawString(370, 750 - y, str(gerar_pdf_dados[i][5]))
pdf.drawString(420, 750 - y, str(gerar_pdf_dados[i][6]))
pdf.drawString(470, 750 - y, str(gerar_pdf_dados[i][7]))
pdf.drawString(520, 750 - y, str(gerar_pdf_dados[i][8]))
pdf.save()
I wanted to save this file on the desktop and not in the program folder, how can I do this?
just save to that folder and use
copy
and send to any other folder, already tried it, by the way this method by what I saw on the Internet only does it– novic
It is because when I turn the program into . exe error when generating the pdf, so I wanted to put a command to save on desktop, understood?
– Dirso
But there is another problem, what is the error:? that you did not inform in the question and then when it closes you complain
– novic
When this happens not from the error, just does not generate the pdf, what I asked in the question is to change the save location.
– Dirso
As I said Dirso this method does not have that, if you have to do for the IO class responsible (I do not know if that’s the name) of python
– novic
All right. I’ll try :/
– Dirso
Example: https://stackoverflow.com/a/123212/6797930
– novic