I have a requirement to perform drag and drop functionality using iText jar file. and also I want to set the image width and height any help grately appriciated.
I am using the following code but unable to set the size of the image(Hint: Half of my PDF page will contain Image but I am unable to do that)
below is my code:
        String imgLoc = "E:/iText/Image1.jpg";
        Image image = Image.getInstance(imgLoc);
        image.setAbsolutePosition(100, 140);
        image.scaleToFit(100f, 70f);
        // image.setAbsolutePosition(280, 10);
        // image.setAbsolutePosition(absoluteX, absoluteY);
        // writer.getDirectContent().addImage(image);
        document.add(preface1);
				
                        
Try with .scalePercent() method. For example, if you want to reduce the size at 50% you can do:
Try different values until you get the one that fits you.