public byte[] getOriginalBytes() { if (originalValue == null) return getBytes(); return PdfEncodings.convertToBytes(originalValue, null); }
/** * @return The original bytes used to create this PDF string, or the bytes of our current value * if the original bytes are missing. */ public byte[] getOriginalBytes() { if (originalValue == null) return getBytes(); return PdfEncodings.convertToBytes(originalValue, null); }
public byte[] getOriginalBytes() { if (originalValue == null) return getBytes(); return PdfEncodings.convertToBytes(originalValue, null); }
/** * Returns the Unicode <CODE>String</CODE> value of this * <CODE>PdfString</CODE>-object. * * @return A <CODE>String</CODE> */ public String toUnicodeString() { if (encoding != null && encoding.length() != 0) return value; getBytes(); if (bytes.length >= 2 && bytes[0] == (byte)254 && bytes[1] == (byte)255) return PdfEncodings.convertToString(bytes, PdfObject.TEXT_UNICODE); else return PdfEncodings.convertToString(bytes, PdfObject.TEXT_PDFDOCENCODING); }
/** * Returns the Unicode <CODE>String</CODE> value of this * <CODE>PdfString</CODE>-object. * * @return A <CODE>String</CODE> */ public String toUnicodeString() { if (encoding != null && encoding.length() != 0) return value; getBytes(); if (bytes.length >= 2 && bytes[0] == (byte)254 && bytes[1] == (byte)255) return PdfEncodings.convertToString(bytes, PdfObject.TEXT_UNICODE); else return PdfEncodings.convertToString(bytes, PdfObject.TEXT_PDFDOCENCODING); }
/** * Returns the Unicode <CODE>String</CODE> value of this * <CODE>PdfString</CODE>-object. * * @return A <CODE>String</CODE> */ public String toUnicodeString() { if (encoding != null && encoding.length() != 0) return value; getBytes(); if (bytes.length >= 2 && bytes[0] == (byte)254 && bytes[1] == (byte)255) return PdfEncodings.convertToString(bytes, PdfObject.TEXT_UNICODE); else return PdfEncodings.convertToString(bytes, PdfObject.TEXT_PDFDOCENCODING); }
/** * Decodes a PdfString (which will contain glyph ids encoded in the font's encoding) * based on the active font, and determine the unicode equivalent * @param in the String that needs to be encoded * @return the encoded String * @since 2.1.7 */ private String decode(PdfString in){ byte[] bytes = in.getBytes(); return gs().font.decode(bytes, 0, bytes.length); }
/** * Decodes a PdfString (which will contain glyph ids encoded in the font's encoding) * based on the active font, and determine the unicode equivalent * @param in the String that needs to be encoded * @return the encoded String * @since 2.1.7 */ private String decode(PdfString in){ byte[] bytes = in.getBytes(); return gs().font.decode(bytes, 0, bytes.length); }
void addFileAttachment(String description, PdfFileSpecification fs) throws IOException { if (description == null) { PdfString desc = (PdfString)fs.get(PdfName.DESC); if (desc == null) { description = ""; } else { description = PdfEncodings.convertToString(desc.getBytes(), null); } } fs.addDescription(description, true); if (description.length() == 0) description = "Unnamed"; String fn = PdfEncodings.convertToString(new PdfString(description, PdfObject.TEXT_UNICODE).getBytes(), null); int k = 0; while (documentFileAttachment.containsKey(fn)) { ++k; fn = PdfEncodings.convertToString(new PdfString(description + " " + k, PdfObject.TEXT_UNICODE).getBytes(), null); } documentFileAttachment.put(fn, fs.getReference()); }
void addFileAttachment(String description, PdfFileSpecification fs) throws IOException { if (description == null) { PdfString desc = (PdfString)fs.get(PdfName.DESC); if (desc == null) { description = ""; } else { description = PdfEncodings.convertToString(desc.getBytes(), null); } } fs.addDescription(description, true); if (description.length() == 0) description = "Unnamed"; String fn = PdfEncodings.convertToString(new PdfString(description, PdfObject.TEXT_UNICODE).getBytes(), null); int k = 0; while (documentFileAttachment.containsKey(fn)) { ++k; fn = PdfEncodings.convertToString(new PdfString(description + " " + k, PdfObject.TEXT_UNICODE).getBytes(), null); } documentFileAttachment.put(fn, fs.getReference()); }
private String decodeString(PdfString ps) { if (ps.isHexWriting()) return PdfEncodings.convertToString(ps.getBytes(), "UnicodeBigUnmarked"); else return ps.toUnicodeString(); }
void addFileAttachment(String description, PdfFileSpecification fs) throws IOException { if (description == null) { PdfString desc = (PdfString)fs.get(PdfName.DESC); if (desc == null) { description = ""; } else { description = PdfEncodings.convertToString(desc.getBytes(), null); } } fs.addDescription(description, true); if (description.length() == 0) description = "Unnamed"; String fn = PdfEncodings.convertToString(new PdfString(description, PdfObject.TEXT_UNICODE).getBytes(), null); int k = 0; while (documentFileAttachment.containsKey(fn)) { ++k; fn = PdfEncodings.convertToString(new PdfString(description + " " + k, PdfObject.TEXT_UNICODE).getBytes(), null); } documentFileAttachment.put(fn, fs.getReference()); }
private String decodeString(PdfString ps) { if (ps.isHexWriting()) { return PdfEncodings.convertToString(ps.getBytes(), "UnicodeBigUnmarked"); } else { return ps.toUnicodeString(); } }
private String decodeString(PdfString ps) { if (ps.isHexWriting()) return PdfEncodings.convertToString(ps.getBytes(), "UnicodeBigUnmarked"); else return ps.toUnicodeString(); }
/** * 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 { 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(PdfContentByte.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 { 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(PdfContentByte.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 { 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(PdfContentByte.escapeString(b)); }
private static void iterateItems(PdfDictionary dic, HashMap<String, PdfObject> items) { PdfArray nn = (PdfArray) PdfReader.getPdfObjectRelease(dic.get(PdfName.NAMES)); if (nn != null) { for (int k = 0; k < nn.size(); ++k) { PdfString s = (PdfString) PdfReader.getPdfObjectRelease(nn.getPdfObject(k++)); items.put(PdfEncodings.convertToString(s.getBytes(), null), nn.getPdfObject(k)); } } else if ((nn = (PdfArray) PdfReader.getPdfObjectRelease(dic.get(PdfName.KIDS))) != null) { for (int k = 0; k < nn.size(); ++k) { PdfDictionary kid = (PdfDictionary) PdfReader.getPdfObjectRelease(nn.getPdfObject(k)); iterateItems(kid, items); } } }
private static void iterateItems(PdfDictionary dic, HashMap items) { PdfArray nn = (PdfArray)PdfReader.getPdfObjectRelease(dic.get(PdfName.NAMES)); if (nn != null) { for (int k = 0; k < nn.size(); ++k) { PdfString s = (PdfString)PdfReader.getPdfObjectRelease(nn.getPdfObject(k++)); items.put(PdfEncodings.convertToString(s.getBytes(), null), nn.getPdfObject(k)); } } else if ((nn = (PdfArray)PdfReader.getPdfObjectRelease(dic.get(PdfName.KIDS))) != null) { for (int k = 0; k < nn.size(); ++k) { PdfDictionary kid = (PdfDictionary)PdfReader.getPdfObjectRelease(nn.getPdfObject(k)); iterateItems(kid, items); } } }
private static void iterateItems(PdfDictionary dic, HashMap items) { PdfArray nn = (PdfArray)PdfReader.getPdfObjectRelease(dic.get(PdfName.NAMES)); if (nn != null) { for (int k = 0; k < nn.size(); ++k) { PdfString s = (PdfString)PdfReader.getPdfObjectRelease(nn.getPdfObject(k++)); items.put(PdfEncodings.convertToString(s.getBytes(), null), nn.getPdfObject(k)); } } else if ((nn = (PdfArray)PdfReader.getPdfObjectRelease(dic.get(PdfName.KIDS))) != null) { for (int k = 0; k < nn.size(); ++k) { PdfDictionary kid = (PdfDictionary)PdfReader.getPdfObjectRelease(nn.getPdfObject(k)); iterateItems(kid, items); } } }