Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
¿Cómo cortar un lienzo grande que tiene una imagen dibujada en un archivo pdf de varias páginas HORIZONTALES y VERTICALES?

Hasta ahora he probado muchas variaciones diferentes de este código.

 function printCanvas(canvasId,title){ var canvas = document.getElementById(canvasId); var imgData = canvas.toDataURL('image/png'); //var imgWidth = 210; // var masterWidth = canvas.width; // var imgWidth = 210; // var pageHeight = 295; // var imgHeight = canvas.height * imgWidth / canvas.width; // var masterHeight = canvas.height * imgWidth / canvas.width; // var heightLeft = imgHeight; // var doc = new jsPDF('p', 'pt'); // pageWidth = 595; // pageHeight = 852; var doc = new jsPDF("p", "mm", [317.5,396.875]); var pageWidth = 317.5; var pageHeight = 396.875; var position = 0; // doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); // heightLeft -= pageHeight; // while (heightLeft >= 0) { // position = heightLeft - imgHeight; // doc.addPage(); // doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); // heightLeft -= pageHeight; // } addP = 0; for (var y=0;y<Math.ceil(canvas.height/pageHeight);y++){ for (var x=0;x<Math.ceil(canvas.width/pageWidth);x++){ if (addP == 1){ doc.addPage(); } doc.addImage(imgData,'PNG',x*pageWidth,y*pageHeight,pageWidth,pageHeight) addP = 1; } } doc.save( 'pattern.pdf'); }

y nada parece funcionar hasta ahora. Lo quiero para que cada página del pdf muestre una imagen de 1200 píxeles de ancho por 1500 píxeles de alto, pero no se ajuste a la página para que se mantenga con las proporciones de píxeles cuadrados correctos (no estirada). y cruzaría por recorte hasta que se alcance el borde derecho de la imagen y luego se desplazará hacia abajo hasta que se muestre la imagen completa (o se pueda ensamblar cuando se imprima el pdf).

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!