Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
How to get the HTML Data except Viewport?

Here I mentioned some sample code. I'm converting div to image using the dom-to-image library. I'm trying to get the full data of a HTML div element without changing its position. I lose data from the Left and Top of the element. What is the best way to get the whole data of the element without changing the position or suggesting a library for solving this problem?

<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dom-to-image/2.6.0/dom-to-image.min.js"></script>
<title>Page Title</title>
<style>
#canvas {
    height: 200px;
    width: 200px;
    border: 1px solid;
    position: absolute;
    top: -100px;
    left: -100px
}
</style>

</head>
<body>

<div id="canvas">
<div>This is for testing purpose</div>
</div>

<script>
  var canvasId = document.getElementById('canvas');
  domtoimage.toJpeg(canvasId, { bgcolor: 'white' }).then(res => {
    var link = document.createElement('a');
    link.download = 'sample.jpeg';
    link.href = res;
    link.click();
  })
</script>
</body>
</html>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda