Cannot read properties of undefined (reading 'split')

WebViewer Version: 10.10.1

Do you have an issue with a specific file(s)? I am getting error on console, not able to download the file
Can you reproduce using one of our samples or online demos?
Are you using the WebViewer server? No
Does the issue only happen on certain browsers? No
Is your issue related to a front-end framework? No
Is your issue related to annotations? Not sure

Please give a brief summary of your issue:
Hi,
I am creating POC for converting html contents to PDF through pdfTron, but unfortunately I am receiving a console error saying Cannot read properties of undefined (reading ‘split’). I am not able figure out what is the issue.
sharing the code here,

convertHtmlToPdf(elementId: string): void {
console.log("ViewInstance: ", this.viewerInstance)
let htmlString = document.getElementById(elementId);
this.viewerInstance.Core.createDocument(htmlString, {
extension: ‘pdf’,
}).then((doc: any) => {
console.log(‘hit’)
doc.getPDFBuffer().then((buffer: ArrayBuffer) => {
const blob = new Blob([buffer], { type: ‘application/pdf’ });
const link = document.createElement(‘a’);
link.href = window.URL.createObjectURL(blob);
link.download = ‘output.pdf’;
link.click();
});
});
}

FYI instance has been created successfully. Please provide a quick suggestion on this issue.

Q: are we able to convert html string to pdf using this package ?

Thank you for posting your question to our forum. We will provide you with an update as soon as possible.

Hello @marafath368,

Thank you for contacting WebViewer support.

If you have not already, please see our guide on converting HTML to PDF here: Convert-html | Apryse Documentation

This will include options for converting HTML using our Windows / Linux SDKs.

If you are still experiencing issues, feel free to provide the following:

  1. Source HTML file used for testing
  2. Screenshot of any errors in the console as well as any failed network logs
  3. Steps to reproduce the issue

Best Regards,
Jacob Romano Carlsen
Web Development Support Engineer
Apryse Software Inc.

WebViewer Version: 10.10.1

Do you have an issue with a specific file(s)? I am getting error on console, not able to download the file
Can you reproduce using one of our samples or online demos?
Are you using the WebViewer server? No
Does the issue only happen on certain browsers? No
Is your issue related to a front-end framework? No
Is your issue related to annotations? Not sure

Please give a brief summary of your issue:
Hi,
I am creating POC for converting html contents to PDF through pdfTron, but unfortunately I am receiving a console error saying Cannot read properties of undefined (reading ‘split’). I am not able figure out what is the issue.
sharing the code here,

convertHtmlToPdf(elementId: string): void {
console.log("ViewInstance: ", this.viewerInstance)
let htmlString = document.getElementById(elementId);
this.viewerInstance.Core.createDocument(htmlString, {
extension: ‘pdf’,
}).then((doc: any) => {
console.log(‘hit’)
doc.getPDFBuffer().then((buffer: ArrayBuffer) => {
const blob = new Blob([buffer], { type: ‘application/pdf’ });
const link = document.createElement(‘a’);
link.href = window.URL.createObjectURL(blob);
link.download = ‘output.pdf’;
link.click();
});
});
}

FYI instance has been created successfully. Please provide a quick suggestion on this issue.

Hello @marafath368,

Thank you for the update.

createDocument() is not able to convert HTML to a PDF directly. You can find the API doc here for approved types: Apryse WebViewer Namespace: Core

If you would like to convert HTML to PDF, please see our guides here for how to do so: Html | Apryse Documentation

Additionally, we have some sample code you can reference here: Samples | Apryse Documentation

Let me know if this works for you.

Best Regards,
Jacob Romano Carlsen
Web Development Support Engineer
Apryse Software Inc.