Saturday 15 August 2015

javascript - Changing html2canvas to accept display as none -



javascript - Changing html2canvas to accept display as none -

i using jspdf create utilize of html2canvas. here illustration of it.

based on this answer, downloaded html2canvas , started using locally create alter suggested, because alternative of setting colour other answers proposed didn't worked me.

also, notice other requirement have different of html2canvas delivers default. need able generate pdf file if display set none.

note on illustration gave, alternative html renderer (early stages) works display none, implements poor render. on other hand, addhtml() using now, renders page is, implies render visible.

this default method of html2canvas decide consider visible.

function iselementvisible(element) { homecoming (getcss(element, 'display') !== "none" && getcss(element, 'visibility') !== "hidden" && !element.hasattribute("data-html2canvas-ignore")); }

i commented line: getcss(element, 'visibility') !== "hidden", , enabled me create pdf if visibility: hidden. samething not true display: none, if method homecoming true.

how implement it?

a node display: none can't domrect calculated it, not have 1 within dom (as display: none).

if want render display: none content, you'll need create display of node else prior rendering.

starting html2canvas 0.5.0, can provide onclone alternative html2canvas callback returns cloned document object, can go , modify dom see fit prior rendering it, without affecting original document.

javascript html2canvas jspdf

No comments:

Post a Comment