Here are the examples of the python api frappe.utils.pdf.get_pdf taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5 Examples
3
Example 1
@frappe.whitelist()
def download_pdf(doctype, name, format=None, doc=None):
html = frappe.get_print(doctype, name, format, doc=doc)
frappe.local.response.filename = "{name}.pdf".format(name=name.replace(" ", "-").replace("/", "-"))
frappe.local.response.filecontent = get_pdf(html)
frappe.local.response.type = "download"
0
Example 2
Project: frappe Source File: email_body.py
def add_pdf_attachment(self, name, html, options=None):
self.add_attachment(name, get_pdf(html, options), 'application/octet-stream')
0
Example 3
Project: frappe Source File: print_format.py
@frappe.whitelist()
def download_multi_pdf(doctype, name, format=None):
# name can include names of many docs of the same doctype.
totalhtml = ""
# Pagebreak to be added between each doc html
pagebreak = """<p style="page-break-after:always;"></p>"""
options = {}
import json
result = json.loads(name)
# Get html of each doc and combine including page breaks
for i, ss in enumerate(result):
html = frappe.get_print(doctype, ss, format)
if i == len(result)-1:
totalhtml = totalhtml + html
else:
totalhtml = totalhtml + html + pagebreak
frappe.local.response.filename = "{doctype}.pdf".format(doctype=doctype.replace(" ", "-").replace("/", "-"))
# Title of pdf
options.update({
'title': doctype,
})
frappe.local.response.filecontent = get_pdf(totalhtml, options)
frappe.local.response.type = "download"
0
Example 4
Project: frappe Source File: print_format.py
@frappe.whitelist()
def report_to_pdf(html):
frappe.local.response.filename = "report.pdf"
frappe.local.response.filecontent = get_pdf(html, {"orientation": "Landscape"})
frappe.local.response.type = "download"
0
Example 5
Project: frappe Source File: __init__.py
def get_print(doctype=None, name=None, print_format=None, style=None, html=None, as_pdf=False, doc=None):
"""Get Print Format for given docuement.
:param doctype: DocType of docuement.
:param name: Name of docuement.
:param print_format: Print Format name. Default 'Standard',
:param style: Print Format style.
:param as_pdf: Return as PDF. Default False."""
from frappe.website.render import build_page
from frappe.utils.pdf import get_pdf
local.form_dict.doctype = doctype
local.form_dict.name = name
local.form_dict.format = print_format
local.form_dict.style = style
local.form_dict.doc = doc
if not html:
html = build_page("print")
if as_pdf:
return get_pdf(html)
else:
return html