1 17 18 19 20 21 27 28 package org.apache.fop.render.rtf.rtflib.testdocs; 29 30 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; 31 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; 32 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic; 33 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; 34 35 import java.io.IOException ; 36 41 class ExternalGraphic extends TestDocument { 42 private String file = "file:///tmp/jfor-images/logo."; 43 44 48 51 public ExternalGraphic () { 52 53 } 54 55 protected void generateDocument (RtfDocumentArea rda, RtfSection sect) throws IOException { 56 RtfParagraph p = sect.newParagraph (); 57 p.newLineBreak(); 58 p.newLineBreak(); 59 p.newLineBreak(); 60 p.newText ("EMF image with 150 % height"); 61 p.newLineBreak(); 62 RtfExternalGraphic imageA = p.newImage (); 63 imageA.setURL (file + "emf"); 64 imageA.setHeight ("150%"); 65 p.newLineBreak(); 66 p.close(); 67 68 p = sect.newParagraph(); 69 p.newLineBreak(); 70 p.newText ("PNG image with 150 % width"); 71 p.newLineBreak(); 72 RtfExternalGraphic imageB = sect.newImage (); 73 imageB.setURL (file + "png"); 74 imageB.setWidth ("150%"); 75 p.newLineBreak(); 76 p.close(); 77 78 p = sect.newParagraph(); 79 p.newLineBreak(); 80 p.newLineBreak(); 81 p.newText ("JPG image with width = 200px and height = 20 px"); 82 p.newLineBreak(); 83 RtfExternalGraphic imageC = sect.newImage (); 84 imageC.setURL (file + "jpg"); 85 imageC.setWidth ("200"); 86 imageC.setHeight ("20"); 87 p.newLineBreak(); 88 p.close(); 89 90 p = sect.newParagraph(); 91 p.newLineBreak(); 92 p.newLineBreak(); 93 p.newText ("GIF image with width = 200px and scaling = 'uniform', that means the image " 94 + "size will adjusted automatically"); 95 p.newLineBreak(); 96 RtfExternalGraphic imageD = sect.newImage (); 97 imageD.setURL (file + "gif"); 98 imageD.setWidth ("200"); 99 imageD.setScaling ("uniform"); 100 p.newLineBreak(); 101 p.close(); 102 103 p = sect.newParagraph(); 104 p.newLineBreak(); 105 p.newLineBreak(); 106 p.newText ("GIF image"); 107 p.newLineBreak(); 108 RtfExternalGraphic imageE = sect.newImage (); 109 imageE.setURL (file + "gif"); 110 p.newLineBreak(); 111 p.close(); 112 113 } 114 115 116 117 } 118 | Popular Tags |