Examples of PDResources


Examples of org.apache.pdfbox.pdmodel.PDResources

        {
            throw new IllegalStateException("No current page, call " +
                    "#processChildStream(PDContentStream, PDPage) instead");
        }

        PDResources parent = pushResources(charProc);
        saveGraphicsState();

        // replace the CTM with the TRM
        getGraphicsState().setCurrentTransformationMatrix(textRenderingMatrix);
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDResources

     * @param appearance The appearance stream to process.
     */
    protected void processAnnotation(PDAnnotation annotation, PDAppearanceStream appearance)
            throws IOException
    {
        PDResources parent = pushResources(appearance);
        saveGraphicsState();

        PDRectangle bbox = appearance.getBBox();
        PDRectangle rect = annotation.getRectangle();
        Matrix matrix = appearance.getMatrix();
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDResources

     *
     * @param tilingPattern tiling patten
     */
    protected final void processTilingPattern(PDTilingPattern tilingPattern) throws IOException
    {
        PDResources parent = pushResources(tilingPattern);
        saveGraphicsState();

        // note: we don't transform the CTM using the stream's matrix, as TilingPaint handles this

        // clip to bounding box
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDResources

     * @throws IOException if there is an exception while processing the stream
     */
    private void processStream(PDContentStream contentStream, PDRectangle patternBBox)
            throws IOException
    {
        PDResources parent = pushResources(contentStream);
        saveGraphicsState();

        // transform the CTM using the stream's matrix
        getGraphicsState().getCurrentTransformationMatrix().concatenate(contentStream.getMatrix());

View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDResources

     * Pushes the given stream's resources, returning the previous resources.
     */
    private PDResources pushResources(PDContentStream contentStream)
    {
        // resource lookup: first look for stream resources, then fallback to the current page
        PDResources parentResources = resources;
        PDResources streamResources = contentStream.getResources();
        if (streamResources != null)
        {
            resources = streamResources;
        }
        else
        {
            resources = currentPage.getResources();
        }

        // resources are required in PDF
        if (resources == null)
        {
            resources = new PDResources();
        }
        return parentResources;
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDResources

        try
        {
            //Create new page
            PDPage page = new PDPage();
            doc.addPage(page);
            PDResources resources = page.getResources();
            if( resources == null )
            {
                resources = new PDResources();
                page.setResources( resources );
            }

            final String[] text = new String[] {
                    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer fermentum lacus in eros",
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDResources

        try
        {
            //Create new page
            PDPage page = new PDPage();
            doc.addPage(page);
            PDResources resources = page.getResources();
            if( resources == null )
            {
                resources = new PDResources();
                page.setResources( resources );
            }

            //Setup page content stream and paint background/title
            PDPageContentStream contentStream = new PDPageContentStream(doc, page, false, false);
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDResources

            catalog.setVersion("1.5");

            //Create new page
            PDPage page = new PDPage();
            doc.addPage(page);
            PDResources resources = page.getResources();
            if( resources == null )
            {
                resources = new PDResources();
                page.setResources( resources );
            }

            //Prepare OCG functionality
            PDOptionalContentProperties ocprops = new PDOptionalContentProperties();
            catalog.setOCProperties(ocprops);
            //ocprops.setBaseState(BaseState.ON); //ON=default

            //Create OCG for background
            PDOptionalContentGroup background = new PDOptionalContentGroup("background");
            ocprops.addGroup(background);
            assertTrue(ocprops.isGroupEnabled("background"));

            //Create OCG for enabled
            PDOptionalContentGroup enabled = new PDOptionalContentGroup("enabled");
            ocprops.addGroup(enabled);
            assertFalse(ocprops.setGroupEnabled("enabled", true));
            assertTrue(ocprops.isGroupEnabled("enabled"));

            //Create OCG for disabled
            PDOptionalContentGroup disabled = new PDOptionalContentGroup("disabled");
            ocprops.addGroup(disabled);
            assertFalse(ocprops.setGroupEnabled("disabled", true));
            assertTrue(ocprops.isGroupEnabled("disabled"));
            assertTrue(ocprops.setGroupEnabled("disabled", false));
            assertFalse(ocprops.isGroupEnabled("disabled"));

            //Add property lists to page resources
            COSName mc0 = COSName.getPDFName("MC0");
            COSName mc1 = COSName.getPDFName("MC1");
            COSName mc2 = COSName.getPDFName("MC2");
            resources.put(mc0, background);
            resources.put(mc1, enabled);
            resources.put(mc2, disabled);

            //Setup page content stream and paint background/title
            PDPageContentStream contentStream = new PDPageContentStream(doc, page, false, false);
            PDFont font = PDType1Font.HELVETICA_BOLD;
            contentStream.beginMarkedContentSequence(COSName.OC, mc0);
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDResources

    private LayoutPage getLayoutPage(PDDocument doc) throws IOException
    {
        PDDocumentCatalog catalog = doc.getDocumentCatalog();
        PDPage page = (PDPage)catalog.getAllPages().get(0);
        COSBase contents = page.getCOSDictionary().getDictionaryObject(COSName.CONTENTS);
        PDResources resources = page.findResources();
        if (resources == null)
        {
            resources = new PDResources();
        }
        return new LayoutPage(page.getMediaBox(), createContentStream(contents), resources.getCOSDictionary());
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDResources

        {
            layoutPage = defaultOverlayPage;
        }
        if (layoutPage != null)
        {
            PDResources resources = page.findResources();
            if (resources == null)
            {
                resources = new PDResources();
                page.setResources(resources);
            }
            String xObjectId = createOverlayXObject(page, layoutPage, layoutPage.overlayContentStream);
            array.add(createOverlayStream(page, layoutPage, xObjectId));
        }
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.