msokk / electron-render-service

Microservice for rendering PDF/PNG/JPEG from HTML with Electron
MIT License
102 stars 31 forks source link

Refactor waitForText to use HTML body (allows to wait for non-visual text) #49

Open msl-kabo opened 7 years ago

msl-kabo commented 7 years ago

I've got a page with an animation on it, and want to generate a PDF of the page after the animation has finished. I can't use waitForText with a text that's on the page because that generates a PDF from before the animation. So I tried setting a timeout for when the animation should be done that renders a text with style display: none. That text doesn't seem to get picked up though. I tried display: hidden but that text got visibly rendered unfortunately.

Could we please have waitForText detect text with display: none (or some other solution that achieves the goal of triggering the pdf render without being visible on the pdf)?

msl-kabo commented 7 years ago

I meant visibility: hidden, not display: hidden

msl-kabo commented 7 years ago

<div style="font-size: 0px; margin: 0px; padding: 0px;">PdfOkToGo</div> seems to work though.

msokk commented 7 years ago

Hi,

waitForText uses browsers find in page functionality, so unfortunately it currently only detects visible text (opacity: 0 works too).

document.body.innerText behaves the same, so using that is off the table. Would have to rewrite it going through innerHTML.