Examples of PDComplexFileSpecification


Examples of org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification

                            {
                                if (debug)
                                {
                                    System.err.println("Processing embedded file " + ent.getKey() + ":");
                                }
                                PDComplexFileSpecification spec = (PDComplexFileSpecification) ent.getValue();
                                PDEmbeddedFile file = spec.getEmbeddedFile();
                                if (file != null && file.getSubtype().equals("application/pdf"))
                                {
                                    if (debug)
                                    {
                                        System.err.println("  is PDF (size=" + file.getSize() + ")");
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification

            //embedded files are stored in a named tree
            PDEmbeddedFilesNameTreeNode efTree = new PDEmbeddedFilesNameTreeNode();


            //first create the file specification, which holds the embedded file
            PDComplexFileSpecification fs = new PDComplexFileSpecification();
            fs.setFile( "Test.txt" );
            //create a dummy file stream, this would probably normally be a FileInputStream
            byte[] data = "This is the contents of the embedded file".getBytes();
            ByteArrayInputStream fakeFile =
                new ByteArrayInputStream( data );
            PDEmbeddedFile ef = new PDEmbeddedFile(doc, fakeFile );
            //now lets some of the optional parameters
            ef.setSubtype( "test/plain" );
            ef.setSize( data.length );
            ef.setCreationDate( new GregorianCalendar() );
            fs.setEmbeddedFile( ef );

            //now add the entry to the embedded file tree and set in the document.
            efTree.setNames( Collections.singletonMap( "My first attachment",  fs ) );
            PDDocumentNameDictionary names = new PDDocumentNameDictionary( doc.getDocumentCatalog() );
            names.setEmbeddedFiles( efTree );
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification

            //embedded files are stored in a named tree
            PDEmbeddedFilesNameTreeNode efTree = new PDEmbeddedFilesNameTreeNode();


            //first create the file specification, which holds the embedded file
            PDComplexFileSpecification fs = new PDComplexFileSpecification();
            fs.setFile( "Test.txt" );
            //create a dummy file stream, this would probably normally be a FileInputStream
            byte[] data = "This is the contents of the embedded file".getBytes();
            ByteArrayInputStream fakeFile =
                new ByteArrayInputStream( data );
            PDEmbeddedFile ef = new PDEmbeddedFile(doc, fakeFile );
            //now lets some of the optional parameters
            ef.setSubtype( "test/plain" );
            ef.setSize( data.length );
            ef.setCreationDate( new GregorianCalendar() );
            fs.setEmbeddedFile( ef );

            //now add the entry to the embedded file tree and set in the document.
            Map efMap = new HashMap();
            efMap.put( "My first attachment", fs );
            efTree.setNames( efMap );
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification

     * {@inheritDoc}
     */
    protected Object convertCOSToPD( COSBase base ) throws IOException
    {
        COSBase destination = base;
        return new PDComplexFileSpecification( (COSDictionary)destination );
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification

            return;
        }

        EmbeddedDocumentExtractor extractor = getEmbeddedDocumentExtractor();
        for (Map.Entry<String,COSObjectable> ent : embeddedFileNames.entrySet()) {
            PDComplexFileSpecification spec = (PDComplexFileSpecification) ent.getValue();
            if (spec == null) {
                //skip silently
                continue;
            }
            PDEmbeddedFile file = spec.getEmbeddedFile();
            if (file == null) {
                //skip silently
                continue;
            }

            //current strategy is to pull all, not just first non-null               
            extractPDEmbeddedFile(ent.getKey(), spec.getFile(), spec.getEmbeddedFile(), extractor);
            extractPDEmbeddedFile(ent.getKey(), spec.getFileMac(), spec.getEmbeddedFileMac(), extractor);
            extractPDEmbeddedFile(ent.getKey(), spec.getFileDos(), spec.getEmbeddedFileDos(), extractor);
            extractPDEmbeddedFile(ent.getKey(), spec.getFileUnix(), spec.getEmbeddedFileUnix(), extractor);

        }
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification

                Map<String, COSObjectable> embeddedFileNames = embeddedFiles.getNames();

                if (embeddedFileNames != null) {
                    for (Map.Entry<String,COSObjectable> ent : embeddedFileNames.entrySet()) {
                        PDComplexFileSpecification spec = (PDComplexFileSpecification) ent.getValue();
                        PDEmbeddedFile file = spec.getEmbeddedFile();

                        Metadata metadata = new Metadata();
                        // TODO: other metadata?
                        metadata.set(Metadata.RESOURCE_NAME_KEY, ent.getKey());
                        metadata.set(Metadata.CONTENT_TYPE, file.getSubtype());
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification

                try {
                    Map<String, Object> names_file = ef.getNames();
                    if (names_file != null) {
                        for (Object o : names_file.values()) {
                            if (o instanceof PDComplexFileSpecification) {
                                PDComplexFileSpecification a = (PDComplexFileSpecification) o;
                                PDEmbeddedFile f = a.getEmbeddedFile();
                                if (f != null) {
                                    String subtype = f.getSubtype();
                                    log.info("found file of type " + subtype + ": " + a.getFile());
                                    result.add(new String[]{subtype, decodeStream(f.getStream())});
                                }
                            }
                        }
                    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification

            EmbeddedDocumentExtractor extractor = getEmbeddedDocumentExtractor();
            for (PDAnnotation annotation : page.getAnnotations()) {

                if (annotation instanceof PDAnnotationFileAttachment){
                    PDAnnotationFileAttachment fann = (PDAnnotationFileAttachment) annotation;
                    PDComplexFileSpecification fileSpec = (PDComplexFileSpecification) fann.getFile();
                    try {
                        extractMultiOSPDEmbeddedFiles("", fileSpec, extractor);
                    } catch (SAXException e) {
                        throw new IOExceptionWithCause("file embedded in annotation sax exception", e);
                    } catch (TikaException e) {
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification

            return;
        }

        EmbeddedDocumentExtractor extractor = getEmbeddedDocumentExtractor();
        for (Map.Entry<String,COSObjectable> ent : embeddedFileNames.entrySet()) {
            PDComplexFileSpecification spec = (PDComplexFileSpecification) ent.getValue();
            extractMultiOSPDEmbeddedFiles(ent.getKey(), spec, extractor);
        }
    }
View Full Code Here

Examples of org.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification

     * {@inheritDoc}
     */
    protected Object convertCOSToPD( COSBase base ) throws IOException
    {
        COSBase destination = base;
        return new PDComplexFileSpecification( (COSDictionary)destination );
    }
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.