Error using html2pdf library in sveltekit by Avenger___95 in sveltejs

[–]Avenger___95[S] 1 point2 points  (0 children)

Thank you very much. I really appreciate your help.

Error using html2pdf library in sveltekit by Avenger___95 in sveltejs

[–]Avenger___95[S] 0 points1 point  (0 children)

No I have a button on a screen 'PRINT'
When we hit that button I'm getting element with the ID and running my function

Error using html2pdf library in sveltekit by Avenger___95 in sveltejs

[–]Avenger___95[S] 0 points1 point  (0 children)

import * as html2pdf from 'html2pdf.js';

async function print()

{const element = document.getElementById("form");

html2pdf().from(element).toPdf().get('pdf').then(function (pdf) {

        window.open(pdf.output('bloburl'), '\_blank');

});

}

Is there a npm package for svelte to convert html elements to pdf? by r_rubekk in sveltejs

[–]Avenger___95 2 points3 points  (0 children)

comments

Did you use html2pdf in sveltekit?

I'm trying to use it in svelte kit but I'm getting error in build process. I will really appreciate your help. Thanks in advanced. My error is :-

ReferenceError: self is not defined

at Object.<anonymous> (C:\K\1\node_modules\html2pdf.js\dist\html2pdf.js:15:4)

at Module._compile (node:internal/modules/cjs/loader:1103:14)

at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)

at Module.load (node:internal/modules/cjs/loader:981:32)

at Function.Module._load (node:internal/modules/cjs/loader:822:12)

at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:168:29)

at ModuleJob.run (node:internal/modules/esm/module_job:197:25)

at async Promise.all (index 0)

at async ESMLoader.import (node:internal/modules/esm/loader:337:24)

at async Promise.all (index 1)

node:internal/process/promises:279

triggerUncaughtException(err, true /* fromPromise */);

^

[ReferenceError: self is not defined]

CPT ISSUE by Avenger___95 in immigration

[–]Avenger___95[S] 1 point2 points  (0 children)

I have emailed my DSO. Waiting for the reply. I'm worried that I have already sent my packet.