Есть 3 вопроса, которые я имею о сгенерированном PDF-анализе в django, о котором я не могу найти хороший ответ. Документация на сайте django охватывает только способ создания PDF-файла для загрузки. Но как я могу приложить сгенерированный PDF-файл к электронной почте и отправить его вместо его загрузки? Как сохранить pdf-файл в каталог на сервере, а не загружать его? Как отобразить PDF в окне браузера, а не загружать его? Просто используйте пример Джанго документации:django reportlab attach pdf to email, save pdf to server, показать pdf в браузере
from reportlab.pdfgen import canvas
from django.http import HttpResponse
def some_view(request):
# Create the HttpResponse object with the appropriate PDF headers.
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"'
# Create the PDF object, using the response object as its "file."
p = canvas.Canvas(response)
# Draw things on the PDF. Here's where the PDF generation happens.
# See the ReportLab documentation for the full list of functionality.
p.drawString(100, 100, "Hello world.")
# Close the PDF object cleanly, and we're done.
p.showPage()
p.save()
return response