Package org.jpedal.objects.raw

Examples of org.jpedal.objects.raw.PdfObject


        final boolean debugDest=false;
           
            //aData can either be in top level of Form (as in Annots)
            //or second level (as in A/ /D - this allows for both
            //whoch this routine handles
            PdfObject a2=aData.getDictionary(PdfDictionary.A);
            if(a2!=null)
                aData=a2;
           
            //new page or -1 returned
            int page=-1;
           
        if (showMethods)
                System.out.println("DefaultActionHandler.gotoDest()");
           
            PdfArrayIterator Dest = aData.getMixedArray(PdfDictionary.Dest);
            if (Dest!=null) {
               
                if (eventType == MOUSECLICKED) {
                   
                    //allow for it being an indirect named object and convert if so
                    if(Dest.getTokenCount()==1){
                        //          System.out.println("val="+ Dest.getNextValueAsString(false));
                       
                        String ref=decode_pdf.getIO().convertNameToRef( Dest.getNextValueAsString(false));
                        if(ref!=null){
                           
                            //can be indirect object stored between []
                            if(ref.charAt(0)=='['){
                                if(debugDest)
                                    System.out.println("data for named obj "+ref);
                               
                                byte[] raw=StringUtils.toBytes(ref);
                                //replace char so subroutine works -ignored but used as flag in routine
                                raw[0]= 0;
                               
                                ArrayDecoder objDecoder=new ArrayDecoder(decode_pdf.getIO().getObjectReader(), 0, raw.length, PdfDictionary.VALUE_IS_MIXED_ARRAY,null, PdfDictionary.Names);
                                objDecoder.readArray(false, raw, aData, PdfDictionary.Dest);
                               
                                Dest=aData.getMixedArray(PdfDictionary.Dest);
                               
                            }else{
                                if(debugDest)
                                    System.out.println("convert named obj "+ref);
                               
                                aData=new OutlineObject(ref);
                                decode_pdf.getIO().readObject(aData);
                                Dest=aData.getMixedArray(PdfDictionary.Dest);
                            }
                        }
                    }
                   
                    String filename = aData.getTextStreamValue(PdfDictionary.F);

                    if(filename==null){
                        PdfObject fDic = aData.getDictionary(PdfDictionary.F);
                       
                        if(fDic!=null)
                            filename = fDic.getTextStreamValue(PdfDictionary.F);
                    }
                   
                    //add path if none present
                    if(filename!=null && filename.indexOf('/')==-1 && filename.indexOf('\\')==-1)
                        filename=decode_pdf.getObjectStore().getCurrentFilepath()+filename;
View Full Code Here


    if (showMethods)
        System.out.println("DefaultActionHandler.additionalAction_Signature()");

    if (eventType == MOUSECLICKED) {

            PdfObject sigObject=formObj.getDictionary(PdfDictionary.V);//.getDictionary(PdfDictionary.Sig);

      if (sigObject == null)
        return;

      actionFactory.showSig(sigObject);
View Full Code Here

    //put values back into fields to hide object
    fieldToHide.setFieldArray(fieldstoHide);
    fieldToHide.setHideArray(whethertoHide);
   
    if (aData.getDictionary(PdfDictionary.Next)!=null) {
      PdfObject nextDic = aData.getDictionary(PdfDictionary.Next);
      getHideMap(nextDic, fieldToHide);
    }
  }
View Full Code Here

    init(fontID, renderPage);

    /**
     * get FontDescriptor object - if present contains metrics on glyphs
     */
    PdfObject pdfFontDescriptor=pdfObject.getDictionary(PdfDictionary.FontDescriptor);

    setBoundsAndMatrix(pdfFontDescriptor);

    setName(pdfObject, fontID);
    setEncoding(pdfObject, pdfFontDescriptor);

    if(renderPage){

            if (pdfFontDescriptor!= null && substituteFont==null) {

                byte[] stream=null;
                PdfObject FontFile2=pdfFontDescriptor.getDictionary(PdfDictionary.FontFile2);

                //allowfor wrong type used (see
                if(FontFile2==null)
                    FontFile2=pdfFontDescriptor.getDictionary(PdfDictionary.FontFile);

                if(FontFile2!=null)
                    stream=currentPdfFile.readStream(FontFile2,true,true,false, false,false, FontFile2.getCacheName(currentPdfFile.getObjectReader()));

                if(stream!=null)
                  readEmbeddedFont(stream,null,hasEncoding, false);

      }
View Full Code Here

                               PdfObjectReader currentPdfFile) throws PdfException {

        if (globalResources != null){
            current.readResources(globalResources,true);

            PdfObject propObj=globalResources.getDictionary(PdfDictionary.Properties);
            if(propObj!=null)
                PropertiesObj=propObj;
        }

        /**read the resources for the page*/
        if (Resources != null){
            current.readResources(Resources,true);

            PdfObject propObj=Resources.getDictionary(PdfDictionary.Properties);
            if(propObj!=null)
                PropertiesObj=propObj;
        }

        /**
 
View Full Code Here

        current.setObjectValue(ValueTypes.PdfLayerList,layers);
    }
 
  public PdfObject getPdfObject(int key) {
   
    PdfObject obj=null;
   
    switch(key){

            case AcroFormObj:
                obj=acroFormObj;
View Full Code Here

        final int[] nameLists=new int[]{PdfDictionary.Dests, PdfDictionary.JavaScript};
        int count=nameLists.length;
        if(isKid)
            count=1;

        PdfObject pdfObj;
        PdfArrayIterator namesArray;

        String name,value;

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

            if(isKid)
                pdfObj=nameObject;
            else
                pdfObj=nameObject.getDictionary(nameLists[ii]);

            if(pdfObj==null)
                continue;

            //any kids
            byte[][] kidList = pdfObj.getKeyArray(PdfDictionary.Kids);
            if(kidList!=null){
                int kidCount=kidList.length;

                /** allow for empty value and put next pages in the queue */
                if (kidCount> 0) {

                    for (byte[] aKidList : kidList) {

                        String nextValue = new String(aKidList);

                        PdfObject nextObject = new NamesObject(nextValue);
                        nextObject.ignoreRecursion(false);

                        objectReader.readObject(nextObject);

                        readNames(nextObject, javascript, true);
                    }
View Full Code Here

           PdfFileReader objectReader=currentPdfFile.getObjectReader();
           ObjectDecoder objectDecoder=new ObjectDecoder(currentPdfFile.getObjectReader());

           //read info object (may be defined and object set in different trailers so must be done at end)
           DecryptionFactory decryption=objectReader.getDecryptionObject();
           PdfObject infoObject=objectReader.getInfoObject();
           if(infoObject!=null &&(!(decryption!=null && (decryption.getBooleanValue(PDFflags.IS_FILE_ENCRYPTED) || decryption.getBooleanValue(PDFflags.IS_PASSWORD_SUPPLIED)))))
               readInformationObject(infoObject,objectDecoder);

           //read and set XML value
           if(metadataObj!=null){
View Full Code Here

        if(debug)
          System.out.println("currentKey="+currentKey+ ' ' +keys);
       
        if(buildDirectly){

      PdfObject BDCobj=(PdfObject) dictionaries.get(currentKey);
     
      boolean isBMC=(BDCobj==null);
     
      if(debug)
        System.out.println(isBMC+" "+currentKey+ ' ' +BDCobj+" markedContentSequence="+markedContentSequence);

            //any custom tags
            if(BDCobj!=null){
                Map metadata=BDCobj.getOtherDictionaries();
                if(metadata!=null){
                    Iterator customValues=metadata.keySet().iterator();
                    Object key;
                    while(customValues.hasNext()){
                        key=customValues.next();
                        root.setAttribute(key.toString(), metadata.get(key).toString());

                        //if(addCoordinates){
                            root.setAttribute("x1", String.valueOf((int) x1));
                            root.setAttribute("y1", String.valueOf((int) y1));
                            root.setAttribute("x2", String.valueOf((int) x2));
                            root.setAttribute("y2", String.valueOf((int) y2));
                        //}
                    }
                }
            }
           
      //add node with name for BMC
      if(isBMC){
        if(currentKey!=null){
         
          Node child=doc.createTextNode(stripEscapeChars(markedContentSequence.toString()));
         
          root.appendChild(child);
         
          if(addCoordinates){
            root.setAttribute("x1", String.valueOf((int) x1));
            root.setAttribute("y1", String.valueOf((int) y1));
            root.setAttribute("x2", String.valueOf((int) x2));
            root.setAttribute("y2", String.valueOf((int) y2));
          }

          Node oldRoot=root.getParentNode();
          if(oldRoot instanceof Element)
          root=(Element) oldRoot;
        }
      }else{
        //get root key on dictionary (should only be 1)
        //and create node
        //Iterator keys=dict.keySet().iterator();
        String S="p";//(String) keys.next();
       

                //System.out.println("dict="+BDCobj.getObjectRefAsString());
               
        if(S==null)
          S="p";

        Element tag = doc.createElement(S);
        root.appendChild(tag);
       
        //now add any attributes
                /**
        Map atts=(Map) dict.get(S);
        if(atts==null)
          atts=(Map)dict.get(null);
        Iterator attribKeys=atts.keySet().iterator();
        while(attribKeys.hasNext()){
          String nextAtt=(String) attribKeys.next();
          tag.setAttribute(nextAtt,stripEscapeChars(atts.get(nextAtt)));
        }
        */
        if(addCoordinates){
          tag.setAttribute("x1", String.valueOf((int) x1));
          tag.setAttribute("y1", String.valueOf((int) y1));
          tag.setAttribute("x2", String.valueOf((int) x2));
          tag.setAttribute("y2", String.valueOf((int) y2));
        }
       
       
        //add the text
        Node child=doc.createTextNode(markedContentSequence.toString());
        tag.appendChild(child);
            }

      //reset
      markedContentSequence=new StringBuffer();


        }else{
         
          String ContentSequence = markedContentSequence.toString();
         
          /*if(ContentSequence.indexOf("&amp;")!= -1){
            ContentSequence = ContentSequence.replaceAll("&amp;","&");
          }
         
          if(ContentSequence.indexOf("&lt;")!= -1){
            ContentSequence = ContentSequence.replaceAll("&lt;","<");
            //System.out.print(">>>>>>>>>>>> Temp =="+ContentSequence);
          }
         
          if(ContentSequence.indexOf("&gt;")!= -1){
            ContentSequence = ContentSequence.replaceAll("&gt;",">");
          }

          if(ContentSequence.indexOf("&#")!= -1){
            //convert hex numbers to the char value
          }*/
         
          //System.out.println(currentKey+" "+markedContentSequence);
            if(debug)
              System.out.println("write out "+currentKey+" text="+markedContentSequence+ '<');
           
            PdfObject BDCobj=(PdfObject) (dictionaries.get(String.valueOf(markedContentLevel)));
           
           // System.out.println("BDCobj="+BDCobj+" currentKey="+currentKey);
           
          
            //reset on MCID tag
            int MCID=-1;
            if(BDCobj!=null)
              MCID=BDCobj.getInt(PdfDictionary.MCID);
           
            if(MCID!=-1){
              values.put(String.valueOf(MCID),ContentSequence);
              //System.out.println(MCID+" "+ContentSequence);
                markedContentSequence=new StringBuffer();
View Full Code Here

            if(objData!=null){

                int size=objData.length;
                if(objData[size-1]=='R'){

                    PdfObject obj=new PdfObject(new String(objData));
                    byte[] newData=objectReader.readObjectData(obj);

                    if(newData!=null){

                        int jj=0,newLen=newData.length;
View Full Code Here

TOP

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

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.