private void pushPageAttributes(PdfDictionary nodePages) { PdfDictionary dic = new PdfDictionary(); if (!pageInh.isEmpty()) { dic.putAll((PdfDictionary)pageInh.get(pageInh.size() - 1)); } for (int k = 0; k < pageInhCandidates.length; ++k) { PdfObject obj = nodePages.get(pageInhCandidates[k]); if (obj != null) dic.put(pageInhCandidates[k], obj); } pageInh.add(dic); }
/** * Adds a PdfDictionary to the pageInh stack to keep track of the page attributes. * @param nodePages a Pages dictionary */ private void pushPageAttributes(PdfDictionary nodePages) { PdfDictionary dic = new PdfDictionary(); if (!pageInh.isEmpty()) { dic.putAll((PdfDictionary)pageInh.get(pageInh.size() - 1)); } for (int k = 0; k < pageInhCandidates.length; ++k) { PdfObject obj = nodePages.get(pageInhCandidates[k]); if (obj != null) dic.put(pageInhCandidates[k], obj); } pageInh.add(dic); }
/** * Adds a PdfDictionary to the pageInh stack to keep track of the page * attributes. * * @param nodePages * a Pages dictionary */ private void pushPageAttributes(PdfDictionary nodePages) { PdfDictionary dic = new PdfDictionary(); if (!pageInh.isEmpty()) { dic.putAll((PdfDictionary) pageInh.get(pageInh.size() - 1)); } for (PdfName pageInhCandidate : pageInhCandidates) { PdfObject obj = nodePages.get(pageInhCandidate); if (obj != null) dic.put(pageInhCandidate, obj); } pageInh.add(dic); }
void add(PdfName key, PdfDictionary resource) { if (resource.size() == 0) return; PdfDictionary dic = getAsDict(key); if (dic == null) put(key, resource); else dic.putAll(resource); } }
void add(PdfName key, PdfDictionary resource) { if (resource.size() == 0) return; PdfDictionary dic = getAsDict(key); if (dic == null) put(key, resource); else dic.putAll(resource); } }
void add(PdfName key, PdfDictionary resource) { if (resource.size() == 0) return; PdfDictionary dic = getAsDict(key); if (dic == null) put(key, resource); else dic.putAll(resource); } }
/** * merge field attributes from two dictionaries * @param parent one dictionary * @param child the other dictionary * @return a merged dictionary */ protected PdfDictionary mergeAttrib(PdfDictionary parent, PdfDictionary child) { PdfDictionary targ = new PdfDictionary(); if (parent != null) targ.putAll(parent); for (Iterator it = child.getKeys().iterator(); it.hasNext();) { PdfName key = (PdfName) it.next(); if (key.equals(PdfName.DR) || key.equals(PdfName.DA) || key.equals(PdfName.Q) || key.equals(PdfName.FF) || key.equals(PdfName.DV) || key.equals(PdfName.V) || key.equals(PdfName.FT) || key.equals(PdfName.F)) { targ.put(key,child.get(key)); } } return targ; } /**
/** * merge field attributes from two dictionaries * @param parent one dictionary * @param child the other dictionary * @return a merged dictionary */ protected PdfDictionary mergeAttrib(PdfDictionary parent, PdfDictionary child) { PdfDictionary targ = new PdfDictionary(); if (parent != null) targ.putAll(parent); for (Iterator it = child.getKeys().iterator(); it.hasNext();) { PdfName key = (PdfName) it.next(); if (key.equals(PdfName.DR) || key.equals(PdfName.DA) || key.equals(PdfName.Q) || key.equals(PdfName.FF) || key.equals(PdfName.DV) || key.equals(PdfName.V) || key.equals(PdfName.FT) || key.equals(PdfName.F)) { targ.put(key,child.get(key)); } } return targ; } /**
/** * merge field attributes from two dictionaries * @param parent one dictionary * @param child the other dictionary * @return a merged dictionary */ protected PdfDictionary mergeAttrib(PdfDictionary parent, PdfDictionary child) { PdfDictionary targ = new PdfDictionary(); if (parent != null) targ.putAll(parent); for (Iterator it = child.getKeys().iterator(); it.hasNext();) { PdfName key = (PdfName) it.next(); if (key.equals(PdfName.DR) || key.equals(PdfName.DA) || key.equals(PdfName.Q) || key.equals(PdfName.FF) || key.equals(PdfName.DV) || key.equals(PdfName.V) || key.equals(PdfName.FT) || key.equals(PdfName.F)) { targ.put(key,child.get(key)); } } return targ; } /**
PdfReader reader = new PdfReader(resource); PdfDictionary form = reader.getCatalog().getAsDict(PdfName.ACROFORM); PdfArray fields = form.getAsArray(PdfName.FIELDS); for (PdfObject object: fields) { PdfDictionary field = (PdfDictionary) PdfReader.getPdfObject(object); if ("Text1".equals(field.getAsString(PdfName.T).toString())) { PdfDictionary newField = new PdfDictionary(); PRIndirectReference newFieldRef = reader.addPdfObject(newField); fields.add(newFieldRef); newField.putAll(field); newField.put(PdfName.T, new PdfString("foobar")); PdfArray newKids = new PdfArray(); newField.put(PdfName.KIDS, newKids); PdfArray kids = field.getAsArray(PdfName.KIDS); PdfObject widget = kids.remove(0); newKids.add(widget); PdfDictionary widgetDict = (PdfDictionary) PdfReader.getPdfObject(widget); widgetDict.put(PdfName.PARENT, newFieldRef); break; } } PdfStamper stamper = new PdfStamper(reader, result); stamper.close();
if (contents != null) { if (contents.isStream()) dic.putAll((PRStream)contents); else bout = reader.getPageContent(pageNumber, file);
if (contents != null) { if (contents.isStream()) dic.putAll((PRStream)contents); else bout = reader.getPageContent(pageNumber, file);
if (contents != null) { if (contents.isStream()) dic.putAll((PRStream)contents); else bout = reader.getPageContent(pageNumber, file);
if (trailer == null) { trailer = new PdfDictionary(); trailer.putAll(stm);
if (trailer == null) { trailer = new PdfDictionary(); trailer.putAll(stm);
if (trailer == null) { trailer = new PdfDictionary(); trailer.putAll(stm);