Pdfs
hypha.apply.utils.pdfs
¶
html_to_pdf
¶
Convert HTML to PDF.
Parameters:
-
html_body
(str
) –The body of the html as string
Returns:
-
BytesIO
(BytesIO
) –PDF file
Source code in hypha/apply/utils/pdfs.py
render_as_pdf
¶
Convert HTML template to PDF file and return as a downloadable file.
Parameters:
-
template_name
(str
) –Django template name to render
-
filename
(str
) –Name of the output PDF file
-
context
(dict
) –Context dictionary for rendering template
-
request
–Request object, defaults to None
Returns:
-
HttpResponse
(HttpResponse
) –PDF file as downloadable response
Example
response = render_as_pdf( template_name='my_template.html', filename='my_pdf.pdf', context={'title': 'My PDF'}, request=request )
Source code in hypha/apply/utils/pdfs.py
merge_pdf
¶
Given two PDFs, merge them together.
Parameters:
-
origin_pdf
(BytesIO
) –a file-like object containing a PDF
-
input_pdf
(BytesIO
) –a file-like object containing a PDF
Returns:
-
File
–Return a File object containing the merged PDF and with the same name as the
-
File
–original PDF.