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

147
Views
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 4 years ago · Juan Pablo Isaza
1 answers
Answer question

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 4 years ago · Juan Pablo Isaza Report
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!