DEV Community

khalildg
khalildg

Posted on

html-pdf problem

hi guys , i'm new at field.
i trying to make pdf generator web application with expressjs using html-pdf package.
i have condition on "engagement" variable
module.exports =
({rs,periode,engagement,siren,num,rue,codePostal,ville,contratRef,commentaire,nomPrenom,fonction,phone,mail}) => {
const today = new Date();
return `
<!DOCTYPE html>




<div class="highlight"><pre class="highlight plaintext"><code>window.onload = function test() {

var en = (document.getElementById('choix1'));
var en1 = (document.getElementById('choix2'));

if (${ engagement } == "oui") {
en.checked = true;
}else if (${ engagement } == "non") {
en1.checked = true
}
}
</code></pre></div>
<p>

when client send data to back end the app crashed and error "cannot set headers after they are sent to the client" in my terminal. how can i resolve this problem ?

Top comments (0)