public String getTextExpansion() { PdfObject o = getAccessibleAttribute(PdfName.E); if (o instanceof PdfString) return ((PdfString)o).toUnicodeString(); return null; }
public String getTextExpansion() { PdfObject o = getAccessibleAttribute(PdfName.E); if (o instanceof PdfString) return ((PdfString)o).toUnicodeString(); return null; }
/** * Adds a child layer. Nested layers can only have one parent. * @param child the child layer */ public void addChild(PdfLayer child) { if (child.parent != null) throw new IllegalArgumentException(MessageLocalization.getComposedMessage("the.layer.1.already.has.a.parent", child.getAsString(PdfName.NAME).toUnicodeString())); child.parent = this; if (children == null) children = new ArrayList<PdfLayer>(); children.add(child); }
/** * Adds a child layer. Nested layers can only have one parent. * @param child the child layer */ public void addChild(PdfLayer child) { if (child.parent != null) throw new IllegalArgumentException(MessageLocalization.getComposedMessage("the.layer.1.already.has.a.parent", child.getAsString(PdfName.NAME).toUnicodeString())); child.parent = this; if (children == null) children = new ArrayList<PdfLayer>(); children.add(child); }
private static String getCOName(PdfReader reader, PRIndirectReference ref) { String name = ""; while (ref != null) { PdfObject obj = PdfReader.getPdfObject(ref); if (obj == null || obj.type() != PdfObject.DICTIONARY) break; PdfDictionary dic = (PdfDictionary)obj; PdfString t = dic.getAsString(PdfName.T); if (t != null) { name = t.toUnicodeString()+ "." + name; } ref = (PRIndirectReference)dic.get(PdfName.PARENT); } if (name.endsWith(".")) name = name.substring(0, name.length() - 1); return name; }
private String decodeString(PdfString ps) { if (ps.isHexWriting()) return PdfEncodings.convertToString(ps.getBytes(), "UnicodeBigUnmarked"); else return ps.toUnicodeString(); }
private static String getCOName(PdfReader reader, PRIndirectReference ref) { String name = ""; while (ref != null) { PdfObject obj = PdfReader.getPdfObject(ref); if (obj == null || obj.type() != PdfObject.DICTIONARY) break; PdfDictionary dic = (PdfDictionary)obj; PdfString t = dic.getAsString(PdfName.T); if (t != null) { name = t.toUnicodeString()+ "." + name; } ref = (PRIndirectReference)dic.get(PdfName.PARENT); } if (name.endsWith(".")) name = name.substring(0, name.length() - 2); return name; }
private static String getCOName(PdfReader reader, PRIndirectReference ref) { String name = ""; while (ref != null) { PdfObject obj = PdfReader.getPdfObject(ref); if (obj == null || obj.type() != PdfObject.DICTIONARY) break; PdfDictionary dic = (PdfDictionary)obj; PdfString t = dic.getAsString(PdfName.T); if (t != null) { name = t.toUnicodeString()+ "." + name; } ref = (PRIndirectReference)dic.get(PdfName.PARENT); } if (name.endsWith(".")) name = name.substring(0, name.length() - 2); return name; }
private static String getCOName(PdfReader reader, PRIndirectReference ref) { String name = ""; while (ref != null) { PdfObject obj = PdfReader.getPdfObject(ref); if (obj == null || obj.type() != PdfObject.DICTIONARY) break; PdfDictionary dic = (PdfDictionary)obj; PdfString t = dic.getAsString(PdfName.T); if (t != null) { name = t.toUnicodeString()+ "." + name; } ref = (PRIndirectReference)dic.get(PdfName.PARENT); } if (name.endsWith(".")) name = name.substring(0, name.length() - 1); return name; }
protected static String getNameString(final PdfDictionary dic, final PdfName key) { PdfObject obj = PdfReader.getPdfObject(dic.get(key)); if (obj == null || !obj.isString()) return null; return ((PdfString)obj).toUnicodeString(); }
public String decodeStringToUnicode(PdfString ps) { if (ps.isHexWriting()) return PdfEncodings.convertToString(ps.getBytes(), "UnicodeBigUnmarked"); else return ps.toUnicodeString(); } }
protected static String getNameString(final PdfDictionary dic, final PdfName key) { PdfObject obj = PdfReader.getPdfObject(dic.get(key)); if (obj == null || !obj.isString()) return null; return ((PdfString)obj).toUnicodeString(); }
public String decodeStringToUnicode(PdfString ps) { if (ps.isHexWriting()) return PdfEncodings.convertToString(ps.getBytes(), "UnicodeBigUnmarked"); else return ps.toUnicodeString(); } }
private LineSegment getUnscaledBaselineWithOffset(float yOffset){ // we need to correct the width so we don't have an extra character and word spaces at the end. The extra character and word spaces // are important for tracking relative text coordinate systems, but should not be part of the baseline String unicodeStr = string.toUnicodeString(); float correctedUnscaledWidth = getUnscaledWidth() - (gs.characterSpacing + (unicodeStr.length() > 0 && unicodeStr.charAt(unicodeStr.length() - 1) == ' ' ? gs.wordSpacing : 0)) * gs.horizontalScaling; return new LineSegment(new Vector(0, yOffset, 1), new Vector(correctedUnscaledWidth, yOffset, 1)); }
private LineSegment getUnscaledBaselineWithOffset(float yOffset){ // we need to correct the width so we don't have an extra character and word spaces at the end. The extra character and word spaces // are important for tracking relative text coordinate systems, but should not be part of the baseline String unicodeStr = string.toUnicodeString(); float correctedUnscaledWidth = getUnscaledWidth() - (gs.characterSpacing + (unicodeStr.length() > 0 && unicodeStr.charAt(unicodeStr.length() - 1) == ' ' ? gs.wordSpacing : 0)) * gs.horizontalScaling; return new LineSegment(new Vector(0, yOffset, 1), new Vector(correctedUnscaledWidth, yOffset, 1)); }
private String decodeString(PdfString ps) { if (ps.isHexWriting()) return PdfEncodings.convertToString(ps.getBytes(), "UnicodeBigUnmarked"); else return ps.toUnicodeString(); }
protected void kidNode(PdfDictionary merged, String name) { PdfArray kids = merged.getAsArray(PdfName.KIDS); if (kids == null || kids.isEmpty()) { if (name.length() > 0) name = name.substring(1); fields.put(name, merged); } else { merged.remove(PdfName.KIDS); for (int k = 0; k < kids.size(); ++k) { PdfDictionary dic = new PdfDictionary(); dic.merge(merged); PdfDictionary newDic = kids.getAsDict(k); PdfString t = newDic.getAsString(PdfName.T); String newName = name; if (t != null) newName += "." + t.toUnicodeString(); dic.merge(newDic); dic.remove(PdfName.T); kidNode(dic, newName); } } }
protected void readFields() { catalog = trailer.getAsDict(PdfName.ROOT); PdfDictionary fdf = catalog.getAsDict(PdfName.FDF); if (fdf == null) return; PdfString fs = fdf.getAsString(PdfName.F); if (fs != null) fileSpec = fs.toUnicodeString(); PdfArray fld = fdf.getAsArray(PdfName.FIELDS); if (fld == null) return; encoding = fdf.getAsName(PdfName.ENCODING); PdfDictionary merged = new PdfDictionary(); merged.put(PdfName.KIDS, fld); kidNode(merged, ""); }
protected void readFields() { catalog = trailer.getAsDict(PdfName.ROOT); PdfDictionary fdf = catalog.getAsDict(PdfName.FDF); if (fdf == null) return; PdfString fs = fdf.getAsString(PdfName.F); if (fs != null) fileSpec = fs.toUnicodeString(); PdfArray fld = fdf.getAsArray(PdfName.FIELDS); if (fld == null) return; encoding = fdf.getAsName(PdfName.ENCODING); PdfDictionary merged = new PdfDictionary(); merged.put(PdfName.KIDS, fld); kidNode(merged, ""); }
private String[] getListOption(String fieldName, int idx) { Item fd = getFieldItem(fieldName); if (fd == null) return null; PdfArray ar = fd.getMerged(0).getAsArray(PdfName.OPT); if (ar == null) return null; String[] ret = new String[ar.size()]; for (int k = 0; k < ar.size(); ++k) { PdfObject obj = ar.getDirectObject( k ); try { if (obj.isArray()) { obj = ((PdfArray)obj).getDirectObject(idx); } if (obj.isString()) ret[k] = ((PdfString)obj).toUnicodeString(); else ret[k] = obj.toString(); } catch (Exception e) { ret[k] = ""; } } return ret; }