protected void do_endnotdefchar(CSOperation operation) {
   Iterator it = operation.getOperands();
   while (it.hasNext()) {
     COSString start = (COSString) it.next();
     COSInteger destination = (COSInteger) it.next();
     CMapCharMap map = new CMapCIDCharCodeMap(start.byteValue(), destination.intValue());
     addNotdef(map);
   }
 }
 protected void do_endcidrange(CSOperation operation) {
   Iterator it = operation.getOperands();
   while (it.hasNext()) {
     COSString start = (COSString) it.next();
     COSString end = (COSString) it.next();
     COSInteger destination = (COSInteger) it.next();
     CMapRangeMap map =
         new CMapCIDRangeCodeMap(start.byteValue(), end.byteValue(), destination.intValue());
     addMap(map);
   }
 }
Example #3
0
 @Override
 protected void initializeFromScratch() {
   super.initializeFromScratch();
   cosSetField(DK_Registry, COSString.create("Adobe"));
   cosSetField(DK_Ordering, COSString.create("Identity"));
   cosSetField(DK_Supplement, COSInteger.create(0));
 }
Example #4
0
 /**
  * This method scans the document for all WidgetAnnotation objects.
  *
  * <p>This is done because some writer do not create a correct list of all PDAcroFormField objects
  * in the AcroForm. In the case that the list of children is empty, we go and search ourselves for
  * candidates...
  *
  * @param doc The document to reconstruct.
  */
 protected COSArray reconstruct(PDDocument doc) {
   COSArray result = COSArray.create();
   if (doc == null) {
     return result;
   }
   PDPageTree pageTree = doc.getPageTree();
   if (pageTree == null) {
     return result;
   }
   boolean signatureExists = false;
   for (PDPage page = pageTree.getFirstPage(); page != null; page = page.getNextPage()) {
     List annotations = page.getAnnotations();
     if (annotations == null) {
       continue;
     }
     for (Iterator it = annotations.iterator(); it.hasNext(); ) {
       PDAnnotation annot = (PDAnnotation) it.next();
       if (annot.isWidgetAnnotation()) {
         COSDictionary cosAnnot = annot.cosGetDict();
         result.basicAddSilent(cosAnnot);
         cosAnnot.basicRemoveSilent(PDAcroFormField.DK_Parent);
         signatureExists |= cosAnnot.get(PDAcroFormField.DK_FT).equals(PDAcroFormField.CN_FT_Sig);
       }
     }
   }
   if (signatureExists) {
     int flags = getFieldInt(PDAcroForm.DK_SigFlags, 0);
     flags |= AcroFormSigFlags.Bit_AppendOnly | AcroFormSigFlags.Bit_SignatureExists;
     cosGetDict().basicPutSilent(PDAcroForm.DK_SigFlags, COSInteger.create(flags));
   }
   return result;
 }
Example #5
0
 protected void cosSetSigFlags(int newFlags) {
   if (newFlags != 0) { // default
     cosSetField(DK_SigFlags, COSInteger.create(newFlags));
   } else {
     cosRemoveField(DK_SigFlags);
   }
 }
 public int[] getDashArray() {
   COSArray array = cosGetField(DK_D).asArray();
   if (array != null) {
     int[] result = new int[array.size()];
     for (int i = 0; i < array.size(); i++) {
       COSInteger value = array.get(i).asInteger();
       if (value != null) {
         result[i] = value.intValue();
       } else {
         // TODO 3 wrong default, maybe restrict
         result[i] = 0;
       }
     }
     return result;
   }
   return new int[] {3}; // default
 }
 @Override
 public void attach(STDocument doc) {
   super.attach(doc);
   if (doc == null) {
     return;
   }
   COSEncryption encryption = getEncryption();
   encryption.cosSetField(COSEncryption.DK_Filter, StandardSecurityHandlerFactory.CN_Standard);
   encryption.cosSetField(StandardSecurityHandler.DK_R, COSInteger.create(getRevision()));
   // apply default permissions
   getEncryption().setFieldInt(StandardSecurityHandler.DK_P, DEFAULT_ACCESS_PERMISSIONS);
 }
  public void setDashArray(int[] newDashArray) {
    if ((newDashArray == null) || ((newDashArray.length == 1) && (newDashArray[0] == 3))) {
      cosRemoveField(DK_D);
      return;
    }

    COSArray a = COSArray.create(newDashArray.length);
    cosSetField(DK_D, a); // overwrite existing array

    for (int i = 0; i < newDashArray.length; i++) {
      a.add(COSInteger.create(newDashArray[i]));
    }
  }
 protected void initializeFromScratch() {
   COSEncryption encryption = getEncryption();
   encryption.cosSetField(COSEncryption.DK_V, COSInteger.create(getVersion()));
 }