1

My paper its B4 - 17,60cm x 24,50cm

its scanned have the size in pixels -> 2048 x 2929

im creating a PDF as A4 size (2480px x 3508px) using itext.. but im unable to scale it with margins, and not even without margins, i need to insert the B4 image into the PDF A4 size, using LEFT margin of 2,5cm and the RIGH margin 2cm, but how can i make it fit calculating the sizes, since a paper A4 has 2480x3508, the B4 image has 2048x2929, if i insert, it cut? the b4 is bigger :| how?? considering size of A4, and the b4 should fit perfectly inside the A4

if i do this:

doc = new Document(PageSize.A4, 0, 0, 0, 0);
os = new FileOutputStream(arquivonomecompleto);
        PdfWriter.getInstance(doc, os);
        doc.open();
       Image img = Image.getInstance(arraypath[i]); // the array store the path to the image    
      //  img.scaleToFit(2090, 1208); // i tried a lot of modifications, i can set i to 500x500 or something like this in have all showed in the pdf, but how can i calculate margins


           doc.add(img);
               doc.add(new Paragraph("TEST: text under the b4 image");
           doc.newPage();

still cutting

if i convert the 17cm and 29,70cm to pixels, and set it in the img.setScaleToFit, still cutting, how? or my computer is crazy or the PDF A4 Size of ITEXT is wrong :|

look what i want:

enter image description here

edit: ops, the margin of LEFT side is 2cm too :)

4

0 回答 0