Exemplo n.º 1
0
 void propagate(PdfObject obj, PdfIndirectReference refo, boolean restricted) throws IOException {
   if (obj == null) return;
   //        if (refo != null)
   //            addToBody(obj, refo);
   if (obj instanceof PdfIndirectReference) return;
   switch (obj.type()) {
     case PdfObject.DICTIONARY:
     case PdfObject.STREAM:
       {
         PdfDictionary dic = (PdfDictionary) obj;
         for (PdfName key : dic.getKeys()) {
           if (restricted && (key.equals(PdfName.PARENT) || key.equals(PdfName.KIDS))) continue;
           PdfObject ob = dic.get(key);
           if (ob != null && ob.isIndirect()) {
             PRIndirectReference ind = (PRIndirectReference) ob;
             if (!setVisited(ind) && !isPage(ind)) {
               PdfIndirectReference ref = getNewReference(ind);
               propagate(PdfReader.getPdfObjectRelease(ind), ref, restricted);
             }
           } else propagate(ob, null, restricted);
         }
         break;
       }
     case PdfObject.ARRAY:
       {
         // PdfArray arr = new PdfArray();
         for (Iterator<PdfObject> it = ((PdfArray) obj).listIterator(); it.hasNext(); ) {
           PdfObject ob = it.next();
           if (ob != null && ob.isIndirect()) {
             PRIndirectReference ind = (PRIndirectReference) ob;
             if (!isVisited(ind) && !isPage(ind)) {
               PdfIndirectReference ref = getNewReference(ind);
               propagate(PdfReader.getPdfObjectRelease(ind), ref, restricted);
             }
           } else propagate(ob, null, restricted);
         }
         break;
       }
     case PdfObject.INDIRECT:
       {
         throw new RuntimeException(
             MessageLocalization.getComposedMessage("reference.pointing.to.reference"));
       }
   }
 }
Exemplo n.º 2
0
 /** @since 2.1.5; before 2.1.5 the method was private */
 protected void updateCalculationOrder(PdfReader reader) {
   PdfDictionary catalog = reader.getCatalog();
   PdfDictionary acro = catalog.getAsDict(PdfName.ACROFORM);
   if (acro == null) return;
   PdfArray co = acro.getAsArray(PdfName.CO);
   if (co == null || co.size() == 0) return;
   AcroFields af = reader.getAcroFields();
   for (int k = 0; k < co.size(); ++k) {
     PdfObject obj = co.getPdfObject(k);
     if (obj == null || !obj.isIndirect()) continue;
     String name = getCOName(reader, (PRIndirectReference) obj);
     if (af.getFieldItem(name) == null) continue;
     name = "." + name;
     if (calculationOrder.contains(name)) continue;
     calculationOrder.add(name);
   }
 }
Exemplo n.º 3
0
 /**
  * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfIndirectReference</CODE>.
  *
  * <p>The object associated with the <CODE>PdfName</CODE> given is retrieved If it is a <CODE>
  * PdfIndirectReference</CODE>, it is cast down and returned as such. Otherwise <CODE>null</CODE>
  * is returned.
  *
  * @param key A <CODE>PdfName</CODE>
  * @return the associated <CODE>PdfIndirectReference</CODE> object, or <CODE>null</CODE>
  */
 public PdfIndirectReference getAsIndirectObject(final PdfName key) {
   PdfIndirectReference ref = null;
   PdfObject orig = get(key); // not getDirect this time.
   if (orig != null && orig.isIndirect()) ref = (PdfIndirectReference) orig;
   return ref;
 }