PdfDictionary pageDict = myReader.getPageN(1); PdfArray annots = pageDict.getAsArray(PdfName.ANNOTS); ArrayList<String> dests = new ArrayList<String>(); if (annots != null) { for (int i = 0; i < annots.size(); ++i) { PdfDictionary annotDict = annots.getAsDict(i); PdfName subType = annotDict.getAsName(PdfName.SUBTYPE); if (subType != null && PdfName.LINK.equals(subType)) { PdfDictionary action = annotDict.getAsDict(PdfName.A); if (action != null && PdfName.URI.equals(action.getAsName(PdfName.S)) { dests.add(action.getAsString(PdfName.URI).toString()); } // else { its an internal link, meh } } } }
//code within the above while() PdfDictionary d = entry.getValue().getMerged(0); PdfString fieldDA = d.getAsString(PdfName.DA); //in case of no form field default appearance create a default one if(fieldDA==null) ... Object[] infos = AcroFields.splitDAelements(fieldDA.toString()); if(infos[0]!=null) String fontName = (String)infos[0]; if(infos[1]!=null) float fontSize= (((Float)infos[1]).floatValue());
AcroFields fields = reader.getAcroFields(); PdfDictionary sigDict = fields.getSignatureDictionary(name); PdfString contents = sigDict.getAsString(PdfName.CONTENTS); byte[] contentBytes = contents.getOriginalBytes();
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 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; }
/** * Retrieve the rich value for the given field * @param name * @return The rich value if present, or null. * @since 5.0.6 */ public String getFieldRichValue(String name) { if (xfa.isXfaPresent()) { return null; } Item item = fields.get(name); if (item == null) { return null; } PdfDictionary merged = item.getMerged(0); PdfString rich = merged.getAsString(PdfName.RV); String markup = null; if (rich != null) { markup = rich.toString(); } return markup; } /**
/** * Retrieve the rich value for the given field * @param name * @return The rich value if present, or null. * @since 5.0.6 */ public String getFieldRichValue(String name) { if (xfa.isXfaPresent()) { return null; } Item item = fields.get(name); if (item == null) { return null; } PdfDictionary merged = item.getMerged(0); PdfString rich = merged.getAsString(PdfName.RV); String markup = null; if (rich != null) { markup = rich.toString(); } return markup; } /**
if (v == null) continue; PdfString contents = v.getAsString(PdfName.CONTENTS); if (contents == null) continue;
if (v == null) continue; PdfString contents = v.getAsString(PdfName.CONTENTS); if (contents == null) continue;
private PdfName getSignatureHashKey(String signatureName) throws NoSuchAlgorithmException, IOException { PdfDictionary dic = acroFields.getSignatureDictionary(signatureName); PdfString contents = dic.getAsString(PdfName.CONTENTS); byte[] bc = contents.getOriginalBytes(); byte[] bt = null; if (PdfName.ETSI_RFC3161.equals(PdfReader.getPdfObject(dic.get(PdfName.SUBFILTER)))) { ASN1InputStream din = new ASN1InputStream(new ByteArrayInputStream(bc)); ASN1Primitive pkcs = din.readObject(); bc = pkcs.getEncoded(); } bt = hashBytesSha1(bc); return new PdfName(Utilities.convertToHex(bt)); }
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 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); } } }
HashSet<String> names = new LinkedHashSet<String>(); PdfDictionary vals = fd.getValue(0); PdfString stringOpt = vals.getAsString( PdfName.OPT );
private PdfName getSignatureHashKey(String signatureName) throws NoSuchAlgorithmException, IOException { PdfDictionary dic = acroFields.getSignatureDictionary(signatureName); PdfString contents = dic.getAsString(PdfName.CONTENTS); byte[] bc = null; if(!reader.isEncrypted()) { bc = contents.getOriginalBytes(); }else{ bc = contents.getBytes(); } byte[] bt = null; if (PdfName.ETSI_RFC3161.equals(PdfReader.getPdfObject(dic.get(PdfName.SUBFILTER)))) { ASN1InputStream din = new ASN1InputStream(new ByteArrayInputStream(bc)); ASN1Primitive pkcs = din.readObject(); bc = pkcs.getEncoded(); } bt = hashBytesSha1(bc); return new PdfName(Utilities.convertToHex(bt)); }
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, ""); }
PdfDictionary decodeParams = getDirectDictionary(stream.get(PdfName.DECODEPARMS)); if (decodeParams != null) { PdfString cryptFilterName = decodeParams.getAsString(PdfName.NAME); if (cryptFilterName != null && !cryptFilterName.equals(PdfName.IDENTITY)) { throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("not.identity.crypt.filter.is.not.permitted")); if (decodeParams != null && i < decodeParams.size()) { PdfDictionary decodeParam = getDirectDictionary(decodeParams.getPdfObject(i)); PdfString cryptFilterName = decodeParam.getAsString(PdfName.NAME); if (cryptFilterName != null && !cryptFilterName.equals(PdfName.IDENTITY)) { throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("not.identity.crypt.filter.is.not.permitted"));
if (cidinfo == null) return; PdfString ordering = cidinfo.getAsString(PdfName.ORDERING); if (ordering == null) return;