/** * This will load a document from a file. * * @param filename The name of the file to load. * * @return The document that was loaded. * * @throws IOException If there is an error reading from the stream. */ public static FDFDocument load(String filename) throws IOException { FDFParser parser = new FDFParser(filename); parser.parse(); return new FDFDocument(parser.getDocument()); }
/** * Constructs parser for given file using given buffer for temporary * storage. * * @param file the pdf to be parsed * * @throws IOException If something went wrong. */ public FDFParser(File file) throws IOException { super(new RandomAccessFile(file, "r")); fileLen = file.length(); init(); }
/** * This will parse the stream and populate the COSDocument object. * * @throws IOException If there is an error reading from the stream or corrupt data * is found. */ public void parse() throws IOException { // set to false if all is processed boolean exceptionOccurred = true; try { if (!parseFDFHeader()) { throw new IOException( "Error: Header doesn't contain versioninfo" ); } initialParse(); exceptionOccurred = false; } finally { if (exceptionOccurred && document != null) { IOUtils.closeQuietly(document); document = null; } } } }
/** * The initial parse will first parse only the trailer, the xrefstart and all xref tables to have a pointer (offset) * to all the pdf's objects. It can handle linearized pdfs, which will have an xref at the end pointing to an xref * at the beginning of the file. Last the root object is parsed. * * @throws IOException If something went wrong. */ private void initialParse() throws IOException { COSDictionary trailer = retrieveTrailer(); COSBase rootObject = parseTrailerValuesDynamically(trailer); // resolve all objects // A FDF doesn't have a catalog, all FDF fields are within the root object if (rootObject instanceof COSDictionary) { parseDictObjects((COSDictionary) rootObject, (COSName[]) null); } initialParseDone = true; }
long startXRefOffset = getStartxrefOffset(); if (startXRefOffset > 0) trailer = parseXref(startXRefOffset); else if (isLenient()) if (isLenient()) trailer = rebuildTrailer(); COSBase rootObject = parseTrailerValuesDynamically(trailer); parseDictObjects((COSDictionary) rootObject, (COSName[]) null);
private void init() throws IOException { String eofLookupRangeStr = System.getProperty(SYSPROP_EOFLOOKUPRANGE); if (eofLookupRangeStr != null) { try { setEOFLookupRange(Integer.parseInt(eofLookupRangeStr)); } catch (NumberFormatException nfe) { LOG.warn("System property " + SYSPROP_EOFLOOKUPRANGE + " does not contain an integer value, but: '" + eofLookupRangeStr + "'"); } } document = new COSDocument(); }
/** * The initial parse will first parse only the trailer, the xrefstart and all xref tables to have a pointer (offset) * to all the pdf's objects. It can handle linearized pdfs, which will have an xref at the end pointing to an xref * at the beginning of the file. Last the root object is parsed. * * @throws IOException If something went wrong. */ private void initialParse() throws IOException { COSDictionary trailer = retrieveTrailer(); COSBase rootObject = parseTrailerValuesDynamically(trailer); // resolve all objects // A FDF doesn't have a catalog, all FDF fields are within the root object if (rootObject instanceof COSDictionary) { parseDictObjects((COSDictionary) rootObject, (COSName[]) null); } initialParseDone = true; }
private void init() throws IOException { String eofLookupRangeStr = System.getProperty(SYSPROP_EOFLOOKUPRANGE); if (eofLookupRangeStr != null) { try { setEOFLookupRange(Integer.parseInt(eofLookupRangeStr)); } catch (NumberFormatException nfe) { LOG.warn("System property " + SYSPROP_EOFLOOKUPRANGE + " does not contain an integer value, but: '" + eofLookupRangeStr + "'"); } } document = new COSDocument(); }
/** * This will load a document from a file. * * @param file The name of the file to load. * * @return The document that was loaded. * * @throws IOException If there is an error reading from the stream. */ public static FDFDocument load(File file) throws IOException { FDFParser parser = new FDFParser(file); parser.parse(); return new FDFDocument(parser.getDocument()); }
/** * This will parse the stream and populate the COSDocument object. * * @throws IOException If there is an error reading from the stream or corrupt data * is found. */ public void parse() throws IOException { // set to false if all is processed boolean exceptionOccurred = true; try { if (!parseFDFHeader()) { throw new IOException( "Error: Header doesn't contain versioninfo" ); } initialParse(); exceptionOccurred = false; } finally { if (exceptionOccurred && document != null) { IOUtils.closeQuietly(document); document = null; } } } }
/** * Constructor. * * @param input input stream representing the pdf. * @throws IOException If something went wrong. */ public FDFParser(InputStream input) throws IOException { super(new RandomAccessBuffer(input)); fileLen = source.length(); init(); }
private void init() throws IOException { String eofLookupRangeStr = System.getProperty(SYSPROP_EOFLOOKUPRANGE); if (eofLookupRangeStr != null) { try { setEOFLookupRange(Integer.parseInt(eofLookupRangeStr)); } catch (NumberFormatException nfe) { LOG.warn("System property " + SYSPROP_EOFLOOKUPRANGE + " does not contain an integer value, but: '" + eofLookupRangeStr + "'"); } } document = new COSDocument(); }
/** * This will load a document from an input stream. * * @param input The stream that contains the document. * * @return The document that was loaded. * * @throws IOException If there is an error reading from the stream. */ public static FDFDocument load(InputStream input) throws IOException { FDFParser parser = new FDFParser(input); parser.parse(); return new FDFDocument(parser.getDocument()); }
/** * This will parse the stream and populate the COSDocument object. * * @throws IOException If there is an error reading from the stream or corrupt data * is found. */ public void parse() throws IOException { // set to false if all is processed boolean exceptionOccurred = true; try { if (!parseFDFHeader()) { throw new IOException( "Error: Header doesn't contain versioninfo" ); } initialParse(); exceptionOccurred = false; } finally { if (exceptionOccurred && document != null) { IOUtils.closeQuietly(document); document = null; } } } }
/** * Constructs parser for given file using given buffer for temporary * storage. * * @param file the pdf to be parsed * * @throws IOException If something went wrong. */ public FDFParser(File file) throws IOException { super(new RandomAccessFile(file, "r")); fileLen = file.length(); init(); }
/** * This will load a document from a file. * * @param file The name of the file to load. * * @return The document that was loaded. * * @throws IOException If there is an error reading from the stream. */ public static FDFDocument load(File file) throws IOException { FDFParser parser = new FDFParser(file); parser.parse(); return new FDFDocument(parser.getDocument()); }
/** * Constructs parser for given file using given buffer for temporary * storage. * * @param file the pdf to be parsed * * @throws IOException If something went wrong. */ public FDFParser(File file) throws IOException { super(new RandomAccessFile(file, "r")); fileLen = file.length(); init(); }
/** * This will load a document from an input stream. * * @param input The stream that contains the document. * * @return The document that was loaded. * * @throws IOException If there is an error reading from the stream. */ public static FDFDocument load(InputStream input) throws IOException { FDFParser parser = new FDFParser(input); parser.parse(); return new FDFDocument(parser.getDocument()); }
/** * Constructor. * * @param input input stream representing the pdf. * @throws IOException If something went wrong. */ public FDFParser(InputStream input) throws IOException { super(new RandomAccessBuffer(input)); fileLen = source.length(); init(); }
/** * This will load a document from a file. * * @param filename The name of the file to load. * * @return The document that was loaded. * * @throws IOException If there is an error reading from the stream. */ public static FDFDocument load(String filename) throws IOException { FDFParser parser = new FDFParser(filename); parser.parse(); return new FDFDocument(parser.getDocument()); }