/** * Reads and parses a PDF document. * * @param is the {@code InputStream} containing the document. The stream is read to the * end but is not closed. * @param properties properties of the created reader * @throws IOException on error */ public PdfReader(InputStream is, ReaderProperties properties) throws IOException { this(new RandomAccessSourceFactory().createSource(is), properties); }
public OpenTypeParser(String ttcPath, int ttcIndex) throws java.io.IOException { this.ttcIndex = ttcIndex; raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createBestSource(ttcPath)); initializeSfntTables(); }
/** * Gets the document bytes that are hashable when using external signatures. * The general sequence is: * {@link #preClose(Map)}, {@link #getRangeStream()} and {@link #close(PdfDictionary)}. * * @return The {@link InputStream} of bytes to be signed. */ protected InputStream getRangeStream() throws IOException { RandomAccessSourceFactory fac = new RandomAccessSourceFactory(); return new RASInputStream(fac.createRanged(getUnderlyingSource(), range)); }
/** * Reads and parses a PDF document. * * @param filename the file name of the document * @param properties properties of the created reader * @throws IOException on error */ public PdfReader(String filename, ReaderProperties properties) throws IOException { this( new RandomAccessSourceFactory() .setForceRead(false) .createBestSource(filename), properties ); this.sourcePath = filename; }
/** * Creates a {@link IRandomAccessSource} based on a URL. The data available at the URL is read into memory and used * as the source for the {@link IRandomAccessSource} * @param url the url to read from * @return the newly created {@link IRandomAccessSource} */ public IRandomAccessSource createSource(URL url) throws java.io.IOException{ InputStream stream = url.openStream(); try { return createSource(stream); } finally { try { stream.close(); } catch(java.io.IOException ignored) { } } }
public RandomAccessFileOrArray getPostscriptBinary() throws java.io.IOException { if (pfbData != null) { return new RandomAccessFileOrArray(sourceFactory.createSource(pfbData)); } else if (pfbPath != null && pfbPath.toLowerCase().endsWith(".pfb")) { return new RandomAccessFileOrArray(sourceFactory.createBestSource(pfbPath)); } else { pfbPath = afmPath.substring(0, afmPath.length() - 3) + "pfb"; return new RandomAccessFileOrArray(sourceFactory.createBestSource(pfbPath)); } }
|| filename.startsWith("wsjar:") || filename.startsWith("vfszip:")) { return createSource(new URL(filename)); } else { return createByReadingToMemory(filename); return createByReadingToMemory(new FileInputStream(filename)); return createBestSource(raf.getChannel()); } catch (java.io.IOException e){ if (exceptionIsMapFailureException(e)) { return new RAFRandomAccessSource(raf);
/** * Creates a new {@link IRandomAccessSource} by reading the specified file/resource into memory * @param filename the name of the resource to read * @return the newly created {@link IRandomAccessSource} * @throws java.io.IOException if reading the underling file or stream fails */ private IRandomAccessSource createByReadingToMemory(String filename) throws java.io.IOException { InputStream stream = ResourceUtil.getResourceStream(filename); if (stream == null) { throw new java.io.IOException(MessageFormatUtil.format(IOException._1NotFoundAsFileOrResource, filename)); } return createByReadingToMemory(stream); }
/** * Creates a {@link IRandomAccessSource} based on a URL. The data available at the URL is read into memory and used * as the source for the {@link IRandomAccessSource} * @param url the url to read from * @return the newly created {@link IRandomAccessSource} */ public IRandomAccessSource createSource(URL url) throws java.io.IOException{ InputStream stream = url.openStream(); try { return createSource(stream); } finally { try { stream.close(); } catch(java.io.IOException ignored) { } } }
public RandomAccessFileOrArray getPostscriptBinary() throws java.io.IOException { if (pfbData != null) { return new RandomAccessFileOrArray(sourceFactory.createSource(pfbData)); } else if (pfbPath != null && pfbPath.toLowerCase().endsWith(".pfb")) { return new RandomAccessFileOrArray(sourceFactory.createBestSource(pfbPath)); } else { pfbPath = afmPath.substring(0, afmPath.length() - 3) + "pfb"; return new RandomAccessFileOrArray(sourceFactory.createBestSource(pfbPath)); } }
|| filename.startsWith("wsjar:") || filename.startsWith("vfszip:")) { return createSource(new URL(filename)); } else { return createByReadingToMemory(filename); return createByReadingToMemory(new FileInputStream(filename)); return createBestSource(raf.getChannel()); } catch (java.io.IOException e){ if (exceptionIsMapFailureException(e)) { return new RAFRandomAccessSource(raf);
/** * This method is invoked while deserialization */ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { in.defaultReadObject(); if (sourcePath != null && tokens == null) { tokens = getOffsetTokeniser(new RandomAccessSourceFactory().setForceRead(false).createBestSource(sourcePath)); } }
/** * Creates a new {@link IRandomAccessSource} by reading the specified file/resource into memory * @param filename the name of the resource to read * @return the newly created {@link IRandomAccessSource} * @throws java.io.IOException if reading the underling file or stream fails */ private IRandomAccessSource createByReadingToMemory(String filename) throws java.io.IOException { InputStream stream = ResourceUtil.getResourceStream(filename); if (stream == null) { throw new java.io.IOException(MessageFormatUtil.format(IOException._1NotFoundAsFileOrResource, filename)); } return createByReadingToMemory(stream); }
/** * Returns the underlying source. * * @return The underlying source * @throws IOException */ protected IRandomAccessSource getUnderlyingSource() throws IOException { RandomAccessSourceFactory fac = new RandomAccessSourceFactory(); return raf == null ? fac.createSource(bout) : fac.createSource(raf); }
public OpenTypeParser(String ttcPath, int ttcIndex) throws java.io.IOException { this.ttcIndex = ttcIndex; raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createBestSource(ttcPath)); initializeSfntTables(); }
/** * Creates a {@link IRandomAccessSource} based on an {@link InputStream}. The full content of the InputStream is read into memory and used * as the source for the {@link IRandomAccessSource} * @param inputStream the stream to read from * @return the newly created {@link IRandomAccessSource} */ public IRandomAccessSource createSource(InputStream inputStream) throws java.io.IOException{ return createSource(StreamUtil.inputStreamToArray(inputStream)); }
/** * Gets the document bytes that are hashable when using external signatures. * The general sequence is: * {@link #preClose(Map)}, {@link #getRangeStream()} and {@link #close(PdfDictionary)}. * * @return The {@link InputStream} of bytes to be signed. */ protected InputStream getRangeStream() throws IOException { RandomAccessSourceFactory fac = new RandomAccessSourceFactory(); return new RASInputStream(fac.createRanged(getUnderlyingSource(), range)); }
return new RandomAccessFileOrArray(sourceFactory.createSource(buf)); } else if (afmPath != null) { if (afmPath.toLowerCase().endsWith(".afm")) { return new RandomAccessFileOrArray(sourceFactory.createBestSource(afmPath)); } else if (afmPath.toLowerCase().endsWith(".pfm")) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); RandomAccessFileOrArray rf = new RandomAccessFileOrArray(sourceFactory.createBestSource(afmPath)); Pfm2afm.convert(rf, ba); rf.close(); return new RandomAccessFileOrArray(sourceFactory.createSource(ba.toByteArray())); } else { throw new IOException(IOException._1IsNotAnAfmOrPfmFontFile).setMessageParams(afmPath); RandomAccessFileOrArray rf = new RandomAccessFileOrArray(sourceFactory.createSource(afmData)); if (isAfmFile(rf)) { return rf; rf.close(); return new RandomAccessFileOrArray(sourceFactory.createSource(ba.toByteArray()));
/** * Returns the underlying source. * * @return The underlying source * @throws IOException */ protected IRandomAccessSource getUnderlyingSource() throws IOException { RandomAccessSourceFactory fac = new RandomAccessSourceFactory(); return raf == null ? fac.createSource(bout) : fac.createSource(raf); }
public OpenTypeParser(String name) throws java.io.IOException { String ttcName = getTTCName(name); this.fileName = ttcName; if (ttcName.length() < name.length()) { ttcIndex = Integer.parseInt(name.substring(ttcName.length() + 1)); } raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createBestSource(fileName)); initializeSfntTables(); }