Package org.pdfbox.pdfparser

Examples of org.pdfbox.pdfparser.PDFParser


public Reader getText(InputStream is,TempFiles tempFiles) throws ExtractionException  {
     File file = null;
     PDDocument document = null;
     try {
       PDFParser parser = new PDFParser(is);
       parser.parse();
       document = parser.getPDDocument();
      
       if (document.isEncrypted()) {
           DocumentEncryption decryptor = new DocumentEncryption(document);
           if (logger.isDebugEnabled()) {
               logger.debug("pdf document appears to be encrypted (will attempt decryption)");
View Full Code Here


     *
     * @throws IOException If there is an error parsing the document.
     */
    private static COSDocument parseDocument( InputStream input )throws IOException
    {
        PDFParser parser = new PDFParser( input );
        parser.parse();
        return parser.getDocument();
    }
View Full Code Here

    }

    private static PDDocument getDocument( String filename ) throws IOException
    {
        FileInputStream input = null;
        PDFParser parser = null;
        PDDocument result = null;
        try
        {
            input = new FileInputStream( filename );
            parser = new PDFParser( input );
            parser.parse();
            result = parser.getPDDocument();
        }
        finally
        {
            if( input != null )
            {
View Full Code Here

        {
            String password = args[0];
            String infile = args[1];
            String outfile = args[2];

            PDFParser parser = null;

            try
            {
                parser = new PDFParser( new FileInputStream( infile ) );
                parser.parse();
                COSDocument document = parser.getDocument();

                if( document.isEncrypted() )
                {
                    DecryptDocument decryptor = new DecryptDocument( document );
                    decryptor.decryptDocument( password );

                    COSWriter writer = new COSWriter( new FileOutputStream( outfile ) );
                    writer.write( document );
                    writer.close();
                }
                else
                {
                    System.err.println( "Error: Document is not encrypted." );
                }
            }
            finally
            {
                if( parser != null && parser.getDocument() != null )
                {
                    parser.getDocument().close();
                }
            }
        }
    }
View Full Code Here

        PDDocument pdf = null;
        COSDocument fdf = null;
        FileInputStream pdfStream = null;
        FileInputStream fdfStream = null;
        FileOutputStream output = null;
        PDFParser pdfParser = null;
        PDFParser fdfParser = null;
        COSWriter writer = null;

        try
        {
            if( args.length != 3 )
            {
                usage();
            }
            else
            {
                ImportFDF importer = new ImportFDF();
                pdfStream = new FileInputStream( args[0] );
                fdfStream = new FileInputStream( args[1] );
                output = new FileOutputStream( args[2] );
                pdfParser = new PDFParser( pdfStream );
                fdfParser = new PDFParser( fdfStream );
                pdfParser.parse();
                fdfParser.parse();

                pdf = pdfParser.getPDDocument();
                fdf = fdfParser.getDocument();
                importer.importFDF( pdf, fdf );

                writer = new COSWriter( output );
                writer.write( pdf );
            }
View Full Code Here

                //first get the PDF document.
                try
                {
                    pdfStream = new FileInputStream( args[0] );
                    PDFParser pdfParser = new PDFParser( pdfStream );

                    pdfParser.parse();

                    pdf = pdfParser.getPDDocument();
                }
                finally
                {
                    close( pdfStream );
                }
View Full Code Here

    private static void addContent( Document document, InputStream is, String documentLocation ) throws IOException
    {
        PDDocument pdfDocument = null;
        try
        {
            PDFParser parser = new PDFParser( is );
            parser.parse();

            pdfDocument = parser.getPDDocument();


            if( pdfDocument.isEncrypted() )
            {
                DecryptDocument decryptor = new DecryptDocument( pdfDocument );
View Full Code Here

    @SuppressWarnings( "unused")
    private static final Logger LOG = Logger.getLogger(PDFHandler.class);
   
    private static COSDocument parseDocument( InputStream is) throws IOException
    {
        PDFParser parser = new PDFParser(is);
        parser.parse();
        return parser.getDocument();
    }
View Full Code Here

TOP

Related Classes of org.pdfbox.pdfparser.PDFParser

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.