I am struggling to convert a lit template into pdf. I am using jsPDF (although I can use another javascript library if needed)
I have the following lit template to export into pdf
import { LitElement, html } from 'lit';
import { jsPDF } from "jspdf";
export class TestPage extends LitElement {
static properties = {
myHTML: { type: Object },
};
constructor() {
super();
this.myHTML = html`<h1>My title</h1>
<div>some text to export to pdf</div>`;
this.doc = new jsPDF();
this.doc.text(this.myHTML, 10, 10);
}
}
customElements.define('test-page', TestPage);
jsPDF returns:
Uncaught Error: Type of text must be string or Array. "[object Object]" is not recognized.
I do not have the option to render the lit template first before exporting it. I need to use the variable as a HTML source.
Thanks for any hints.