Package org.jpedal.objects.raw

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


           //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

        // 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

        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

    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

        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

                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

    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

      Map forms = compData.getRawFormData();

      //if some forms exist iterate over them
      if(forms.size()>1){
        Iterator formsIter = forms.keySet().iterator();
        FormObject form;
        while(formsIter.hasNext()){
          form = (FormObject) forms.get(formsIter.next());
          if (form != null){
           
            //check to see if the text color has changed
            if(form.hasColorChanged()){
              //update to the new color
              compData.setTextColor(form.getObjectRefAsString(), form.getTextColor());
              compData.invalidate(form.getTextStreamValue(PdfDictionary.T));
             
              // reset color changed, so we dant do it again unless needed
              form.resetColorChanged();
            }

            // if the form has changed reload the values into the display object
            if(form.hasValueChanged()){
            //dont set unformatted value here
            String objRef = form.getObjectRefAsString();
            compData.setUnformattedValue(objRef, compData.getValue(objRef));
            //dont set the last valid value as were not sure if it is valid
           
            //change the values within the componentData
            compData.setValue(form.getObjectRefAsString(), form.getValue(), false, false);

               
                      compData.invalidate(form.getTextStreamValue(PdfDictionary.T));

                        // reset values changed so we dant do it again unless needed
              form.resetFormChanged();
            }

          //check to see if the display has chnaged
            if(form.hasDisplayChanged()){

              boolean[] characteristic = form.getCharacteristics();
              //check if the form should be hidden, or shown now
                  if (characteristic[0] || characteristic[1] || characteristic[5]) {
                      compData.setCompVisible(form.getObjectRefAsString(),false);
                  }else {
                    compData.setCompVisible(form.getObjectRefAsString(),true);
                  }
            }
          }
        }
      }
View Full Code Here

        //rearrange heap into a sorted array
        while (right > 0) {

            //assert: largest unsorted value is at a[0]
            //move largest item to right end
          FormObject tempA = array[0];
            array[0] = array[right];
            array[right] = tempA;
            //assert: a[right..] is sorted

            //right is largest and sorted decrement it
View Full Code Here

TOP

Related Classes of org.jpedal.objects.raw.FormObject

Copyright © 2018 www.massapicom. 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.