Package org.apache.pdfbox.util

Examples of org.apache.pdfbox.util.Matrix


        }
        int imageWidth = awtImage.getWidth();
        int imageHeight = awtImage.getHeight();
        double pageHeight = pageSize.getHeight();
       
        Matrix ctm = drawer.getGraphicsState().getCurrentTransformationMatrix();
        int pageRotation = page.findRotation();

        AffineTransform ctmAT = ctm.createAffineTransform();
        ctmAT.scale(1f/imageWidth, 1f/imageHeight);
        Matrix rotationMatrix = new Matrix();
        rotationMatrix.setFromAffineTransform( ctmAT );
        if (pageRotation == 0 || pageRotation == 180)
        {
            rotationMatrix.setValue(2,1,(float)pageHeight-ctm.getYPosition()-ctm.getYScale());
        }
        else if (pageRotation == 90 || pageRotation == 270)
        {
            rotationMatrix.setValue(2,0,(float)ctm.getXPosition()-ctm.getYScale());
            rotationMatrix.setValue(2,1,(float)pageHeight-ctm.getYPosition());
        }
        rotationMatrix.setValue(0, 1, (-1)*rotationMatrix.getValue(0, 1));
        rotationMatrix.setValue(1, 0, (-1)*rotationMatrix.getValue(1, 0));
        AffineTransform at = new AffineTransform(
                rotationMatrix.getValue(0,0),rotationMatrix.getValue(0,1),
                rotationMatrix.getValue(1,0), rotationMatrix.getValue( 1, 1),
                rotationMatrix.getValue(2,0),rotationMatrix.getValue(2,1)
                );
        Shape clip = context.getGraphicsState().getCurrentClippingPath();
        // If the pdf is printed, sometimes a NPE occurs, see PDFBOX-552 for details
        // As a workaround we have to replace a possible null-value with a rectangle having
        // the same dimension than the page to be printed
View Full Code Here


                int imageHeight = awtImage.getHeight();
                double pageHeight = pageSize.getHeight();

                log.info("imageWidth: " + imageWidth + "\t\timageHeight: " + imageHeight);
       
                Matrix ctm = drawer.getGraphicsState().getCurrentTransformationMatrix();
                int pageRotation = page.findRotation();

                AffineTransform ctmAT = ctm.createAffineTransform();
                ctmAT.scale(1f/imageWidth, 1f/imageHeight);
                Matrix rotationMatrix = new Matrix();
                rotationMatrix.setFromAffineTransform( ctmAT );
                if (pageRotation == 0 || pageRotation == 180)
                {
                    rotationMatrix.setValue(2,1,(float)pageHeight-ctm.getYPosition()-ctm.getYScale());
                }
                else if (pageRotation == 90 || pageRotation == 270)
                {
                    rotationMatrix.setValue(2,0,(float)ctm.getXPosition()-ctm.getYScale());
                    rotationMatrix.setValue(2,1,(float)pageHeight-ctm.getYPosition());
                }
                rotationMatrix.setValue(0, 1, (-1)*rotationMatrix.getValue(0, 1));
                rotationMatrix.setValue(1, 0, (-1)*rotationMatrix.getValue(1, 0));

                AffineTransform at = new AffineTransform(
                        rotationMatrix.getValue(0,0),rotationMatrix.getValue(0,1),
                        rotationMatrix.getValue(1,0), rotationMatrix.getValue( 1, 1),
                        rotationMatrix.getValue(2,0),rotationMatrix.getValue(2,1)
                    );
                Shape clip = context.getGraphicsState().getCurrentClippingPath();
                // If the pdf is printed, sometimes a NPE occurs, see PDFBOX-552 for details
                // As a workaround we have to replace a possible null-value with a rectangle having
                // the same dimension than the page to be printed
