1 31 package org.pdfbox.util.operator; 32 33 import java.util.List ; 34 35 import org.pdfbox.util.Matrix; 36 import org.pdfbox.util.PDFOperator; 37 import org.pdfbox.cos.COSArray; 38 import org.pdfbox.cos.COSBase; 39 import org.pdfbox.cos.COSNumber; 40 import java.io.IOException ; 41 import org.pdfbox.cos.COSString; 42 43 52 53 public class ShowTextGlyph extends OperatorProcessor 54 { 55 61 public void process(PDFOperator operator, List arguments) throws IOException 62 { 63 COSArray array = (COSArray)arguments.get( 0 ); 64 float adjustment=0; 65 for( int i=0; i<array.size(); i++ ) 66 { 67 COSBase next = array.get( i ); 68 if( next instanceof COSNumber ) 69 { 70 adjustment = ((COSNumber)next).floatValue(); 71 72 Matrix adjMatrix = new Matrix(); 73 adjustment=(-adjustment/1000)*context.getGraphicsState().getTextState().getFontSize() * 74 (context.getGraphicsState().getTextState().getHorizontalScalingPercent()/100); 75 adjMatrix.setValue( 2, 0, adjustment ); 76 context.setTextMatrix( adjMatrix.multiply( context.getTextMatrix() ) ); 77 } 78 else if( next instanceof COSString ) 79 { 80 context.showString( ((COSString)next).getBytes() ); 81 } 82 else 83 { 84 throw new IOException ( "Unknown type in array for TJ operation:" + next ); 85 } 86 } 87 } 88 89 } 90 | Popular Tags |