• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

112
Vistas
Declare new height and width for every new page on added jspdf using javascript
var doc = new jsPDF('px','px', [388, 2401]); 
var width = doc.internal.pageSize.getWidth;
var height = doc.internal.pageSize.getHeight;
doc.addImage(img, 'JPEG', 0, 0, width, height);
doc.addPage();
doc.addImage(img1, 'JPEG', 0, 0, new_width, new_height); // another image 
doc.save("gg.pdf");

How can I re assign new width and height for every new image on jspdf as new jsPDF('px','px', [388, 2401]); only works for first image any way to do so that I can set new width and height for every image I add to pdf? Any suggestions would be appreciated.

about 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

We seem to agree that px appears to be applied as 54 per inch

// We must declare 1st page canvas before use "p", is for portrait then default units , [size x, size y] 
var doc = new jsPDF("p", "px", [388, 2401]); 
var width = doc.internal.pageSize.getWidth;
var height = doc.internal.pageSize.getHeight;
doc.addImage(img, 'JPEG', 0, 0, width, height);

// oddly the order for new page is reversed, so size, then orientation
doc.addPage([new_width, new_height], "p");
doc.addImage(img1, 'JPEG', 0, 0, new_width, new_height); // another image
 
doc.save("gg.pdf");

However always check the scaling these 2 should be same units just rotated, they report same dimension and appearance of difference is perhaps an illusion. Same file, facing pages, one pane set as MangaMode

enter image description here

about 3 years ago · Juan Pablo Isaza Denunciar
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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda