Examples of FormObject


Examples of org.jpedal.objects.raw.FormObject

            preName = formObject.substring(formObject.indexOf('.') + 1,
                formObject.indexOf(".x") + 1);
          }
          if (formObject.contains(" R")) {

                       FormObject formObj=new FormObject(formObject);
                       currentPdfFile.readObject(formObj);


                        tok=formObj.getTextStreamValue(PdfDictionary.T);
                           if (preName != null) {
              names.append(preName);
            }
            names.append(tok);
            names.append(',');
View Full Code Here

Examples of org.jpedal.objects.raw.FormObject

     * @return page number or -1 if no page found
     */
    public int getPageForFormObject(String formName) {

        //Object checkObj;
        FormObject formObj=null;

    if (formName.contains("R")) {
    //  checkObj = refToCompIndex.get(formName);
            formObj = ((FormObject)rawFormData.get(formName));

    }else {
    //  checkObj = nameToCompIndex.get(formName);
            String ref= (String) nameToRef.get(formName);
            if(ref!=null)
            formObj = ((FormObject)rawFormData.get(ref));

    }

        if(formObj == null)
      return -1;
        else
            return formObj.getPageNumber();

  }
View Full Code Here

Examples of org.jpedal.objects.raw.FormObject

        // get correct key to lookup form data
        String ref = this.convertIDtoRef(currentComp);


        //System.out.println(currentComp+" "+comp.getLocation()+" "+comp);
        FormObject form = (FormObject) ((Object[])getRawForm(ref))[0];

        if(form!=null){
            return componentsToIgnore!=null &&
                    (componentsToIgnore.containsKey(form.getParameterConstant(PdfDictionary.Subtype)) ||
            componentsToIgnore.containsKey(form.getParameterConstant(PdfDictionary.Type)));

        }else
            return false;
    }
View Full Code Here

