Package org.apache.pdfbox.pdfviewer

Examples of org.apache.pdfbox.pdfviewer.PageDrawer


     * @param operator The operator that is being executed.
     * @param arguments List
     */
    public void process(PDFOperator operator, List<COSBase> arguments)
    {
        PageDrawer drawer = (PageDrawer)context;
        drawer.getLinePath().reset();
    }
View Full Code Here


     */
    public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
    {
        super.process(operator, arguments);
        float miterLimit = (float)context.getGraphicsState().getMiterLimit();
        PageDrawer drawer = (PageDrawer)context;
        BasicStroke stroke = (BasicStroke)drawer.getStroke();
        if (stroke == null)
        {
            drawer.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER,
                    miterLimit, null, 0.0f));
        }
        else
        {
            drawer.setStroke( new BasicStroke(stroke.getLineWidth(), stroke.getEndCap(), stroke.getLineJoin(),
                    miterLimit, null, 0.0f));
        }
    }
View Full Code Here

        BufferedImage retval = new BufferedImage( widthPx, heightPx, imageType );
        Graphics2D graphics = (Graphics2D)retval.getGraphics();
        graphics.setBackground( TRANSPARENT_WHITE );
        graphics.clearRect( 0, 0, retval.getWidth(), retval.getHeight() );
        graphics.scale( scaling, scaling );
        PageDrawer drawer = new PageDrawer();
        drawer.drawPage( graphics, this, pageDimension );

        //TODO This could be done directly by manipulating the transformation matrix before painting.
        //That could result in a better image quality.
        try
        {
View Full Code Here

    public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
        throws PrinterException
    {
        try
        {
            PageDrawer drawer = new PageDrawer();
            PDRectangle cropBox = findCropBox();
            drawer.drawPage( graphics, this, cropBox.createDimension() );
            return PAGE_EXISTS;
        }
        catch( IOException io )
        {
            throw new PrinterIOException( io );
View Full Code Here

     * @param operator The operator that is being executed.
     * @param arguments List
     */
    public void process(PDFOperator operator, List<COSBase> arguments)
    {
        PageDrawer drawer = (PageDrawer)context;

        COSNumber x2 = (COSNumber)arguments.get( 0 );
        COSNumber y2 = (COSNumber)arguments.get( 1 );
        COSNumber x3 = (COSNumber)arguments.get( 2 );
        COSNumber y3 = (COSNumber)arguments.get( 3 );
        GeneralPath path = drawer.getLinePath();
        Point2D currentPoint = path.getCurrentPoint();

        Point2D point2 = drawer.transformedPoint(x2.doubleValue(), y2.doubleValue());
        Point2D point3 = drawer.transformedPoint(x3.doubleValue(), y3.doubleValue());

        drawer.getLinePath().curveTo((float)currentPoint.getX(), (float)currentPoint.getY(),
                (float)point2.getX(), (float)point2.getY(), (float)point3.getX(), (float)point3.getY());
    }
View Full Code Here

    public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
    {

        try
        {
            PageDrawer drawer = (PageDrawer)context;
            drawer.setClippingPath(GeneralPath.WIND_EVEN_ODD);
        }
        catch (Exception e)
        {
            log.warn(e, e);
        }
View Full Code Here

     * @param arguments List
     * @throws IOException If there is an error invoking the sub object.
     */
    public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
    {
        PageDrawer drawer = (PageDrawer)context;
        PDPage page = drawer.getPage();
        COSName objectName = (COSName)arguments.get( 0 );
        Map xobjects = drawer.getResources().getXObjects();
        PDXObject xobject = (PDXObject)xobjects.get( objectName.getName() );
        if( xobject instanceof PDXObjectImage )
        {
            PDXObjectImage image = (PDXObjectImage)xobject;
            try
            {
                image.setGraphicsState(drawer.getGraphicsState());
                BufferedImage awtImage = image.getRGBImage();
                if (awtImage == null)
                {
                    log.warn("getRGBImage returned NULL");
                    return;//TODO PKOCH
                }
                int imageWidth = awtImage.getWidth();
                int imageHeight = awtImage.getHeight();
                double pageHeight = drawer.getPageSize().getHeight();

                log.debug("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 );
                // calculate the inverse rotation angle
                // scaleX = m00 = cos
                // shearX = m01 = -sin
                // tan = sin/cos
                double angle = Math.atan(ctmAT.getShearX()/ctmAT.getScaleX());
                Matrix translationMatrix = null;
                if (pageRotation == 0 || pageRotation == 180)
                {
                    translationMatrix = Matrix.getTranslatingInstance((float)(Math.sin(angle)*ctm.getXScale()), (float)(pageHeight-2*ctm.getYPosition()-Math.cos(angle)*ctm.getYScale()));
                }
                else if (pageRotation == 90 || pageRotation == 270)
                {
                    translationMatrix = Matrix.getTranslatingInstance((float)(Math.sin(angle)*ctm.getYScale()), (float)(pageHeight-2*ctm.getYPosition()));
                }
                rotationMatrix = rotationMatrix.multiply(translationMatrix);
                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)
                    );
              
                drawer.drawImage( awtImage, at );
            }
            catch( Exception e )
            {
                e.printStackTrace();
                log.error(e, e);
View Full Code Here

     */
    public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
    {
        try
        {
            PageDrawer drawer = (PageDrawer)context;
            drawer.SHFill((COSName)(arguments.get(0)));
           
        }
        catch (Exception e)
        {
            log.warn(e, e);
View Full Code Here

    {

        try
        {
            ///dwilson refactoring
            PageDrawer drawer = (PageDrawer)context;
            drawer.fillPath(GeneralPath.WIND_NON_ZERO);
        }
        catch (Exception e)
        {
            log.warn(e, e);
        }
View Full Code Here

     *
     * @throws IOException If an error occurs while processing the font.
     */
    public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
    {
        PageDrawer drawer = (PageDrawer)context;
        GeneralPath currentPath = (GeneralPath)drawer.getLinePath().clone();

        context.processOperator( "f", arguments );
        drawer.setLinePath( currentPath );

        context.processOperator( "S", arguments );
    }
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.pdfviewer.PageDrawer

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.