public PdfObjectStream(PdfDocument doc) { this(doc, new ByteArrayOutputStream()); indexStream = new PdfOutputStream(new ByteArrayOutputStream()); }
/** * This method is called when another split document is to be created. * You can override this method and return your own {@link PdfWriter} depending on your needs. * * @param documentPageRange the page range of the original document to be included in the document being created now. * @return the PdfWriter instance for the document which is being created. */ protected PdfWriter getNextPdfWriter(PageRange documentPageRange) { return new PdfWriter(new ByteArrayOutputStream()); }
private PdfWriter setDebugMode() { duplicateStream = new PdfOutputStream(new ByteArrayOutputStream()); return this; }
/** * This method is invoked while deserialization */ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { in.defaultReadObject(); if (outputStream == null && duplicateContentBuffer != null) { outputStream = new ByteArrayOutputStream(); write(duplicateContentBuffer); duplicateContentBuffer = null; } }
protected void initOutputStream(java.io.OutputStream stream) { if (getOutputStream() == null && inputStream == null) outputStream = new PdfOutputStream(stream != null ? stream : new ByteArrayOutputStream()); }
/** * Constructs a {@code PdfStream}-object. * * @param bytes initial content of {@link PdfOutputStream}. * @param compressionLevel the compression level (0 = best speed, 9 = best compression, -1 is default) */ public PdfStream(byte[] bytes, int compressionLevel) { super(); setState(MUST_BE_INDIRECT); this.compressionLevel = compressionLevel; if (bytes != null && bytes.length > 0) { this.outputStream = new PdfOutputStream(new ByteArrayOutputStream(bytes.length)); this.outputStream.writeBytes(bytes); } else { this.outputStream = new PdfOutputStream(new ByteArrayOutputStream()); } }
/** * This method is invoked while deserialization */ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { in.defaultReadObject(); if (outputStream == null) { outputStream = new ByteArrayOutputStream().assignBytes(getDebugBytes()); } }
@SuppressWarnings("unused") private byte[] getSerializedBytes() { ByteArrayOutputStream bos = null; ObjectOutputStream oos = null; try { bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); oos.writeObject(this); oos.flush(); return bos.toByteArray(); } catch (Exception e) { Logger logger = LoggerFactory.getLogger(PdfDocument.class); logger.warn(LogMessageConstant.DOCUMENT_SERIALIZATION_EXCEPTION_RAISED, e); return null; } finally { if (oos != null) { try { oos.close(); } catch (IOException ignored) { } } if (bos != null) { try { bos.close(); } catch (IOException ignored) { } } } }
/** * Load data by 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 { InputStream input = null; try { input = UrlUtil.openStream(url); ByteArrayOutputStream stream = new ByteArrayOutputStream(); StreamUtil.transferBytes(UrlUtil.openStream(url), stream); data = stream.toByteArray(); } finally { if (input != null) { input.close(); } } } }
/** * Load data by 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 { InputStream input = null; try { input = UrlUtil.openStream(url); ByteArrayOutputStream stream = new ByteArrayOutputStream(); StreamUtil.transferBytes(UrlUtil.openStream(url), stream); data = stream.toByteArray(); } finally { if (input != null) { input.close(); } } } }
/** * 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(); }
/** * 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(); }
outputStream = new PdfOutputStream(new ByteArrayOutputStream());
bytes = decodeFlateBytes(pdfStream, bytes); pdfStream.initOutputStream(new ByteArrayOutputStream(bytes.length)); pdfStream.getOutputStream().write(bytes); if (toCompress && !containsFlateFilter(pdfStream) && (allowCompression || userDefinedCompression)) { // compress updateCompressionFilter(pdfStream); byteArrayStream = new ByteArrayOutputStream(); DeflaterOutputStream zip = new DeflaterOutputStream(byteArrayStream, pdfStream.getCompressionLevel()); if (pdfStream instanceof PdfObjectStream) { if (pdfStream instanceof PdfObjectStream) { PdfObjectStream objectStream = (PdfObjectStream) pdfStream; byteArrayStream = new ByteArrayOutputStream(); ((ByteArrayOutputStream) objectStream.getIndexStream().getOutputStream()).writeTo(byteArrayStream); ((ByteArrayOutputStream) objectStream.getOutputStream().getOutputStream()).writeTo(byteArrayStream); ByteArrayOutputStream encodedStream = new ByteArrayOutputStream(); OutputStreamEncryption ose = crypto.getEncryptionStream(encodedStream); byteArrayStream.writeTo(ose);
DeflaterOutputStream mzip = null; if (extraSamples > 0) { mstream = new ByteArrayOutputStream(); mzip = new DeflaterOutputStream(mstream); g4 = new CCITTG4Encoder(w); } else { stream = new ByteArrayOutputStream(); if (compression != TIFFConstants.COMPRESSION_OJPEG && compression != TIFFConstants.COMPRESSION_JPEG) zip = new DeflaterOutputStream(stream);
DeflaterOutputStream mzip = null; if (extraSamples > 0) { mstream = new ByteArrayOutputStream(); mzip = new DeflaterOutputStream(mstream); g4 = new CCITTG4Encoder(w); } else { stream = new ByteArrayOutputStream(); if (compression != TIFFConstants.COMPRESSION_OJPEG && compression != TIFFConstants.COMPRESSION_JPEG) zip = new DeflaterOutputStream(stream);