Examples of org.jpedal.objects.raw.FormObject

           //allow for indirect
           while(FfieldCount==1){

                String key=fieldList.getNextValueAsString(false);

                FormObject kidObject = new FormObject(key,formsActionHandler);
                currentPdfFile.readObject(kidObject);

                byte[][] childList =getKid(kidObject);

                if(childList==null)
View Full Code Here

Examples of org.jpedal.objects.raw.FormObject

        // if no name, or parent has one recursively scan tree for one in Parent
        boolean isMultiple=false;
        String fullyQualName=null;

        while (parent != null && !parent.equals(ref)) {
            FormObject parentObj;
                {
                //parent.indexOf(" R")!=-1
                parentObj =new FormObject(parent,false);
                pdfDecoder.getIO().readObject(parentObj);
            }

//parentObj is null in mixedForms.pdf
            String newName = null;
            if(parentObj!=null)
                newName = parentObj.getTextStreamValue(PdfDictionary.T);
            if (newName == null)
                break;
            else if (fieldName!=null){
                //we pass in kids data so stop name.name
                if(!fieldName.contains(newName)) {
                    fullyQualName = newName + '.' + fieldName.substring(fieldName.lastIndexOf('.')+1);
                    isMultiple=true;
                }
            }

            parent = parentObj.getParentRef();
        }

        //set the field name to be the Fully Qualified Name
        if(isMultiple)
            fullyQualToRef.put(fullyQualName, ref);
View Full Code Here

Examples of org.jpedal.objects.raw.FormObject

        Acount=AfieldCount[page];

      Fforms = new FormObject[FfieldCount];
      FormObject[] xfaFormList = null;
      Aforms = new FormObject[Acount];
      FormObject formObject;
      String objRef;
      int i, count;

      //scan list for all relevant values and add to array if valid
      //0 = xfa, 1 = forms, 2 = annots
      int decodeToForm = 2;
      for(int forms=0;forms<decodeToForm;forms++){

        i=0;

        if(forms==0){
          count=0;
          if(fieldList!=null){
            fieldList.resetToStart();
            count=fieldList.getTokenCount()-1;
          }

        }else{
          if(annotList!=null && annotList.length>page && annotList[page]!=null){
            annotList[page].resetToStart();

                        //create lookup and array for values to set order correctly in HTML
                        if(formFactory.getType()==FormFactory.HTML){
                            Map annotOrder=new HashMap();

                            int count2=annotList[page].getTokenCount();
                            String val;
                            for(int ii=0;ii<count2;ii++){
                                val=annotList[page].getNextValueAsString(true);
                                annotOrder.put(val,String.valueOf(ii+1));
                            }

                            formFactory.setAnnotOrder(annotOrder);
                        }


                        annotList[page].resetToStart();
                    }
          count=Acount-1;
        }

        for (int fieldNum =count; fieldNum >-1; fieldNum--) {

          objRef=null;

          if(forms==0){
            if(fieldList!=null)
              objRef=fieldList.getNextValueAsString(true);
          }else{
            if(annotList.length>page && annotList[page]!=null)
              objRef=annotList[page].getNextValueAsString(true);

          }

          if(objRef==null || (objRef!=null && (formsProcessed.get(objRef)!=null || objRef.length()==0)))
            continue;

          formObject= (FormObject) cachedObjs.get(objRef);
          if(formObject==null){

            formObject = new FormObject(objRef,formsActionHandler,pageData.getRotation(page-1));
            //formObject.setPDFRef((String)objRef);

            if(objRef.charAt(objRef.length()-1)=='R'){
              currentPdfFile.readObject(formObject);
            }else{

              //changed by Mark as cover <<>> as well as 1 0 R
              formObject.setStatus(PdfObject.UNDECODED_REF);
              formObject.setUnresolvedData(StringUtils.toBytes(objRef),id);
              currentPdfFile.checkResolved(formObject);
            }

            cachedObjs.put(objRef,formObject);
          }

          byte[][] kids=formObject.getKeyArray(PdfDictionary.Kids);
          if(kids!=null) //not 'proper' kids so process here
            i = flattenKids(page, debugNew, formsProcessed, formObject, i, forms);
          else
            i = processFormObject(page, debugNew, formsProcessed, formObject, objRef, i, forms);
        }
      }

      /**
       * process XFA FORMS and add in values
       */
      if (hasXFA && fDecoder.hasXFADataSet()) {
        currentItems.clear();

        //needs reversing
        ///Users/markee/Downloads/write_test16_pdfform.pdf
        int size=Fforms.length;
        FormObject[] tmp=new FormObject[size];
        for(int ii=0;ii<size;ii++)
          tmp[ii]=Fforms[size-ii-1];

        xfaFormList = ((XFAFormStream) fDecoder).createAppearanceString(tmp);

        compData.storeXFARefToForm(((XFAFormStream)fDecoder).getRefToFormArray());

      }

      List unsortedForms= new ArrayList();
      compData.setUnsortedListForPage(page,unsortedForms);

      //XFA, FDF FORMS then ANNOTS
      int readToForm = 3;
      for(int forms=0;forms<readToForm;forms++){

        count=0;

        if(forms==0){
          if(xfaFormList!=null)
            count=xfaFormList.length;
        }else if(forms==1){
          //store current order of forms for printing
                    for (FormObject Fform : Fforms) {
                        if (Fform != null)
                            unsortedForms.add(Fform.getObjectRefAsString());
                    }

          //sort forms into size order for display
          Fforms = FormUtils.sortGroupLargestFirst(Fforms);
          count=Fforms.length;
        }else{
          //store current order of forms for printing
                    for (FormObject Aform : Aforms) {
                        if (Aform != null)
                            unsortedForms.add(Aform.getObjectRefAsString());
                    }

          //sort forms into size order for display
          Aforms = FormUtils.sortGroupLargestFirst(Aforms);
          count=Aforms.length;
        }

        for (int k = 0; k <count; k++) {

          if(forms==0)
            formObject = xfaFormList[k];
          else if(forms==1)
            formObject = Fforms[k];
          else
            formObject =Aforms[k];

          if (formObject != null && (formsCreated.get(formObject.getObjectRefAsString())==null) && page==formObject.getPageNumber()){// && !formObject.getObjectRefAsString().equals("216 0 R")){
            //String OEPROPval=formObject.getTextStreamValue(PdfDictionary.EOPROPtype);
            //NOTE: if this custom form needs redrawing more change ReadOnlyTextIcon.MAXSCALEFACTOR to 1;
            if(formsRasterizedForDisplay() && current!=null){// || OEPROPval!=null){
   
                            //rasterize any flattened PDF forms here
                            try {
                                current.drawFlattenedForm(formObject);
                            }catch( PdfException e ){
                                e.printStackTrace();
                            }
                           
            }else {
              createField(formObject, compData.getNextFreeField()); //now we turn the data into a Swing component
              //set the raw data here so that the field names are the fully qualified names
              compData.storeRawData(formObject); //store data so user can access

              formsCreated.put(formObject.getObjectRefAsString(), "x");
            }
          }
        }
      }

View Full Code Here

Examples of org.jpedal.objects.raw.FormObject

    if(checkObj==null)
      return null;
   
    // Now set the formObject value so we keep track of the current field value within our FormObject
    String pdfRef = convertIDtoRef(((Integer)checkObj).intValue());
    FormObject form = ((FormObject)rawFormData.get(pdfRef));
//    System.out.println("ComponentData.setValue("+ref+" formvalue="+value+")");
    form.setValue((String)value);
   
    return checkObj;
  }
