1 import org.faceless.pdf2.*; 2 import java.io.*; 3 import java.awt.Color ; 4 import java.util.*; 5 6 public class LayoutExample 12 { 13 static String text1 = "orem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."; 14 15 16 public static void main(String [] args) 17 throws IOException 18 { 19 PDF pdf = new PDF(); 23 PDFPage page = pdf.newPage(PDF.PAGESIZE_A4); 24 25 PDFStyle style = new PDFStyle(); 26 style.setTextAlign(PDFStyle.TEXTALIGN_JUSTIFY + PDFStyle.TEXTALIGN_BOTTOM); 27 style.setFont(new StandardFont(StandardFont.TIMES), 9); 28 style.setFillColor(Color.black); 29 30 PDFImage image = new PDFImage(new FileInputStream("resources/L.gif")); 31 LayoutBox.Box imagebox=null; 32 33 34 LayoutBox flow = new LayoutBox(page.getWidth()-200); 37 flow.setStyle(style); 38 39 imagebox = flow.addBoxLeft(image.getWidth()/3, image.getHeight()/3, LayoutBox.CLEAR_LEFT); 43 imagebox.setImage(image); 44 flow.addText(text1, style, Locale.getDefault()); 45 flow.addLineBreak(style); 46 flow.addLineBreak(style); 47 48 imagebox = flow.addBoxInline(image.getWidth()/3, image.getHeight()/3, 0); 54 imagebox.setImage(image); 55 flow.addText(text1, style, Locale.getDefault()); 56 imagebox = flow.addBoxInline(9, 9, 0); 60 imagebox.setImage(image); 61 flow.addText(text1, style, Locale.getDefault()); 62 63 int top = (int)page.getHeight()-50; 66 page.drawLayoutBox(flow, 100, top); 67 style.setLineColor(Color.red); 68 style.setFillColor(null); 69 page.setStyle(style); 70 page.drawRectangle(100, top, page.getWidth()-100, top-flow.getHeight()); 71 72 pdf.render(new FileOutputStream("LayoutExample.pdf")); 73 } 74 } 75 | Popular Tags |