public void close() throws IOException { file.close(); }
public void close() throws IOException { file.close(); }
/** * @param reader */ public void unRegisterReader(PdfReader reader) { if (!readers2intrefs.containsKey(reader)) return; readers2intrefs.remove(reader); RandomAccessFileOrArray raf = readers2file.get(reader); if (raf == null) return; readers2file.remove(reader); try { raf.close(); } catch (Exception e) { } }
/** * @param reader */ public void unRegisterReader(PdfReader reader) { if (!readers2intrefs.containsKey(reader)) return; readers2intrefs.remove(reader); RandomAccessFileOrArray raf = readers2file.get(reader); if (raf == null) return; readers2file.remove(reader); try { raf.close(); } catch (Exception e) { } }
public static void populateDescription(String path, byte[] contents, BaseFont font, FontDescription descr) throws IOException, NoSuchFieldException, IllegalAccessException, DocumentException { RandomAccessFileOrArray rf = null; try { rf = new RandomAccessFileOrArray(contents); rf = populateDescription0(path, font, descr, rf); } finally { if (rf != null) { try { rf.close(); } catch (IOException e) { // ignore } } } }
/** Gets the contents of the page. * @param pageNum the page number. 1 is the first * @throws IOException on error * @return the content */ public byte[] getPageContent(final int pageNum) throws IOException{ RandomAccessFileOrArray rf = getSafeFile(); try { rf.reOpen(); return getPageContent(pageNum, rf); } finally { try{rf.close();}catch(Exception e){} } }
/** Gets the contents of the page. * @param pageNum the page number. 1 is the first * @throws IOException on error * @return the content */ public byte[] getPageContent(final int pageNum) throws IOException{ RandomAccessFileOrArray rf = getSafeFile(); try { rf.reOpen(); return getPageContent(pageNum, rf); } finally { try{rf.close();}catch(Exception e){} } }
/** * Gets the global document JavaScript. * @throws IOException on error * @return the global document JavaScript */ public String getJavaScript() throws IOException { RandomAccessFileOrArray rf = getSafeFile(); try { rf.reOpen(); return getJavaScript(rf); } finally { try{rf.close();}catch(Exception e){} } }
/** * Gets the global document JavaScript. * @throws IOException on error * @return the global document JavaScript */ public String getJavaScript() throws IOException { RandomAccessFileOrArray rf = getSafeFile(); try { rf.reOpen(); return getJavaScript(rf); } finally { try{rf.close();}catch(Exception e){} } }
public static void populateDescription(String path, BaseFont font, FontDescription descr) throws IOException, NoSuchFieldException, IllegalAccessException, DocumentException { RandomAccessFileOrArray rf = null; try { rf = new RandomAccessFileOrArray(getTTCName(path)); rf = populateDescription0(path, font, descr, rf); } finally { if (rf != null) { try { rf.close(); } catch (IOException e) { // ignore } } } }
/** Get the content from a stream applying the required filters. * @param stream the stream * @throws IOException on error * @return the stream content */ public static byte[] getStreamBytes(final PRStream stream) throws IOException { RandomAccessFileOrArray rf = stream.getReader().getSafeFile(); try { rf.reOpen(); return getStreamBytes(stream, rf); } finally { try{rf.close();}catch(Exception e){} } }
/** Get the content from a stream applying the required filters. * @param stream the stream * @throws IOException on error * @return the stream content */ public static byte[] getStreamBytes(final PRStream stream) throws IOException { RandomAccessFileOrArray rf = stream.getReader().getSafeFile(); try { rf.reOpen(); return getStreamBytes(stream, rf); } finally { try{rf.close();}catch(Exception e){} } }
/** Get the content from a stream as it is without applying any filter. * @param stream the stream * @throws IOException on error * @return the stream content */ public static byte[] getStreamBytesRaw(final PRStream stream) throws IOException { RandomAccessFileOrArray rf = stream.getReader().getSafeFile(); try { rf.reOpen(); return getStreamBytesRaw(stream, rf); } finally { try{rf.close();}catch(Exception e){} } }
/** Get the content from a stream as it is without applying any filter. * @param stream the stream * @throws IOException on error * @return the stream content */ public static byte[] getStreamBytesRaw(final PRStream stream) throws IOException { RandomAccessFileOrArray rf = stream.getReader().getSafeFile(); try { rf.reOpen(); return getStreamBytesRaw(stream, rf); } finally { try{rf.close();}catch(Exception e){} } }
protected byte[] getFullFont() throws IOException { RandomAccessFileOrArray rf2 = null; try { rf2 = new RandomAccessFileOrArray(rf); rf2.reOpen(); byte b[] = new byte[(int) rf2.length()]; rf2.readFully(b); return b; } finally { try { if (rf2 != null) { rf2.close(); } } catch (Exception e) { } } }
protected byte[] getFullFont() throws IOException { RandomAccessFileOrArray rf2 = null; try { rf2 = new RandomAccessFileOrArray(rf); rf2.reOpen(); byte b[] = new byte[(int) rf2.length()]; rf2.readFully(b); return b; } finally { try { if (rf2 != null) { rf2.close(); } } catch (Exception e) { } } }
/** * If this font file is using the Compact Font File Format, then this method * will return the raw bytes needed for the font stream. If this method is * ever made public: make sure to add a test if (cff == true). * * @return a byte array * @since 2.1.3 */ protected byte[] readCffFont() throws IOException { RandomAccessFileOrArray rf2 = new RandomAccessFileOrArray(rf); byte b[] = new byte[cffLength]; try { rf2.reOpen(); rf2.seek(cffOffset); rf2.readFully(b); } finally { try { rf2.close(); } catch (Exception e) { // empty on purpose } } return b; }
/** Gets the XML metadata. * @throws IOException on error * @return the XML metadata */ public byte[] getMetadata() throws IOException { PdfObject obj = getPdfObject(catalog.get(PdfName.METADATA)); if (!(obj instanceof PRStream)) return null; RandomAccessFileOrArray rf = getSafeFile(); byte b[] = null; try { rf.reOpen(); b = getStreamBytes((PRStream)obj, rf); } finally { try { rf.close(); } catch (Exception e) { // empty on purpose } } return b; }
public void writeAllPages() throws IOException { try { file.reOpen(); for (Object element : importedPages.values()) { PdfImportedPage ip = (PdfImportedPage)element; if (ip.isToCopy()) { writer.addToBody(ip.getFormXObject(writer.getCompressionLevel()), ip.getIndirectReference()); ip.setCopied(); } } writeAllVisited(); } finally { try { // TODO: Removed - the user should be responsible for closing all PdfReaders. But, this could cause a lot of memory leaks in code out there that hasn't been properly closing things - maybe add a finalizer to PdfReader that calls PdfReader#close() ?? // reader.close(); file.close(); } catch (Exception e) { //Empty on purpose } } } }
public void writeAllPages() throws IOException { try { file.reOpen(); for (Object element : importedPages.values()) { PdfImportedPage ip = (PdfImportedPage)element; if (ip.isToCopy()) { writer.addToBody(ip.getFormXObject(writer.getCompressionLevel()), ip.getIndirectReference()); ip.setCopied(); } } writeAllVisited(); } finally { try { // TODO: Removed - the user should be responsible for closing all PdfReaders. But, this could cause a lot of memory leaks in code out there that hasn't been properly closing things - maybe add a finalizer to PdfReader that calls PdfReader#close() ?? // reader.close(); file.close(); } catch (Exception e) { //Empty on purpose } } } }