Pergunta

I would like to create a pdf file with the tool "reportlab". Afterwards I'd like to save the created file in a given directory (so to say in a given folder)

Here is the code for creating my PDF:

def pdfLeereRechnung(request):
response = HttpResponse(content_type='application/pdf')
filename = str("LR_" + str(article) + "_" + str(first_name) + "_" + str(last_name) + "_" + str(date.today().year))
response['Content-Disposition'] = 'attachment; filename=' + filename + ".pdf"

p = canvas.Canvas(response, pagesize=A4) 
#Do something,...
p.showPage()
p.save()
return response

Creating the PDF works perfectly, but I don't want to save my files into "Downloads". So here is my question: Is it possible, to say something like: p.save_in("C/folder/...")? Thank you very much for your help

Foi útil?

Solução

You are not able to tell the user agents (their web browsers) where to save downloaded files. It doesn't make sense, you don't even know their folder structure.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top