Examples of PDXObjectForm


Examples of org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm

        else if(xobject instanceof PDXObjectForm)
        {
            // save the graphics state
            context.getGraphicsStack().push( (PDGraphicsState)context.getGraphicsState().clone() );
           
            PDXObjectForm form = (PDXObjectForm)xobject;
            COSStream formContentstream = form.getCOSStream();
            // find some optional resources, instead of using the current resources
            PDResources pdResources = form.getResources();
            // if there is an optional form matrix, we have to map the form space to the user space
            Matrix matrix = form.getMatrix();
            if (matrix != null)
            {
                Matrix xobjectCTM = matrix.multiply( context.getGraphicsState().getCurrentTransformationMatrix());
                context.getGraphicsState().setCurrentTransformationMatrix(xobjectCTM);
            }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm

                    image.clear(); // PDFBOX-2101 get rid of cache ASAP
                }
                // maybe there are more images embedded in a form object
                else if (xobject instanceof PDXObjectForm)
                {
                    PDXObjectForm xObjectForm = (PDXObjectForm)xobject;
                    PDResources formResources = xObjectForm.getResources();
                    processResources(formResources, prefix, addKey, directJPEG);
                }
            }
        }
        resources.clear();
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm

        }
    }

    private String createOverlayXObject(PDPage page, LayoutPage layoutPage, COSStream contentStream)
    {
        PDXObjectForm xobjForm = new PDXObjectForm(contentStream);
        xobjForm.setResources(new PDResources(layoutPage.overlayResources));
        xobjForm.setFormType(1);
        xobjForm.setBBox(layoutPage.overlayMediaBox.createRetranslatedRectangle());
        xobjForm.setMatrix(new AffineTransform());
        PDResources resources = page.findResources();
        return resources.addXObject(xobjForm, XOBJECT_PREFIX);
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm

        else if(xobject instanceof PDXObjectForm)
        {
            // save the graphics state
            context.getGraphicsStack().push( (PDGraphicsState)context.getGraphicsState().clone() );
           
            PDXObjectForm form = (PDXObjectForm)xobject;
            COSStream formContentstream = form.getCOSStream();
            // find some optional resources, instead of using the current resources
            PDResources pdResources = form.getResources();
            // if there is an optional form matrix, we have to map the form space to the user space
            Matrix matrix = form.getMatrix();
            if (matrix != null)
            {
                Matrix xobjectCTM = matrix.multiply( context.getGraphicsState().getCurrentTransformationMatrix());
                context.getGraphicsState().setCurrentTransformationMatrix(xobjectCTM);
            }
            if (form.getBBox() != null)
            {
                PDGraphicsState graphicsState = context.getGraphicsState();
                PDRectangle bBox = form.getBBox();

                float x1 = bBox.getLowerLeftX();
                float y1 = bBox.getLowerLeftY();
                float x2 = bBox.getUpperRightX();
                float y2 = bBox.getUpperRightY();
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm

            ((PDFMarkedContentExtractor) this.context).xobject(xobject);
        }

        if(xobject instanceof PDXObjectForm)
        {
            PDXObjectForm form = (PDXObjectForm)xobject;
            COSStream invoke = (COSStream)form.getCOSObject();
            PDResources pdResources = form.getResources();
            PDPage page = context.getCurrentPage();
            if(pdResources == null)
            {
                pdResources = page.findResources();
            }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm

                log.error(e, e);
            }
        }
        else if(xobject instanceof PDXObjectForm)
        {
            PDXObjectForm form = (PDXObjectForm)xobject;
            COSStream invoke = (COSStream)form.getCOSObject();
            PDResources pdResources = form.getResources();
            if(pdResources == null)
            {
                pdResources = page.findResources();
            }
            // if there is an optional form matrix, we have to
            // map the form space to the user space
            Matrix matrix = form.getMatrix();
            if (matrix != null)
            {
                Matrix xobjectCTM = matrix.multiply( context.getGraphicsState().getCurrentTransformationMatrix());
                context.getGraphicsState().setCurrentTransformationMatrix(xobjectCTM);
            }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm

                    myrect.setLowerLeftY(550);

                    // Create a PDXObjectForm
                    PDStream formstream = new PDStream(document);
                    OutputStream os = formstream.createOutputStream();
                    PDXObjectForm form = new PDXObjectForm(formstream);
                    form.setResources(new PDResources());
                    form.setBBox(myrect);
                    form.setFormType(1);
                    // adjust the image to the target rectangle and add it to the stream
                    drawXObject(mypic, form.getResources(), os, 250, 550, 25, 25);
                    os.close();

                    PDAppearanceStream myDic = new PDAppearanceStream(form.getCOSStream());
                    PDAppearanceDictionary appearance = new PDAppearanceDictionary(new COSDictionary());
                    appearance.setNormalAppearance(myDic);
                    rubberStamp.setAppearance(appearance);
                    rubberStamp.setRectangle(myrect);
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm

    public PDXObjectForm importPageAsForm(PDDocument sourceDoc, PDPage page) throws IOException
    {
        COSStream pageStream = (COSStream)page.getContents().getCOSObject();
        PDStream newStream = new PDStream(targetDoc,
                pageStream.getUnfilteredStream(), false);
        PDXObjectForm form = new PDXObjectForm(newStream);

        //Copy resources
        PDResources pageRes = page.findResources();
        PDResources formRes = new PDResources();
        cloner.cloneMerge(pageRes, formRes);
        form.setResources(formRes);

        //Transfer some values from page to form
        transferDict(page.getCOSDictionary(), form.getCOSStream(), PAGE_TO_FORM_FILTER, true);

        Matrix matrix = form.getMatrix();
        AffineTransform at = matrix != null ? matrix.createAffineTransform() : new AffineTransform();
        PDRectangle mediaBox = page.findMediaBox();
        PDRectangle cropBox = page.findCropBox();
        PDRectangle viewBox = (cropBox != null ? cropBox : mediaBox);

        //Handle the /Rotation entry on the page dict
        int rotation = getNormalizedRotation(page);

        //Transform to FOP's user space
        //at.scale(1 / viewBox.getWidth(), 1 / viewBox.getHeight());
        at.translate(mediaBox.getLowerLeftX() - viewBox.getLowerLeftX(),
                mediaBox.getLowerLeftY() - viewBox.getLowerLeftY());
        switch (rotation)
        {
        case 90:
            at.scale(viewBox.getWidth() / viewBox.getHeight(), viewBox.getHeight() / viewBox.getWidth());
            at.translate(0, viewBox.getWidth());
            at.rotate(-Math.PI / 2.0);
            break;
        case 180:
            at.translate(viewBox.getWidth(), viewBox.getHeight());
            at.rotate(-Math.PI);
            break;
        case 270:
            at.scale(viewBox.getWidth() / viewBox.getHeight(), viewBox.getHeight() / viewBox.getWidth());
            at.translate(viewBox.getHeight(), 0);
            at.rotate(-Math.PI * 1.5);
        default:
            //no additional transformations necessary
        }
        //Compensate for Crop Boxes not starting at 0,0
        at.translate(-viewBox.getLowerLeftX(), -viewBox.getLowerLeftY());
        if (!at.isIdentity())
        {
            form.setMatrix(at);
        }

        BoundingBox bbox = new BoundingBox();
        bbox.setLowerLeftX(viewBox.getLowerLeftX());
        bbox.setLowerLeftY(viewBox.getLowerLeftY());
        bbox.setUpperRightX(viewBox.getUpperRightX());
        bbox.setUpperRightY(viewBox.getUpperRightY());
        form.setBBox(new PDRectangle(bbox));

        return form;
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm

    public PDXObjectForm getNormalIcon()
    {
        COSBase i = this.getDictionary().getDictionaryObject("I");
        if (i instanceof COSStream)
        {
            return new PDXObjectForm((COSStream) i);
        }
        return null;
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm

    public PDXObjectForm getRolloverIcon()
    {
        COSBase i = this.getDictionary().getDictionaryObject("RI");
        if (i instanceof COSStream)
        {
            return new PDXObjectForm((COSStream) i);
        }
        return null;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.