1 import java.util.*; 2 import java.io.*; 3 import java.awt.Color ; 4 import org.faceless.pdf2.*; 5 6 11 public class Images 12 { 13 public static void main(String [] args) 14 throws IOException 15 { 16 PDF pdf = new PDF(); 19 20 PDFPage page = pdf.newPage(PDF.PAGESIZE_A4_LANDSCAPE); 23 24 25 float width = page.getWidth(); 30 float height = page.getHeight(); 31 page.setUnits(PDFPage.UNITS_POINTS, PDFPage.ORIGIN_PAGETOP); 32 33 34 PDFStyle background = new PDFStyle(); 37 background.setFillColor(new Color (208,231,240)); 38 page.setStyle(background); 39 page.drawRectangle(100, 100, width-100, height-100); 40 41 42 PDFImage map = new PDFImage(new FileInputStream("resources/images/africa.gif")); 49 PDFImage sand = new PDFImage(new FileInputStream("resources/images/sanddune.jpg")); 50 PDFImage canoe = new PDFImage(new FileInputStream("resources/images/canoe.jpg")); 51 PDFImage logo = new PDFImage(new FileInputStream("resources/images/logosmall.png")); 52 53 54 63 page.drawImage(map, width-430, 100, width-100, height-100); 67 68 page.drawImage(canoe, 120, 120, 350, 260); 73 page.drawImage(sand, 120, 315, 350, 455); 74 75 page.drawImage(logo, width-220, height, width-100, height-100); 81 82 83 84 PDFStyle borderStyle = new PDFStyle(); 89 borderStyle.setLineColor(Color.black); 90 page.setStyle(borderStyle); 91 page.drawRectangle(100, 100, width-100, height-100); 92 93 94 95 102 PDFStyle footer = new PDFStyle(); 109 footer.setFont(new StandardFont(StandardFont.HELVETICAOBLIQUE), 8); 110 footer.setFillColor(Color.black); 111 footer.setTextAlign(PDFStyle.TEXTALIGN_RIGHT); 112 113 PDFStyle caption = new PDFStyle(); 114 caption.setFont(new StandardFont(StandardFont.TIMES), 12); 115 caption.setFillColor(Color.black); 116 117 PDFStyle heading = new PDFStyle(); 118 heading.setFont(new StandardFont(StandardFont.TIMES), 24); 119 heading.setFillColor(Color.black); 120 121 page.setStyle(heading); 124 page.drawText("Some Photos from Africa", 100, 70); 125 126 page.setStyle(caption); 127 page.drawText("An example showing two JPEG images, a GIF and a PNG image", 100, 90); 128 page.drawText("A fishing boat on the beach - Western Ghana", 120, 280); 129 page.drawText("The largest sand dunes in the world - Namibia", 120, 475); 130 131 page.setStyle(footer); 132 page.drawText("Document created using the Big Faceless PDF Library - http://big.faceless.org/products/pdf", width-240, height-45); 133 134 135 143 144 pdf.setInfo("Author", "Big Faceless Organization, Inc."); 147 pdf.setInfo("Title", "Some Photos from Africa"); 148 pdf.setInfo("Subject", "A feeble excuse to parade two of Mikes better holiday snaps"); 149 pdf.setAction(Event.OPEN, PDFAction.goToFit(page)); 150 151 OutputStream fo = new FileOutputStream("Images.pdf"); 154 pdf.render(fo); 155 fo.close(); 156 } 157 } 158 | Popular Tags |