/** * 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 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(); }
public OpenTypeParser(byte[] ttc, int ttcIndex) throws java.io.IOException { this.ttcIndex = ttcIndex; raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(ttc)); initializeSfntTables(); }
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(); }
public OpenTypeParser(String ttcPath, int ttcIndex) throws java.io.IOException { this.ttcIndex = ttcIndex; raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createBestSource(ttcPath)); initializeSfntTables(); }
/** * Creates a new {@link TrueTypeCollection} instance by its bytes. * * @param ttc the byte contents of the collection * @throws java.io.IOException in case the input in mal-formatted */ public TrueTypeCollection(byte[] ttc) throws java.io.IOException { raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(ttc)); this.ttc = ttc; initFontSize(); }
public OpenTypeParser(String ttcPath, int ttcIndex) throws java.io.IOException { this.ttcIndex = ttcIndex; raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createBestSource(ttcPath)); initializeSfntTables(); }
public OpenTypeParser(byte[] ttf) throws java.io.IOException { raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(ttf)); initializeSfntTables(); }
/** * Creates a new {@link TrueTypeCollection} instance by its bytes. * * @param ttc the byte contents of the collection * @throws java.io.IOException in case the input in mal-formatted */ public TrueTypeCollection(byte[] ttc) throws java.io.IOException { raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(ttc)); this.ttc = ttc; initFontSize(); }
/** * 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); }
/** * 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)); } }
/** * Load data from URL. url must be not null. * Note, this method doesn't check if data or url is null. * @throws java.io.IOException */ void loadData() throws java.io.IOException { RandomAccessFileOrArray raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(url)); ByteArrayOutputStream stream = new ByteArrayOutputStream(); StreamUtil.transferBytes(raf, stream); raf.close(); data = stream.toByteArray(); }
/** * 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)); }
/** Gets the number of pages the TIFF document has. * @param bytes a byte array containing a TIFF image. * @return the number of pages. */ public static int getNumberOfPages(byte[] bytes) { IRandomAccessSource ras = new RandomAccessSourceFactory().createSource(bytes); return getNumberOfPages(new RandomAccessFileOrArray(ras)); }
/** * Gets the number of pages in a JBIG2 image. * @param bytes a byte array containing a JBIG2 image * @return the number of pages */ public static int getNumberOfPages(byte[] bytes) { IRandomAccessSource ras = new RandomAccessSourceFactory().createSource(bytes); return getNumberOfPages(new RandomAccessFileOrArray(ras)); }
/** Gets the number of pages the TIFF document has. * @param bytes a byte array containing a TIFF image. * @return the number of pages. */ public static int getNumberOfPages(byte[] bytes) { IRandomAccessSource ras = new RandomAccessSourceFactory().createSource(bytes); return getNumberOfPages(new RandomAccessFileOrArray(ras)); }
/** * 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)); }
/** * Creates a new {@link TrueTypeCollection} instance by its file path. * * @param ttcPath the path of the collection * @throws java.io.IOException in case the input in mal-formatted */ public TrueTypeCollection(String ttcPath) throws java.io.IOException { if (!FileUtil.fileExists(ttcPath)) { throw new IOException(IOException.FontFile1NotFound).setMessageParams(ttcPath); } raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createBestSource(ttcPath)); this.ttcPath = ttcPath; initFontSize(); }
static byte[] readFontBytesFromPath(String path) throws java.io.IOException { RandomAccessFileOrArray raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createBestSource(path)); int bufLen = (int) raf.length(); if (bufLen < raf.length()) { throw new IOException(MessageFormatUtil.format("Source data from \"{0}\" is bigger than byte array can hold.", path)); } byte[] buf = new byte[bufLen]; raf.readFully(buf); return buf; } }
static byte[] readFontBytesFromPath(String path) throws java.io.IOException { RandomAccessFileOrArray raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createBestSource(path)); int bufLen = (int) raf.length(); if (bufLen < raf.length()) { throw new IOException(MessageFormatUtil.format("Source data from \"{0}\" is bigger than byte array can hold.", path)); } byte[] buf = new byte[bufLen]; raf.readFully(buf); return buf; } }