/** * Escapes a <CODE>byte</CODE> array according to the PDF conventions. * * @param bytes the <CODE>byte</CODE> array to escape * @return an escaped <CODE>byte</CODE> array */ public static byte[] escapeString(final byte bytes[]) { ByteBuffer content = new ByteBuffer(); escapeString(bytes, content); return content.toByteArray(); }
/** * Escapes a <CODE>byte</CODE> array according to the PDF conventions. * * @param bytes the <CODE>byte</CODE> array to escape * @return an escaped <CODE>byte</CODE> array */ public static byte[] escapeString(final byte bytes[]) { ByteBuffer content = new ByteBuffer(); escapeString(bytes, content); return content.toByteArray(); }
/** * Converts an array of bytes to a String of hexadecimal values * @param bytes a byte array * @return the same bytes expressed as hexadecimal values */ public static String convertToHex(byte[] bytes) { ByteBuffer buf = new ByteBuffer(); for (byte b : bytes) { buf.appendHex(b); } return PdfEncodings.convertToString(buf.toByteArray(), null).toUpperCase(); }
/** * Converts an array of bytes to a String of hexadecimal values * @param bytes a byte array * @return the same bytes expressed as hexadecimal values */ public static String convertToHex(byte[] bytes) { ByteBuffer buf = new ByteBuffer(); for (byte b : bytes) { buf.appendHex(b); } return PdfEncodings.convertToString(buf.toByteArray(), null).toUpperCase(); }
ByteStore(PdfDictionary dict, HashMap<RefKey, Integer> serialized) throws IOException { try { md5 = MessageDigest.getInstance("MD5"); } catch (Exception e) { throw new ExceptionConverter(e); } ByteBuffer bb = new ByteBuffer(); int level = 100; serObject(dict, level, bb, serialized); this.b = bb.toByteArray(); hash = calculateHash(this.b); md5 = null; }
ByteStore(PRStream str, HashMap<RefKey, Integer> serialized) throws IOException { try { md5 = MessageDigest.getInstance("MD5"); } catch (Exception e) { throw new ExceptionConverter(e); } ByteBuffer bb = new ByteBuffer(); int level = 100; serObject(str, level, bb, serialized); this.b = bb.toByteArray(); hash = calculateHash(this.b); md5 = null; }
ByteStore(PdfDictionary dict, HashMap<RefKey, Integer> serialized) throws IOException { try { md5 = MessageDigest.getInstance("MD5"); } catch (Exception e) { throw new ExceptionConverter(e); } ByteBuffer bb = new ByteBuffer(); int level = 100; serObject(dict, level, bb, serialized); this.b = bb.toByteArray(); hash = calculateHash(this.b); md5 = null; }
ByteStore(PRStream str, HashMap<RefKey, Integer> serialized) throws IOException { try { md5 = MessageDigest.getInstance("MD5"); } catch (Exception e) { throw new ExceptionConverter(e); } ByteBuffer bb = new ByteBuffer(); int level = 100; serObject(str, level, bb, serialized); this.b = bb.toByteArray(); hash = calculateHash(this.b); md5 = null; }
ByteBuffer buf = new ByteBuffer(length + 20); buf.append('/'); char c;
/** * @see Graphics#dispose() */ @Override public void dispose() { if (kid) return; if (!disposeCalled) { disposeCalled = true; cb.restoreState(); cb.restoreState(); if (dg2 != null) { dg2.dispose(); dg2 = null; } if (kids != null) { ByteBuffer buf = new ByteBuffer(); internalDispose(buf); ByteBuffer buf2 = cb.getInternalBuffer(); buf2.reset(); buf2.append(buf); } } }
protected PdfWriter.PdfBody.PdfCrossReference addToObjStm(final PdfObject obj, final int nObj) throws IOException { if (numObj >= OBJSINSTREAM) flushObjStm(); if (index == null) { index = new ByteBuffer(); streamObjects = new ByteBuffer(); currentObjNum = getIndirectReferenceNumber(); numObj = 0; } int p = streamObjects.size(); int idx = numObj++; PdfEncryption enc = writer.crypto; writer.crypto = null; obj.toPdf(writer, streamObjects); writer.crypto = enc; streamObjects.append(' '); index.append(nObj).append(' ').append(p).append(' '); return new PdfWriter.PdfBody.PdfCrossReference(2, nObj, currentObjNum, idx); }
protected PdfWriter.PdfBody.PdfCrossReference addToObjStm(final PdfObject obj, final int nObj) throws IOException { if (numObj >= OBJSINSTREAM) flushObjStm(); if (index == null) { index = new ByteBuffer(); streamObjects = new ByteBuffer(); currentObjNum = getIndirectReferenceNumber(); numObj = 0; } int p = streamObjects.size(); int idx = numObj++; PdfEncryption enc = writer.crypto; writer.crypto = null; obj.toPdf(writer, streamObjects); writer.crypto = enc; streamObjects.append(' '); index.append(nObj).append(' ').append(p).append(' '); return new PdfWriter.PdfBody.PdfCrossReference(2, nObj, currentObjNum, idx); }
/** * Writes the PDF representation of this <CODE>PdfString</CODE> as an array * of <CODE>byte</CODE> to the specified <CODE>OutputStream</CODE>. * * @param writer for backwards compatibility * @param os The <CODE>OutputStream</CODE> to write the bytes to. */ public void toPdf(PdfWriter writer, OutputStream os) throws IOException { PdfWriter.checkPdfIsoConformance(writer, PdfIsoKeys.PDFISOKEY_OBJECT, this); byte b[] = getBytes(); PdfEncryption crypto = null; if (writer != null) crypto = writer.getEncryption(); if (crypto != null && !crypto.isEmbeddedFilesOnly()) b = crypto.encryptByteArray(b); if (hexWriting) { ByteBuffer buf = new ByteBuffer(); buf.append('<'); int len = b.length; for (int k = 0; k < len; ++k) buf.appendHex(b[k]); buf.append('>'); os.write(buf.toByteArray()); } else os.write(StringUtils.escapeString(b)); }
/** * Writes the PDF representation of this <CODE>PdfString</CODE> as an array * of <CODE>byte</CODE> to the specified <CODE>OutputStream</CODE>. * * @param writer for backwards compatibility * @param os The <CODE>OutputStream</CODE> to write the bytes to. */ public void toPdf(PdfWriter writer, OutputStream os) throws IOException { PdfWriter.checkPdfIsoConformance(writer, PdfIsoKeys.PDFISOKEY_OBJECT, this); byte b[] = getBytes(); PdfEncryption crypto = null; if (writer != null) crypto = writer.getEncryption(); if (crypto != null && !crypto.isEmbeddedFilesOnly()) b = crypto.encryptByteArray(b); if (hexWriting) { ByteBuffer buf = new ByteBuffer(); buf.append('<'); int len = b.length; for (int k = 0; k < len; ++k) buf.appendHex(b[k]); buf.append('>'); os.write(buf.toByteArray()); } else os.write(StringUtils.escapeString(b)); }
public static PdfObject createInfoId(byte id[], boolean modified) throws IOException { ByteBuffer buf = new ByteBuffer(90); if (id.length == 0) id = createDocumentId(); buf.append('[').append('<'); for (int k = 0; k < id.length; ++k) buf.appendHex(id[k]); buf.append('>').append('<'); if (modified) id = createDocumentId(); for (int k = 0; k < id.length; ++k) buf.appendHex(id[k]); buf.append('>').append(']'); buf.close(); return new PdfLiteral(buf.toByteArray()); }
public static PdfObject createInfoId(byte id[], boolean modified) throws IOException { ByteBuffer buf = new ByteBuffer(90); if (id.length == 0) id = createDocumentId(); buf.append('[').append('<'); for (int k = 0; k < id.length; ++k) buf.appendHex(id[k]); buf.append('>').append('<'); if (modified) id = createDocumentId(); for (int k = 0; k < id.length; ++k) buf.appendHex(id[k]); buf.append('>').append(']'); buf.close(); return new PdfLiteral(buf.toByteArray()); }
throw new DocumentException("Not enough space"); StreamUtil.CopyBytes(readerSource, 0, gaps[1] + 1, outs); ByteBuffer bb = new ByteBuffer(spaceAvailable * 2); for (byte bi : signedContent) { bb.appendHex(bi);
throw new DocumentException("Not enough space"); StreamUtil.CopyBytes(readerSource, 0, gaps[1] + 1, outs); ByteBuffer bb = new ByteBuffer(spaceAvailable * 2); for (byte bi : signedContent) { bb.appendHex(bi);
pageN.put(PdfName.CONTENTS, ar); ByteBuffer out = new ByteBuffer(); if (ps.under != null) { out.append(PdfContents.SAVESTATE);
pageN.put(PdfName.CONTENTS, ar); ByteBuffer out = new ByteBuffer(); if (under != null) { out.append(PdfContents.SAVESTATE);