Java tutorial
package objects; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Image; import com.itextpdf.text.Rectangle; import com.itextpdf.text.pdf.PdfWriter; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Arnav */ public class manipulate { public static void createPDF(String filename, String[] RESOURCES) throws DocumentException, FileNotFoundException, IOException { Document document = new Document(); document.setMargins(0, 0, 0, 0); Rectangle rectangle = new Rectangle(0, 0, 742, 960); document.setPageSize(rectangle); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); Image img; for (int i = 0; i < RESOURCES.length; i++) { //img = Image.getInstance(String.format("resources/img/%s", RESOURCES[i])); img = Image.getInstance(RESOURCES[i]); if (img.getScaledWidth() > 742 || img.getScaledHeight() > 960) { img.scaleToFit(742, 960); } document.add(img); } document.close(); } }