public byte[] toByteArray() throws IOException { return IOUtils.toByteArray(this); } }
private static byte[] getBytesFromStream(final COSStream stream) throws IOException { try (final InputStream is = stream.createInputStream()) { return IOUtils.toByteArray(is); } }
/** * Creates a signed timestamp token by the given input stream. * * @param content InputStream of the content to sign * @return the byte[] of the timestamp token * @throws IOException */ public byte[] getTimeStampToken(InputStream content) throws IOException { return tsaClient.getTimeStampToken(IOUtils.toByteArray(content)); }
@Override public void actionPerformed(ActionEvent actionEvent) { try { byte[] bytes = IOUtils.toByteArray(cosStream.createInputStream()); saveStream(bytes, fileFilter, extension); } catch (IOException e) { e.printStackTrace(); } } });
/** * Creates a new JPEG Image XObject from an input stream containing JPEG data. * * The input stream data will be preserved and embedded in the PDF file without modification. * @param document the document where the image will be created * @param stream a stream of JPEG data * @return a new Image XObject * * @throws IOException if the input stream cannot be read */ public static PDImageXObject createFromStream(PDDocument document, InputStream stream) throws IOException { return createFromByteArray(document, IOUtils.toByteArray(stream)); }
@Override public void actionPerformed(ActionEvent actionEvent) { try { InputStream data = stream.createInputStream(stopFilters); saveStream(IOUtils.toByteArray(data), null, null); } catch (IOException e) { e.printStackTrace(); } } });
@Override public void actionPerformed(ActionEvent actionEvent) { try { byte[] bytes = IOUtils.toByteArray(cosStream.createRawInputStream()); saveStream(bytes, null, null); } catch (IOException e) { e.printStackTrace(); } } });
@Override public void actionPerformed(ActionEvent actionEvent) { try { byte[] bytes = IOUtils.toByteArray(cosStream.createInputStream()); File temp = File.createTempFile("pdfbox", "." + extension); temp.deleteOnExit(); try (FileOutputStream outputStream = new FileOutputStream(temp)) { outputStream.write(bytes); Desktop.getDesktop().open(temp); } } catch (IOException e) { e.printStackTrace(); } } });
response = IOUtils.toByteArray(input);
try (FileInputStream fis = new FileInputStream(fileName)) documentBytes = IOUtils.toByteArray(fis);
@Override public byte[] getBytes() throws IOException { PDStream ff3Stream = getFontDescriptor().getFontFile3(); return IOUtils.toByteArray(ff3Stream.createInputStream()); } }
@Override public byte[] getBytes() throws IOException { PDStream ff3Stream = getFontDescriptor().getFontFile3(); return IOUtils.toByteArray(ff3Stream.createInputStream()); } }
/** * This will encrypt a stream, but not the dictionary as the dictionary is * encrypted by visitFromString() in COSWriter and we don't want to encrypt * it twice. * * @param stream The stream to decrypt. * @param objNum The object number. * @param genNum The object generation number. * * @throws IOException If there is an error getting the stream data. */ public void encryptStream(COSStream stream, long objNum, int genNum) throws IOException { byte[] rawData = IOUtils.toByteArray(stream.createRawInputStream()); ByteArrayInputStream encryptedStream = new ByteArrayInputStream(rawData); try (OutputStream output = stream.createRawOutputStream()) { encryptData(objNum, genNum, encryptedStream, output, false /* encrypt */); } }
protected final byte[] getMetaDataStreamAsBytes(PDMetadata metadata) { try (InputStream metaDataContent = metadata.createInputStream()) { return IOUtils.toByteArray(metaDataContent); } catch (IOException e) { this.fContainer.push(new ValidationError(ERROR_METADATA_FORMAT_STREAM, this.font.getName() + ": Unable to read font metadata due to : " + e.getMessage(), e)); return null; } }
private void requestStreamText(String command) throws IOException { new DocumentCreator(command).execute(); synchronized (stream) { InputStream is = stream.getStream(command); if (is == null) { JOptionPane.showMessageDialog(panel, command + " text not available (filter missing?)"); return; } hexView.changeData(IOUtils.toByteArray(is)); } }
final int[] readCIDToGIDMap() throws IOException { int[] cid2gid = null; COSBase map = dict.getDictionaryObject(COSName.CID_TO_GID_MAP); if (map instanceof COSStream) { COSStream stream = (COSStream) map; InputStream is = stream.createInputStream(); byte[] mapAsBytes = IOUtils.toByteArray(is); IOUtils.closeQuietly(is); int numberOfInts = mapAsBytes.length / 2; cid2gid = new int[numberOfInts]; int offset = 0; for (int index = 0; index < numberOfInts; index++) { int gid = (mapAsBytes[offset] & 0xff) << 8 | mapAsBytes[offset + 1] & 0xff; cid2gid[index] = gid; offset += 2; } } return cid2gid; } }
try byte[] bytes = IOUtils.toByteArray(stream.createInputStream()); out = stream.createOutputStream(COSName.FLATE_DECODE); out.write(bytes);
/** * Go through the elements of a COSArray containing each an COSStream to print in Hex. * * @param elements COSArray of elements containing a COS Stream * @param description to append on Print * @throws IOException */ private void printStreamsFromArray(COSArray elements, String description) throws IOException { for (COSBase baseElem : elements) { COSObject streamObj = (COSObject) baseElem; if (streamObj.getObject() instanceof COSStream) { COSStream cosStream = (COSStream) streamObj.getObject(); try (InputStream is = cosStream.createInputStream()) { byte[] streamBytes = IOUtils.toByteArray(is); System.out.println(description + " (" + elements.indexOf(streamObj) + "): " + Hex.getString(streamBytes)); } } } }
private StyledDocument getContentStreamDocument(InputStream inputStream) { StyledDocument docu = new DefaultStyledDocument(); PDFStreamParser parser; try { parser = new PDFStreamParser(IOUtils.toByteArray(inputStream)); parser.parse(); } catch (IOException e) { return null; } for (Object obj : parser.getTokens()) { writeToken(obj, docu); } return docu; }
byte[] mapAsBytes = IOUtils.toByteArray(is); IOUtils.closeQuietly(is); int numberOfInts = mapAsBytes.length / 2;