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

151
Views
Validate img to save with JSpdf

i have 3 inputs to upload 3 diferent images, i want to validate if 2 of the input have uploaded image, then save as pdf, if i have just 1 can save it to pdf. This is my code of JSPdf:

 if(parseInt(img) === 0){
        doc.addImage('JPEG', 16,110,85,85);
        } else {
            doc.addImage(img2, 'JPEG', 110,110,85,85);
            doc.addImage(img3, 'JPEG', 16,200,85,85);
        } 

        if(parseInt(img2) === 0){
            doc.addImage('JPEG', 110,110,85,85);
        } else {
            doc.addImage(img, 'JPEG', 16,110,85,85);
            doc.addImage(img3, 'JPEG', 16,200,85,85);
        } 
        
        if(parseInt(img3) === 0){
            doc.addImage('JPEG', 16,200,85,85);
        } else {
            doc.addImage(img, 'JPEG', 16,110,85,85);
            doc.addImage(img2, 'JPEG', 110,110,85,85);
        } 

doc.save('mypdf.pdf');

img, img1 and img2 works if i upload the 3 images at same time but if i upload just 1 or 2 it doesn't work.

When i use this code:

      doc.addImage(imagen, 'JPEG', 16,110,85,85);
      doc.addImage(imagen2, 'JPEG', 110,110,85,85);
      doc.addImage(imagen3, 'JPEG', 16,200,85,85);

Works great but only if ai upload the 3 img at same time, if i try to upload just one or two not working.

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!