View Full Code Here

Examples of org.jpedal.objects.raw.FormObject

        for (byte[] aKidList : kidList) { //iterate through all parts

            String key = new String(aKidList);

            //now we have inherited values, read
            FormObject childObj = new FormObject(key, null);

            //inherit values
            if (formObject != null)
                childObj.copyInheritedValuesFromParent(formObject);

            currentPdfFile.readObject(childObj);
            //childObj.setPDFRef(key);


            childObj.setHandler(formsActionHandler);
            childObj.setRef(key);

            //flag its a kid so we can align value sif needed
            childObj.setKid(true);

            if (childObj.getKeyArray(PdfDictionary.Kids) == null) {

                //test and then test with it commented out
                //check space not filled
                Object rectTocheck = childObj.toString(childObj.getFloatArray(PdfDictionary.Rect), true);
                if (rectTocheck != null && !addItem(rectTocheck)) {

                } else {
                    new FormStream().createAppearanceString(childObj, currentPdfFile);
                }
View Full Code Here

Examples of org.jpedal.objects.raw.FormObject

                if (hasKids) {

                    int kidCount=kidList.length;

                    FormObject kidObject;
                    for(int jj=0;jj<kidCount;jj++){
                        String key=new String(kidList[jj]);

                        kidObject= (FormObject) cachedObjs.get(key);

                        if(kidObject==null){
                            kidObject = new FormObject(key,formsActionHandler);
                            //kidObject.setPageNumber(page);
                            //kidObject.setPDFRef((String)key);
                            currentPdfFile.readObject(kidObject);

                            cachedObjs.put(key, kidObject);

                        }

                        pageObj=kidObject.getDictionary(PdfDictionary.P);

                        if(pageObj!=null)
                            pageRef=pageObj.getUnresolvedData();

                        if(pageRef!=null)
                            jj=kidCount;
                    }
                }
            }

            int objPage=-1;
            if(pageRef!=null)
                objPage=currentPdfFile.convertObjectToPageNumber(new String(pageRef));

            isOnPage=objPage==page;

        }

        if(forms==1 || isOnPage){


            //if(objRef!=null && objRef.equals("48 0 R"))
              //              System.out.println("c "+forms+" "+isOnPage);

          //code to read the page number from the P (page) object of the form, but it is wrong.
//          PdfObject pageObj = formObject.getDictionary(PdfDictionary.P);
//          if(pageObj!=null){
//            String pageObjRef = pageObj.getObjectRefAsString();
//            int formPage = decode_pdf.getPageFromObjectRef(pageObjRef);
//            if(formPage==-1)
//              formObject.setPageNumber(page);
//            else
//              formObject.setPageNumber(formPage);
//          }else
            formObject.setPageNumber(page);

            //lose from cache
            cachedObjs.remove(objRef);

            String parent=formObject.getStringKey(PdfDictionary.Parent);

            //clone parent to allow inheritance of values or create new
            if(parent!=null){
                FormObject parentObj = getParent(parent);

                //inherited values
                if(parentObj!=null){
                  //all values are copied from the parent inside this call
                    formObject.setParent(parent,parentObj,true);
View Full Code Here

Examples of org.jpedal.objects.raw.FormObject

    private FormObject getParent(String parent) {

        Map objects=compData.getRawFormData();

        FormObject parentObj;
        parentObj=(FormObject)objects.get(parent);

        if(parentObj==null && parent!=null){ //not yet read so read and cache
            parentObj = new FormObject(parent,formsActionHandler);
            currentPdfFile.readObject(parentObj);

            //remove kids in Parent
            parentObj.setKeyArray(PdfDictionary.Kids,new byte[][]{{0}});

            objects.put(parent, parentObj);

        }
        return parentObj;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.