1 31 package org.pdfbox.pdmodel.font; 32 33 import java.awt.Image ; 34 35 import java.io.IOException ; 36 37 import java.util.List ; 38 39 import org.fontbox.util.BoundingBox; 40 41 import org.pdfbox.cos.COSNumber; 42 import org.pdfbox.cos.COSStream; 43 44 import org.pdfbox.pdmodel.graphics.xobject.PDInlinedImage; 45 46 import org.pdfbox.util.ImageParameters; 47 import org.pdfbox.util.PDFOperator; 48 import org.pdfbox.util.PDFStreamEngine; 49 50 56 public class Type3StreamParser extends PDFStreamEngine 57 { 58 private PDInlinedImage image = null; 59 private BoundingBox box = null; 60 61 62 71 public Image createImage( COSStream type3Stream ) throws IOException 72 { 73 processStream( null, null, type3Stream ); 74 return image.createImage(); 75 } 76 77 85 protected void processOperator( PDFOperator operator, List arguments ) throws IOException 86 { 87 super.processOperator( operator, arguments ); 88 String operation = operator.getOperation(); 89 if( operation.equals( "BI" ) ) 111 { 112 ImageParameters params = operator.getImageParameters(); 113 image = new PDInlinedImage(); 114 image.setImageParameters( params ); 115 image.setImageData( operator.getImageData() ); 116 }if( operation.equals( "d0" ) ) 150 { 151 } 157 else if( operation.equals( "d1" ) ) 158 { 159 COSNumber llx = (COSNumber)arguments.get( 2 ); 163 COSNumber lly = (COSNumber)arguments.get( 3 ); 164 COSNumber urx = (COSNumber)arguments.get( 4 ); 165 COSNumber ury = (COSNumber)arguments.get( 5 ); 166 167 box = new BoundingBox(); 170 box.setLowerLeftX( llx.floatValue() ); 171 box.setLowerLeftY( lly.floatValue() ); 172 box.setUpperRightX( urx.floatValue() ); 173 box.setUpperRightY( ury.floatValue() ); 174 } 605 } 606 607 608 } | Popular Tags |