I'm trying to export the html generated by the Kendo Vue Native Editor to a PDF document, using the Kendo Vue Native PDF Processing (I'm not using the Editor's embedded pdf export button, because I need to send this PDF to the backend).
I can't see any documentation about how to this. This is what I first tried:
const iframe = document.querySelector(".k-editor-content .k-iframe");
const htmlElementContent = iframe.contentWindow.document.querySelector("html")
savePDF(htmlElementContent, {
paperSize: "A4"
});
But then I got this error: "DOMException: Failed to execute 'insertBefore' on 'Node': Only one element on document allowed."
To bypass this error, I tried to manipulate the Iframe content first:
const iFrameDocument = document.querySelector(".k-editor-content .k-iframe").contentWindow.document;
const iFrameRootHtml = iFrameDocument.querySelector("html")
const newSection = iFrameDocument.createElement('section');
newSection.appendChild(iFrameRootHtml);
iFrameDocument.appendChild(newSection);
const newRoot = newSection.querySelector("html");
savePDF(newRoot, {
paperSize: "A4"
});
With the above code I'm able to generate an PDF, but with no embedded fonts at all. Also, if I try to drag an image into the editor (the editor transforms it into a base64 string) and then generate the PDF, I got this error: "DOMException: Failed to execute 'appendChild' on 'Node': Only one element on document allowed."
Still regarding the fonts, I'm declaring them in the style section of the html that is inside the iframe content, using the onLoaded event of the Editor (https://www.telerik.com/kendo-vue-ui/components/editor/styling-content/). I'm also declaring them on the outer content (the main website). The fonts are hosted on my own website. Still, no embedded fonts on the generated PDF.
Also, to the Telerik forum admins, I just noted that there is no tag available neither for the Native Editor or the native PDF Processing, so I'm forced to tag this question with wrong/generic tags.
Any help will be appreciated, thanks in advance.