View Full Code Here

        if (fontMatrix == null)
        {
            COSArray array = (COSArray) dict.getDictionaryObject(COSName.FONT_MATRIX);
            if (array != null)
            {
                fontMatrix = new Matrix(array);
            }
            else
            {
                return super.getFontMatrix();
            }
View Full Code Here

    @Override
    public Matrix getMatrix()
    {
        // todo: take into account user-space unit redefinition as scale?
        return new Matrix();
    }
View Full Code Here

        if (fontMatrix == null)
        {
            List<Number> numbers = cffFont.getFontMatrix();
            if (numbers != null && numbers.size() == 6)
            {
                fontMatrix = new Matrix(numbers.get(0).floatValue(), numbers.get(1).floatValue(),
                                        numbers.get(2).floatValue(), numbers.get(3).floatValue(),
                                        numbers.get(4).floatValue(), numbers.get(5).floatValue());
            }
            else
            {
View Full Code Here

            if (type1font != null)
            {
                List<Number> numbers = type1font.getFontMatrix();
                if (numbers != null && numbers.size() == 6)
                {
                    fontMatrix = new Matrix(
                            numbers.get(0).floatValue(), numbers.get(1).floatValue(),
                            numbers.get(2).floatValue(), numbers.get(3).floatValue(),
                            numbers.get(4).floatValue(), numbers.get(5).floatValue());
                }
                else
View Full Code Here

     * It maps the form space into the user space.
     * @return the form matrix
     */
    public Matrix getMatrix()
    {
        Matrix returnMatrix = null;
        if (matrix == null)
        {
            matrix = (COSArray)getCOSDictionary().getDictionaryObject( COSName.MATRIX );
        }
        if( matrix != null )
        {
            returnMatrix = new Matrix();
            returnMatrix.setValue(0, 0, ((COSNumber) matrix.get(0)).floatValue());
            returnMatrix.setValue(0, 1, ((COSNumber) matrix.get(1)).floatValue());
            returnMatrix.setValue(1, 0, ((COSNumber) matrix.get(2)).floatValue());
            returnMatrix.setValue(1, 1, ((COSNumber) matrix.get(3)).floatValue());
            returnMatrix.setValue(2, 0, ((COSNumber) matrix.get(4)).floatValue());
            returnMatrix.setValue(2, 1, ((COSNumber) matrix.get(5)).floatValue());
        }
        return returnMatrix;
    }
View Full Code Here

     * @return the form matrix
     */
    @Override
    public Matrix getMatrix()
    {
        Matrix matrix = null;
        COSArray array = (COSArray)getCOSDictionary().getDictionaryObject(COSName.MATRIX);
        if (array != null)
        {
            matrix = new Matrix();
            matrix.setValue(0, 0, ((COSNumber) array.get(0)).floatValue());
            matrix.setValue(0, 1, ((COSNumber) array.get(1)).floatValue());
            matrix.setValue(1, 0, ((COSNumber) array.get(2)).floatValue());
            matrix.setValue(1, 1, ((COSNumber) array.get(3)).floatValue());
            matrix.setValue(2, 0, ((COSNumber) array.get(4)).floatValue());
            matrix.setValue(2, 1, ((COSNumber) array.get(5)).floatValue());
        }
        else
        {
            // default value is the identity matrix
            matrix = new Matrix();
        }
        return matrix;
    }
View Full Code Here

     * @return the form matrix
     */
    @Override
    public Matrix getMatrix()
    {
        Matrix retval = null;
        COSArray array = (COSArray) getCOSStream().getDictionaryObject(COSName.MATRIX);
        if (array != null)
        {
            retval = new Matrix();
            retval.setValue(0, 0, ((COSNumber) array.get(0)).floatValue());
            retval.setValue(0, 1, ((COSNumber) array.get(1)).floatValue());
            retval.setValue(1, 0, ((COSNumber) array.get(2)).floatValue());
            retval.setValue(1, 1, ((COSNumber) array.get(3)).floatValue());
            retval.setValue(2, 0, ((COSNumber) array.get(4)).floatValue());
            retval.setValue(2, 1, ((COSNumber) array.get(5)).floatValue());
        }
        else
        {
            // default value is the identity matrix
            retval = new Matrix();
        }
        return retval;
    }
View Full Code Here

        }

        matrix = shading.getMatrix();
        if (matrix == null)
        {
            matrix = new Matrix();
        }

        try
        {
            // get inverse transform to be independent of
View Full Code Here

TOP

Related Classes of org.apache.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.