Examples of PDDocumentCatalog


Examples of org.apache.pdfbox.pdmodel.PDDocumentCatalog

            contentStream.drawString( message );
            contentStream.endText();
            contentStream.saveGraphicsState();
            contentStream.close();
           
            PDDocumentCatalog cat = doc.getDocumentCatalog();
            PDMetadata metadata = new PDMetadata(doc);
            cat.setMetadata(metadata);

            XMPMetadata xmp = XMPMetadata.createXMPMetadata();
            try
            {
                PDFAIdentificationSchema pdfaid = xmp.createAndAddPFAIdentificationSchema();
                pdfaid.setConformance("B");
                pdfaid.setPart(1);
                pdfaid.setAboutAsSimple("PDFBox PDFA sample");
                XmpSerializer serializer = new XmpSerializer();
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                serializer.serialize(xmp, baos, false);
                metadata.importXMPMetadata( baos.toByteArray() );
            }
            catch(BadFieldValueException badFieldexception)
            {
                // can't happen here, as the provided value is valid
            }
            catch(XmpSerializationException xmpException)
            {
                System.err.println(xmpException.getMessage());
            }
            InputStream colorProfile = CreatePDFA.class.getResourceAsStream("/org/apache/pdfbox/resources/pdfa/sRGB Color Space Profile.icm");
            // create output intent
            PDOutputIntent oi = new PDOutputIntent(doc, colorProfile);
            oi.setInfo("sRGB IEC61966-2.1");
            oi.setOutputCondition("sRGB IEC61966-2.1");
            oi.setOutputConditionIdentifier("sRGB IEC61966-2.1");
            oi.setRegistryName("http://www.color.org");
            cat.addOutputIntent(oi);
           
            doc.save( file );
          
        }
        finally
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDDocumentCatalog

        PDDocument doc = new PDDocument();
        try
        {
            //OCGs have been introduced with PDF 1.5
            doc.getDocument().setHeaderString("%PDF-1.5");
            PDDocumentCatalog catalog = doc.getDocumentCatalog();
            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);
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDDocumentCatalog

        PDDocument doc = PDDocument.load(pdfFile);
        try
        {
            assertEquals("%PDF-1.5", doc.getDocument().getHeaderString());
            PDDocumentCatalog catalog = doc.getDocumentCatalog();
            assertEquals("1.5", catalog.getVersion());

            PDPage page = doc.getPage(0);
            PDOptionalContentGroup ocg = (PDOptionalContentGroup)page.getResources()
                    .getProperties(COSName.getPDFName("MC0"));
            assertNotNull(ocg);
            assertEquals("background", ocg.getName());

            assertNull(page.getResources().getProperties(COSName.getPDFName("inexistent")));

            PDOptionalContentProperties ocgs = catalog.getOCProperties();
            assertEquals(BaseState.ON, ocgs.getBaseState());
            Set<String> names = new java.util.HashSet<String>(Arrays.asList(ocgs.getGroupNames()));
            assertEquals(3, names.size());
            assertTrue(names.contains("background"));
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDDocumentCatalog

        try
        {
            PDDocument doc = PDDocument.load(TestEmbeddedFiles.class.getResourceAsStream(
                "null_PDComplexFileSpecification.pdf"));

            PDDocumentCatalog catalog = doc.getDocumentCatalog();
            PDDocumentNameDictionary names = catalog.getNames();
            assertEquals("expected two files", 2, names.getEmbeddedFiles().getNames().size());
            PDEmbeddedFilesNameTreeNode embeddedFiles = names.getEmbeddedFiles();

            PDComplexFileSpecification spec = (PDComplexFileSpecification)
                                            embeddedFiles.getNames().get("non-existent-file.docx");
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDDocumentCatalog

public class PageTreeValidationProcess extends AbstractProcess
{

    public void validate(PreflightContext context) throws ValidationException
    {
        PDDocumentCatalog catalog = context.getDocument().getDocumentCatalog();
        if (catalog != null)
        {
            int numPages = context.getDocument().getNumberOfPages();
            for (int i = 0; i < numPages; i++)
            {
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDDocumentCatalog

                    doc = PDDocument.load(e.getValue());
                }
                specificPageOverlay.put(e.getKey(), doc);
                specificPageOverlayPage.put(e.getKey(), getLayoutPage(doc));
            }
            PDDocumentCatalog pdfCatalog = sourcePDFDocument.getDocumentCatalog();
            processPages(pdfCatalog.getAllPages());

            sourcePDFDocument.save(outputFile);
        }
        finally
        {
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDDocumentCatalog

        }
    }

    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();
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDDocumentCatalog

               
                // Extract text for main document:
                stripper.writeText( document, output );
               
                // ... also for any embedded PDFs:
                PDDocumentCatalog catalog = document.getDocumentCatalog();
                PDDocumentNameDictionary names = catalog.getNames();   
                if (names != null)
                {
                    PDEmbeddedFilesNameTreeNode embeddedFiles = names.getEmbeddedFiles();
                    if (embeddedFiles != null)
                    {
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDDocumentCatalog

     *             if an IOException occurs during the DestOutputProfile parsing
     */
    private static ICCProfileWrapper searchFirstICCProfile(PreflightContext context) throws ValidationException
    {
        PreflightDocument document = context.getDocument();
        PDDocumentCatalog catalog = document.getDocumentCatalog();
        COSBase cBase = catalog.getCOSDictionary().getItem(COSName.getPDFName(DOCUMENT_DICTIONARY_KEY_OUTPUT_INTENTS));
        COSArray outputIntents = COSUtils.getAsArray(cBase, document.getDocument());

        for (int i = 0; outputIntents != null && i < outputIntents.size(); ++i)
        {
            COSDictionary outputIntentDict = COSUtils.getAsDictionary(outputIntents.get(i), document.getDocument());
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.PDDocumentCatalog

public class BookmarkValidationProcess extends AbstractProcess
{

    public void validate(PreflightContext ctx) throws ValidationException
    {
        PDDocumentCatalog catalog = ctx.getDocument().getDocumentCatalog();
        if (catalog != null)
        {
            PDDocumentOutline outlineHierarchy = catalog.getDocumentOutline();
            if (outlineHierarchy != null)
            {
                // Count entry is mandatory if there are childrens
                if (!isCountEntryPresent(outlineHierarchy.getCOSDictionary())
                        && (outlineHierarchy.getFirstChild() != null || outlineHierarchy.getLastChild() != 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.