Dom-to-image: Cant print position: absolute

Created on 28 Feb 2017  路  4Comments  路  Source: tsayen/dom-to-image

Hey there,

I am having some problems with printing elements that have position set to absolute. I am using Chrome.

Is this intended?

Thanks,

Most helpful comment

I am using a similar implementation, with the temporary off-screen element to render the nodes I want to capture. Using this configuration, I can call domtoimage.toPng() on nodes that are dynamically appended to the #viz-container element and everything works as expected.

<!-- css
#viz-containment{
  position:relative;
  overflow:hidden;
  height:0;
  width:0;
}
#viz-container{
  width:100vw;
  position:absolute;
  left:-10000vw;
}
-->

<!-- body -->
<div id="viz-containment">
  <div id="viz-container"></div>
</div>
<!-- /body -->

All 4 comments

I have the same issue. My element has position: absolute and left position set to be off the screen, as it's a temporary element that would be used only for capturing into an image using this lib. However, the image rendered never includes my element, just empty pixels.

I am using a similar implementation, with the temporary off-screen element to render the nodes I want to capture. Using this configuration, I can call domtoimage.toPng() on nodes that are dynamically appended to the #viz-container element and everything works as expected.

<!-- css
#viz-containment{
  position:relative;
  overflow:hidden;
  height:0;
  width:0;
}
#viz-container{
  width:100vw;
  position:absolute;
  left:-10000vw;
}
-->

<!-- body -->
<div id="viz-containment">
  <div id="viz-container"></div>
</div>
<!-- /body -->

Had the same issue as @tafs7 , my solution was to simply set the z-index below the rest of my content. Opacity 0 seemed to work as well as this library doesn't take it into account.

css

#nodeToTransform { 
  height: 0px;
  z-index: -99;
}

solved my issues to generate the image from an element outside of view.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanielZambranoC picture DanielZambranoC  路  5Comments

ezramod picture ezramod  路  5Comments

pete-hotchkiss picture pete-hotchkiss  路  6Comments

Pistil-Studio picture Pistil-Studio  路  6Comments

distroyq picture distroyq  路  6Comments