Last active
February 10, 2018 14:07
-
-
Save dralletje/e0e8f8dadb18d970c1c76a4ec9fe3fbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//let REPORT_TO_PDF_URL = 'http://localhost:5000'; // For testing locally | |
let REPORT_TO_PDF_URL = 'https://report-to-pdf.herokuapp.com'; | |
let download_pdf_from_html = async ({ html_body, pdf_options, filename }) => { | |
let resp = await fetch(`${REPORT_TO_PDF_URL}/request_pdf_path`, { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ html_body, pdf_options, filename }), | |
}); | |
let { pdf_path } = await resp.json(); | |
window.location.href = `${REPORT_TO_PDF_URL}${pdf_path}`; | |
} | |
/* | |
download_pdf_from_html({ | |
html_body: '<h1>Hey!</h1>', | |
pdf_options: { landscape: true }, | |
filename: 'my-report.pdf', | |
}) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment