jsPDF & Html2Canvas Tutorial to Convert Div With Attribute Hidden to PDF and Print it in Browser Using HTML5 & Javascript

 

 

To hide an HTML tag; add this attribute tag data-html2canvas-ignore="true" instead of the hidden.

 

 

So with Mario Alexandro Santini’s suggestion in the comments, I was able to solve the problem. I used jquery to unhide the div in my makePdf() function then hide it again after jsPDF and html2canvas had done their “magic”:

 

 

 

 

 

 

You could change the layout of your page on different media through css.

This is true for printing too.

So you could write a dedicated stylesheet that is valid only when you print the page in pdf.

Please have a look at:

For your example you could use a code like:

This should select the div with hidden attribute and made those visible.

If you prefere the programatic approach then you could get all div in the page with attribute hidden and remove the attribute, print your document, than put the attribute back.

You could use something like:

 

 

Leave a Reply