Package org.pdfbox.util

Examples of org.pdfbox.util.Matrix


            if( xobject instanceof PDXObjectImage )
            {
                try
                {
                    PDPage page = getCurrentPage();
                    Matrix ctm = getGraphicsState().getCurrentTransformationMatrix();
                    double rotationInRadians =(page.findRotation() * Math.PI)/180;
                    
                   
                    AffineTransform rotation = new AffineTransform();
                    rotation.setToRotation( rotationInRadians );
                    AffineTransform rotationInverse = rotation.createInverse();
                    Matrix rotationInverseMatrix = new Matrix();
                    rotationInverseMatrix.setFromAffineTransform( rotationInverse );
                    Matrix rotationMatrix = new Matrix();
                    rotationMatrix.setFromAffineTransform( rotation );
                   
                    Matrix unrotatedCTM = ctm.multiply( rotationInverseMatrix );
                   
                    System.out.println( "Found image[" + objectName.getName() + "] " +
                            "at " + unrotatedCTM.getXPosition() + "," + unrotatedCTM.getYPosition() );
                }
                catch( NoninvertibleTransformException e )
                {
                    throw new WrappedIOException( e );
                }
View Full Code Here


        PDInlinedImage image = new PDInlinedImage();
        image.setImageParameters( params );
        image.setImageData( operator.getImageData() );
        BufferedImage awtImage = image.createImage();
       
        Matrix ctm = drawer.getGraphicsState().getCurrentTransformationMatrix();
       
        int width = awtImage.getWidth();
        int height = awtImage.getHeight();

       
        AffineTransform at = new AffineTransform(
            ctm.getValue(0,0)/width,
            ctm.getValue(0,1),
            ctm.getValue(1,0),
            ctm.getValue(1,1)/height,
            ctm.getValue(2,0),
            ctm.getValue(2,1)
        );
        //at.setToRotation((double)page.getRotation());

       
        // The transformation should be done
View Full Code Here

     * @param operator The operator that is being executed.
     * @param arguments List
     */
    public void process(PDFOperator operator, List arguments)
    {
        context.setTextMatrix( new Matrix());
        context.setTextLineMatrix( new Matrix() );
    }
View Full Code Here

        COSNumber c = (COSNumber) arguments.get(2);
        COSNumber d = (COSNumber) arguments.get(3);
        COSNumber e = (COSNumber) arguments.get(4);
        COSNumber f = (COSNumber) arguments.get(5);
   
        Matrix newMatrix = new Matrix();
        newMatrix.setValue(0, 0, a.floatValue());
        newMatrix.setValue(0, 1, b.floatValue());
        newMatrix.setValue(1, 0, c.floatValue());
        newMatrix.setValue(1, 1, d.floatValue());
        newMatrix.setValue(2, 0, e.floatValue());
        newMatrix.setValue(2, 1, f.floatValue());
   
        //this line has changed
        context.getGraphicsState().setCurrentTransformationMatrix(
                newMatrix.multiply( context.getGraphicsState().getCurrentTransformationMatrix() ) );

    }
View Full Code Here

        {
            PDXObjectImage image = (PDXObjectImage)xobject;
            try
            {
                BufferedImage awtImage = image.getRGBImage();
                Matrix ctm = drawer.getGraphicsState().getCurrentTransformationMatrix();
               
                int width = awtImage.getWidth();
                int height = awtImage.getHeight();

                double rotationInRadians =(page.findRotation() * Math.PI)/180;
                
               
                AffineTransform rotation = new AffineTransform();
                rotation.setToRotation( rotationInRadians );
                AffineTransform rotationInverse = rotation.createInverse();
                Matrix rotationInverseMatrix = new Matrix();
                rotationInverseMatrix.setFromAffineTransform( rotationInverse );
                Matrix rotationMatrix = new Matrix();
                rotationMatrix.setFromAffineTransform( rotation );
               
                Matrix unrotatedCTM = ctm.multiply( rotationInverseMatrix );
               
                Matrix scalingParams = unrotatedCTM.extractScaling();
                Matrix scalingMatrix = Matrix.getScaleInstance(1f/width,1f/height);
                scalingParams = scalingParams.multiply( scalingMatrix );
               
                Matrix translationParams = unrotatedCTM.extractTranslating();
                Matrix translationMatrix = null;
                int pageRotation = page.findRotation();
                if( pageRotation == 0 )
                {
                    translationParams.setValue(2,1, -translationParams.getValue( 2,1 ));
                    translationMatrix = Matrix.getTranslatingInstance(
View Full Code Here

        COSNumber c = (COSNumber)arguments.get( 2 );
        COSNumber d = (COSNumber)arguments.get( 3 );
        COSNumber e = (COSNumber)arguments.get( 4 );
        COSNumber f = (COSNumber)arguments.get( 5 );

        Matrix textMatrix = new Matrix();
        textMatrix.setValue( 0, 0, a.floatValue() );
        textMatrix.setValue( 0, 1, b.floatValue() );
        textMatrix.setValue( 1, 0, c.floatValue() );
        textMatrix.setValue( 1, 1, d.floatValue() );
        textMatrix.setValue( 2, 0, e.floatValue() );
        textMatrix.setValue( 2, 1, f.floatValue() );
        context.setTextMatrix( textMatrix );
        context.setTextLineMatrix( textMatrix.copy() );
    }
View Full Code Here

            COSBase next = array.get( i );
            if( next instanceof COSNumber )
            {
                adjustment = ((COSNumber)next).floatValue();

                Matrix adjMatrix = new Matrix();
                adjustment=(-adjustment/1000)*context.getGraphicsState().getTextState().getFontSize() *
                    (context.getGraphicsState().getTextState().getHorizontalScalingPercent()/100);
                adjMatrix.setValue( 2, 0, adjustment );
                context.setTextMatrix( adjMatrix.multiply( context.getTextMatrix() ) );
            }
            else if( next instanceof COSString )
            {
                context.showString( ((COSString)next).getBytes() );
            }
View Full Code Here

     */
    public void process(PDFOperator operator, List arguments)
    {
        COSNumber x = (COSNumber)arguments.get( 0 );
        COSNumber y = (COSNumber)arguments.get( 1 );
        Matrix td = new Matrix();
        td.setValue( 2, 0, x.floatValue() );//.* textMatrix.getValue(0,0) );
        td.setValue( 2, 1, y.floatValue() );//* textMatrix.getValue(1,1) );
        //log.debug( "textLineMatrix before " + textLineMatrix );
        context.setTextLineMatrix( td.multiply( context.getTextLineMatrix() ) ); //textLineMatrix.multiply( td );
        //log.debug( "textLineMatrix after " + textLineMatrix );
        context.setTextMatrix( context.getTextLineMatrix().copy() );
    }
View Full Code Here

TOP

Related Classes of org.pdfbox.util.Matrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.