Image
class provides the method ‘setAbsolutePosition’ to set the image at given
position.
import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Image; import com.itextpdf.text.pdf.PdfWriter; public class TestImage { public static void main(String args[]) throws DocumentException, MalformedURLException, IOException { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("my_images.pdf")); document.open(); Image image1 = Image.getInstance("lion.jpeg"); image1.scalePercent(50); image1.setAbsolutePosition(400, 650); document.add(image1); document.close(); } }
No comments:
Post a Comment