/** * Creates the TableModel. * * @param dictionary the dictionary we want to show * @param pluginMode the plugin mode * @param parser the pdf syntax parser * @param owner the owner */ public DictionaryTableModel(PdfDictionary dictionary, boolean pluginMode, PdfSyntaxParser parser, Component owner) { this.pluginMode = pluginMode; this.dictionary = dictionary; this.parser = parser; this.parent = owner; this.keys.addAll(dictionary.keySet()); }
public Set<PdfName> getStates() { return getPdfObject().keySet(); }
/** * Gets the names of all the added resources. * * @return the name of all the added resources. */ public Set<PdfName> getResourceNames() { Set<PdfName> names = new TreeSet<>(); // TODO: isn't it better to use HashSet? Do we really need certain order? for (PdfName resType : getPdfObject().keySet()) { names.addAll(getResourceNames(resType)); } return names; }
/** * Gets the names of all resources of specified type. * * @param resType the resource type. Should be {@link PdfName#ColorSpace}, {@link PdfName#ExtGState}, * {@link PdfName#Pattern}, {@link PdfName#Shading}, {@link PdfName#XObject}, {@link PdfName#Font}. * @return set of resources name of corresponding type. May be empty. * Will be empty in case of incorrect resource type. */ public Set<PdfName> getResourceNames(PdfName resType) { PdfDictionary resourceCategory = getPdfObject().getAsDictionary(resType); return resourceCategory == null ? new TreeSet<PdfName>() : resourceCategory.keySet(); // TODO: TreeSet or HashSet enough? }
private static void appendSyntaxString(PdfDictionary dictionary) { stringBuilder.append("<< "); for (PdfName key : dictionary.keySet()) { safeAppendSyntaxString(key); stringBuilder.append(" "); safeAppendSyntaxString(dictionary.get(key, false)); stringBuilder.append(" "); } stringBuilder.append(">>"); }
private void addRow(PdfName key, PdfObject value) { dictionary.put(key, value); int index = -1; for (PdfName name : dictionary.keySet()) { ++index; if (name.equals(key)) { break; } } keys.add(index, key); fireTableRowsInserted(index, index); }
protected void inspectAttributes(PdfStructElem kid) { PdfObject attrObj = kid.getAttributes(false); if (attrObj != null) { PdfDictionary attrDict; if (attrObj instanceof PdfArray) { attrDict = ((PdfArray) attrObj).getAsDictionary(0); } else { attrDict = (PdfDictionary) attrObj; } try { for (PdfName key : attrDict.keySet()) { out.write(' '); String attrName = key.getValue(); out.write(Character.toLowerCase(attrName.charAt(0)) + attrName.substring(1)); out.write("=\""); out.write(attrDict.get(key, false).toString()); out.write("\""); } } catch (java.io.IOException e) { throw new com.itextpdf.io.IOException(com.itextpdf.io.IOException.UnknownIOException, e); } } }
/** * This method merges different fields from two dictionaries into the current one * @param other a dictionary whose fields should be merged into the current dictionary. */ public void mergeDifferent(PdfDictionary other){ for (PdfName key : other.keySet()){ if(!containsKey(key)) put(key, other.get(key)); } }
protected void buildResources(PdfDictionary dictionary) { for (PdfName resourceType : dictionary.keySet()) { if (getPdfObject().get(resourceType) == null) { getPdfObject().put(resourceType, new PdfDictionary()); } PdfDictionary resources = dictionary.getAsDictionary(resourceType); if (resources == null) { continue; } for (PdfName resourceName : resources.keySet()) { PdfObject resource = resources.get(resourceName, false); resourceToName.put(resource, resourceName); } } }
private void serDic(PdfDictionary dic, ByteBuffer bb, int level, Map<PdfIndirectReference, byte[]> serializedCache) throws SelfReferenceException { bb.append("$D"); if (level <= 0) return; for (PdfName key : dic.keySet()) { if (isKeyRefersBack(dic, key)) { continue; } serObject(key, bb, level, serializedCache); serObject(dic.get(key, false), bb, level, serializedCache); } bb.append("$\\D"); }
if (normal != null && !normal.isFlushed()) { if (normal.isDictionary()) { for (PdfName key : ((PdfDictionary) normal).keySet()) { PdfStream appearance = ((PdfDictionary) normal).getAsStream(key); PdfDictionary resDict = appearance.getAsDictionary(PdfName.Resources);
if (normal != null && !normal.isFlushed()) { if (normal.isDictionary()) { for (PdfName key : ((PdfDictionary) normal).keySet()) { PdfStream appearance = ((PdfDictionary) normal).getAsStream(key); PdfDictionary resDict = appearance.getAsDictionary(PdfName.Resources);
@Override protected void checkPageObject(PdfDictionary pageDict, PdfDictionary pageResources) { PdfDictionary actions = pageDict.getAsDictionary(PdfName.AA); if (actions != null) { for (PdfName key : actions.keySet()) { PdfDictionary action = actions.getAsDictionary(key); checkAction(action); } } if (pageDict.containsKey(PdfName.Group) && PdfName.Transparency.equals(pageDict.getAsDictionary(PdfName.Group).getAsName(PdfName.S))) { throw new PdfAConformanceException(PdfAConformanceException.A_GROUP_OBJECT_WITH_AN_S_KEY_WITH_A_VALUE_OF_TRANSPARENCY_SHALL_NOT_BE_INCLUDED_IN_A_PAGE_XOBJECT); } }
@Override protected void checkPageObject(PdfDictionary pageDict, PdfDictionary pageResources) { PdfDictionary actions = pageDict.getAsDictionary(PdfName.AA); if (actions != null) { for (PdfName key : actions.keySet()) { PdfDictionary action = actions.getAsDictionary(key); checkAction(action); } } if (pageDict.containsKey(PdfName.Group) && PdfName.Transparency.equals(pageDict.getAsDictionary(PdfName.Group).getAsName(PdfName.S))) { throw new PdfAConformanceException(PdfAConformanceException.A_GROUP_OBJECT_WITH_AN_S_KEY_WITH_A_VALUE_OF_TRANSPARENCY_SHALL_NOT_BE_INCLUDED_IN_A_PAGE_XOBJECT); } }
/** * In case an object is an array, a dictionary or a stream, * we need to loop over the entries and process them one by one. * * @param obj the object to examine */ protected final void loopOver(PdfObject obj) { switch (obj.getType()) { case PdfObject.ARRAY: PdfArray array = (PdfArray) obj; for (int i = 0; i < array.size(); i++) { process(array.get(i)); } break; case PdfObject.DICTIONARY: case PdfObject.STREAM: PdfDictionary dict = (PdfDictionary) obj; if (PdfName.Pages.equals(dict.get(PdfName.Type))) { break; } for (PdfName name : dict.keySet()) { process(dict.get(name)); } break; } }
private void write(PdfDictionary pdfDictionary) { writeBytes(openDict); for (PdfName key : pdfDictionary.keySet()) { boolean isAlreadyWriteSpace = false; write(key);
for (PdfName n : vrim.keySet()) { if (validated.containsKey(n)) { PdfDictionary vri = vrim.getAsDictionary(n);
for (PdfName n : vrim.keySet()) { if (validated.containsKey(n)) { PdfDictionary vri = vrim.getAsDictionary(n);
for (PdfName glyphName : charProcsDic.keySet()) { int unicode = AdobeGlyphList.nameToUnicode(glyphName.getValue()); if (unicode != -1 && fontEncoding.canEncode(unicode)) {