From 4f296fc3f837412b330f5a5183769dba50704649 Mon Sep 17 00:00:00 2001 From: pdanner Date: Tue, 9 Nov 2010 10:34:41 +0000 Subject: signature positioning bugfix git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@607 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../at/knowcenter/wag/egov/egiz/pdf/PDFPage.java | 287 +++------------------ 1 file changed, 36 insertions(+), 251 deletions(-) diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java index 0bae3d2..cb4e642 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java @@ -88,248 +88,6 @@ public class PDFPage extends PDFTextStripper operators.put("Do", newInvoke); } - // /** - // * You should override this method if you want to perform an action when a - // * string is being shown. - // * - // * @param string The string to display. - // * - // * @throws IOException If there is an error showing the string - // */ - // public void showString( byte[] string ) throws IOException - // { - // float spaceWidth = 0; - // float spacing = 0; - // StringBuffer stringResult = new StringBuffer(string.length); - // - // float characterDisplacement = 0; - // float spaceDisplacement = 0; - // - // PDGraphicsState graphicsState = getGraphicsState(); - // float fontSize = graphicsState.getTextState().getFontSize(); - // float horizontalScaling = - // graphicsState.getTextState().getHorizontalScalingPercent()/100f; - // float rise = graphicsState.getTextState().getRise(); - // final float wordSpacing = graphicsState.getTextState().getWordSpacing(); - // final float characterSpacing = - // graphicsState.getTextState().getCharacterSpacing(); - // float wordSpacingDisplacement = 0; - // - // PDFont font = graphicsState.getTextState().getFont(); - // - // //This will typically be 1000 but in the case of a type3 font - // //this might be a different number - // float glyphSpaceToTextSpaceFactor = 1f/font.getFontMatrix().getValue( 0, 0 - // ); - // Float averageWidth = (Float)fontToAverageWidths.get( font ); - // if( averageWidth == null ) - // { - // averageWidth = new Float( font.getAverageFontWidth() ); - // fontToAverageWidths.put( font, averageWidth ); - // } - // - // Matrix initialMatrix = new Matrix(); - // initialMatrix.setValue(0,0,1); - // initialMatrix.setValue(0,1,0); - // initialMatrix.setValue(0,2,0); - // initialMatrix.setValue(1,0,0); - // initialMatrix.setValue(1,1,1); - // initialMatrix.setValue(1,2,0); - // initialMatrix.setValue(2,0,0); - // initialMatrix.setValue(2,1,rise); - // initialMatrix.setValue(2,2,1); - // - // - // //this - // int codeLength = 1; - // Matrix ctm = graphicsState.getCurrentTransformationMatrix(); - // - // //lets see what the space displacement should be - // spaceDisplacement = (font.getFontWidth( SPACE_BYTES, 0, 1 - // )/glyphSpaceToTextSpaceFactor); - // if( spaceDisplacement == 0 ) - // { - // spaceDisplacement = - // (averageWidth.floatValue()/glyphSpaceToTextSpaceFactor); - // //The average space width appears to be higher than necessary - // //so lets make it a little bit smaller. - // spaceDisplacement *= .80f; - // if( log.isDebugEnabled() ) - // { - // log.debug( "Font: Space From Average=" + spaceDisplacement ); - // } - // } - // int pageRotation = page.findRotation(); - // - // // very strange.... the ctms are multiplied by right, but suddenly the - // textM is multiplied from the left. - // // but: PDF matrices are multiplied from left ==> ctm is wrong - // Matrix trm = initialMatrix.multiply( textMatrix ).multiply( ctm ); - // float x = trm.getValue(2,0); - // float y = trm.getValue(2,1); - // float flipped_y = -y + page.findMediaBox().getHeight(); - // if( pageRotation == 0 ) - // { - // trm.setValue( 2,1, flipped_y ); - // } - // else if( pageRotation == 90 ) - // { - // trm.setValue( 2,0, y ); - // trm.setValue( 2,1, x ); - // } - // else if( pageRotation == 270 ) - // { - // trm.setValue( 2,0, flipped_y ); - // trm.setValue( 2,1, x ); - // } - // for( int i=0; i