I have this solution integrated (a simplified example is below)
<form action="/action_page.php" onsubmit="downloadPdf()" >
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br>
<label><input name="privacy" type="checkbox" required> I agree to the privacy policy</label><br>
<input type="submit" value="Submit">
</form>
<script src='build/pdfmake.min.js'></script>
<script type="text/javascript">
function downloadPdf() {
// create PDF
pdfMake.fonts = {
// my fonts here
},
let docDefinition = {
// my definitions here
};
pdfMake.createPdf(docDefinition).open();
}
</script>
So, form submitting does two things, executes PDFMake and submits the form. It works in Chrome and Edge without issues, but in Firefox I am getting this error
Uncaught (in promise) TypeError: Failed to fetch (url: "http://localhost/site/assets/fonts/myfont.woff")
Do you maybe have idea how to solve this?
What's funny, when I remove the privacy checkbox from the form it also works in Firefox. But the privacy checkbox is mandatory these days, so I can't remove it.
I think form submiting should be delayed until javascript function downloadPdf() is executed and then submit the form. Which works automaticaly in Chrome and Edge, but not in Firefox. But I am not sure how to do it.