rasterizeHTML.js icon indicating copy to clipboard operation
rasterizeHTML.js copied to clipboard

Body or Html element background does not apply to whole canvas

Open cburgmer opened this issue 9 years ago • 2 comments

A background defined on <body> or <html> are supposed to apply to the whole canvas, not just the size of the element itself (http://www.w3.org/TR/css3-background/#special-backgrounds).

Also see #94

cburgmer avatar Mar 22 '15 17:03 cburgmer

Is it possible to sneak into attached stylesheets to check background color associated with body or html or classes associated with them? Once the color is found, canvas can be filled with that color before drawing the rasterized content. I believe this approach will some clashes with Firefox's Cross-domain Security.

Another approach could be:

  1. Clone the document.
  2. Create and Attach a <div /> element to body of a cloned document.
  3. Make this div 100% of scrollWidth and scrollHeight of document.
  4. move the content of <body /> into created <div />.
  5. Rasterize

Since the <div /> will occupy entire page size, background color in that region will be visible.

cchandurkar avatar Mar 03 '16 06:03 cchandurkar

The document in any case ends up being loaded in an iframe, detached from the original URL. So we should be able to inspect it from the outside. As you propose, the background color can be proactively set, as a workaround for this limitation. However, I would not bother with the canvas, but try to apply it to the SVG image, which is the interim representation.

cburgmer avatar Mar 03 '16 14:03 cburgmer