private PdfDictionary getPdfAOutputIntent(PdfArray outputIntents) { for (int i = 0; i < outputIntents.size(); ++i) { PdfName outputIntentSubtype = outputIntents.getAsDictionary(i).getAsName(PdfName.S); if (PdfName.GTS_PDFA1.equals(outputIntentSubtype)) { return outputIntents.getAsDictionary(i); } } return null; }
private PdfDictionary getPdfAOutputIntent(PdfArray outputIntents) { for (int i = 0; i < outputIntents.size(); ++i) { PdfName outputIntentSubtype = outputIntents.getAsDictionary(i).getAsName(PdfName.S); if (PdfName.GTS_PDFA1.equals(outputIntentSubtype)) { return outputIntents.getAsDictionary(i); } } return null; }
public PdfUserProperty getUserProperty(int i) { PdfDictionary propDict = getPdfObject().getAsArray(PdfName.P).getAsDictionary(i); if (propDict == null) { return null; } return new PdfUserProperty(propDict); }
private void actualizeNamespacesInStructTreeRoot() { if (namespaces.size() > 0) { PdfStructTreeRoot structTreeRoot = getDocument().getStructTreeRoot(); PdfArray rootNamespaces = structTreeRoot.getNamespacesObject(); Set<PdfDictionary> newNamespaces = new LinkedHashSet<>(namespaces); for (int i = 0; i < rootNamespaces.size(); ++i) { newNamespaces.remove(rootNamespaces.getAsDictionary(i)); } for (PdfDictionary newNs : newNamespaces) { rootNamespaces.add(newNs); } if (!newNamespaces.isEmpty()) { structTreeRoot.setModified(); } } }
@Override protected void checkOutputIntents(PdfDictionary catalog) { PdfArray outputIntents = catalog.getAsArray(PdfName.OutputIntents); if (outputIntents == null) return; int i; PdfObject destOutputProfile = null; for (i = 0; i < outputIntents.size() && destOutputProfile == null; ++i) { destOutputProfile = outputIntents.getAsDictionary(i).get(PdfName.DestOutputProfile); } for (; i < outputIntents.size(); ++i) { PdfObject otherDestOutputProfile = outputIntents.getAsDictionary(i).get(PdfName.DestOutputProfile); if (otherDestOutputProfile != null && destOutputProfile != otherDestOutputProfile) { throw new PdfAConformanceException(PdfAConformanceException.IF_OUTPUTINTENTS_ARRAY_HAS_MORE_THAN_ONE_ENTRY_WITH_DESTOUTPUTPROFILE_KEY_THE_SAME_INDIRECT_OBJECT_SHALL_BE_USED_AS_THE_VALUE_OF_THAT_OBJECT); } } }
private String createUniqueName() { int uniqueID = 0; Set<String> usedNames = new HashSet<>(); PdfArray configs = getPdfObject().getAsArray(PdfName.Configs); if (null != configs) { for (int i = 0; i < configs.size(); i++) { PdfDictionary alternateDictionary = configs.getAsDictionary(i); if (null != alternateDictionary && alternateDictionary.containsKey(PdfName.Name)) { usedNames.add(alternateDictionary.getAsString(PdfName.Name).toUnicodeString()); } } } while (usedNames.contains("OCConfigName" + uniqueID)) { uniqueID++; } return "OCConfigName" + uniqueID; }
@Override protected void checkOutputIntents(PdfDictionary catalog) { PdfArray outputIntents = catalog.getAsArray(PdfName.OutputIntents); if (outputIntents == null) return; int i; PdfObject destOutputProfile = null; for (i = 0; i < outputIntents.size() && destOutputProfile == null; ++i) { destOutputProfile = outputIntents.getAsDictionary(i).get(PdfName.DestOutputProfile); } for (; i < outputIntents.size(); ++i) { PdfObject otherDestOutputProfile = outputIntents.getAsDictionary(i).get(PdfName.DestOutputProfile); if (otherDestOutputProfile != null && destOutputProfile != otherDestOutputProfile) { throw new PdfAConformanceException(PdfAConformanceException.IF_OUTPUTINTENTS_ARRAY_HAS_MORE_THAN_ONE_ENTRY_WITH_DESTOUTPUTPROFILE_KEY_THE_SAME_INDIRECT_OBJECT_SHALL_BE_USED_AS_THE_VALUE_OF_THAT_OBJECT); } } }
private boolean isEqualSameNameDestExist(Map<PdfPage, PdfPage> page2page, PdfDocument toDocument, String srcDestName, PdfArray srcDestArray, PdfPage oldPage) { PdfArray sameNameDest = (PdfArray) toDocument.getCatalog().getNameTree(PdfName.Dests).getNames().get(srcDestName); boolean equalSameNameDestExists = false; if (sameNameDest != null && sameNameDest.getAsDictionary(0) != null) { PdfIndirectReference existingDestPageRef = sameNameDest.getAsDictionary(0).getIndirectReference(); PdfIndirectReference newDestPageRef = page2page.get(oldPage).getPdfObject().getIndirectReference(); if (equalSameNameDestExists = existingDestPageRef.equals(newDestPageRef) && sameNameDest.size() == srcDestArray.size()) { for (int i = 1; i < sameNameDest.size(); ++i) { equalSameNameDestExists = equalSameNameDestExists && sameNameDest.get(i).equals(srcDestArray.get(i)); } } } return equalSameNameDestExists; }
public CalGray(float[] whitePoint) { this(getInitialPdfArray()); if (whitePoint == null || whitePoint.length != 3) throw new PdfException(PdfException.WhitePointIsIncorrectlySpecified, this); PdfDictionary d = ((PdfArray)getPdfObject()).getAsDictionary(1); d.put(PdfName.WhitePoint, new PdfArray(whitePoint)); }
public Lab(float[] whitePoint) { this(getInitialPdfArray()); if (whitePoint == null || whitePoint.length != 3) throw new PdfException(PdfException.WhitePointIsIncorrectlySpecified, this); PdfDictionary d = ((PdfArray)getPdfObject()).getAsDictionary(1); d.put(PdfName.WhitePoint, new PdfArray(whitePoint)); }
public CalGray(float[] whitePoint, float[] blackPoint, float gamma) { this(whitePoint); PdfDictionary d = ((PdfArray)getPdfObject()).getAsDictionary(1); if (blackPoint != null) d.put(PdfName.BlackPoint, new PdfArray(blackPoint)); if (gamma != Float.NaN) d.put(PdfName.Gamma, new PdfNumber(gamma)); }
public Lab(float[] whitePoint, float[] blackPoint, float[] range) { this(whitePoint); PdfDictionary d = ((PdfArray)getPdfObject()).getAsDictionary(1); if (blackPoint != null) d.put(PdfName.BlackPoint, new PdfArray(blackPoint)); if (range != null) d.put(PdfName.Range, new PdfArray(range)); }
public CalRgb(float[] whitePoint) { this(getInitialPdfArray()); if (whitePoint == null || whitePoint.length != 3) throw new PdfException(PdfException.WhitePointIsIncorrectlySpecified, this); PdfDictionary d = ((PdfArray)getPdfObject()).getAsDictionary(1); d.put(PdfName.WhitePoint, new PdfArray(whitePoint)); }
private void checkAnnotations(PdfDictionary page) { PdfArray annots = page.getAsArray(PdfName.Annots); if (annots != null) { for (int i = 0; i < annots.size(); i++) { PdfDictionary annot = annots.getAsDictionary(i); checkAnnotation(annot); PdfDictionary action = annot.getAsDictionary(PdfName.A); if (action != null) { checkAction(action); } } } }
private void checkAnnotations(PdfDictionary page) { PdfArray annots = page.getAsArray(PdfName.Annots); if (annots != null) { for (int i = 0; i < annots.size(); i++) { PdfDictionary annot = annots.getAsDictionary(i); checkAnnotation(annot); PdfDictionary action = annot.getAsDictionary(PdfName.A); if (action != null) { checkAction(action); } } } }
private void flushResourcesContentStreams() { flushResourcesContentStreams(getResources().getPdfObject()); PdfArray annots = getAnnots(false); if (annots != null) { for (int i = 0; i < annots.size(); ++i) { PdfDictionary apDict = annots.getAsDictionary(i).getAsDictionary(PdfName.AP); if (apDict != null) { flushAppearanceStreams(apDict); } } } }
private boolean isRadioButton() { if (isWidgetAnnotation(getPdfObject())) { return true; } else if (getPdfObject().getAsName(PdfName.V) != null) { return false; } else if (getKids() != null) { return isWidgetAnnotation(getKids().getAsDictionary(0)); } else { return false; } }
public CalRgb(float[] whitePoint, float[] blackPoint, float[] gamma, float[] matrix) { this(whitePoint); PdfDictionary d = ((PdfArray)getPdfObject()).getAsDictionary(1); if (blackPoint != null) d.put(PdfName.BlackPoint, new PdfArray(blackPoint)); if (gamma != null) d.put(PdfName.Gamma, new PdfArray(gamma)); if (matrix != null) d.put(PdfName.Matrix, new PdfArray(matrix)); }
private boolean isRadioButton() { if (isWidgetAnnotation(getPdfObject())) { return true; } else if (getPdfObject().getAsName(PdfName.V) != null) { return false; } else if (getKids() != null) { return isWidgetAnnotation(getKids().getAsDictionary(0)); } else { return false; } }
public void expand(PdfIndirectReference ref, PdfDictionary dict) { if (dict == null) return; if (PdfName.Pages.equals(dict.getAsName(PdfName.Type))) { PdfArray kids = dict.getAsArray(PdfName.Kids); if (kids != null) { for (int i = 0; i < kids.size(); i++) { expand((PdfIndirectReference) kids.get(i, false), kids.getAsDictionary(i)); } } } else if (PdfName.Page.equals(dict.getAsName(PdfName.Type))) { pages.add((PdfPageTreeNode) factory.getNode(ref.getObjNumber())); } } }