Package org.jpedal.objects.raw

Examples of org.jpedal.objects.raw.PdfObject


        if(!mouseClicked)
          return;

        //FS obj contains an EF obj which contains an F obj with the data in
        //F can be various - we are only interested in it as a Dictionary with a stream
        PdfObject EFobj=null, FSobj=annotObj.getDictionary(PdfDictionary.FS);
        if(FSobj!=null)
          EFobj=FSobj.getDictionary(PdfDictionary.EF);

        /**
         * create the file chooser to select the file name
         **/
        JFileChooser chooser = new JFileChooser(commonValues.getInputDir());
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        int state = chooser.showSaveDialog(currentGUI.getFrame());


        /**
         * save file and take the hit
         */
        if(state==0){
          File fileTarget = chooser.getSelectedFile();

          //here is where we take the hit (Only needed if on lazy init - ie Unread Dictionary like EF)....     
          if(EFobj!=null)
            pdfObjectReader.checkResolved(EFobj);

          //contains the actual file data
          PdfObject Fobj=EFobj.getDictionary(PdfDictionary.F);

          //see if cached or decoded (cached if LARGE)
          //IMPORTANT NOTE!!! - if the object is in a compressed stream (a 'blob' of
          //objects which we need to read in one go, it will not be cached
          String nameOnDisk=Fobj.getCachedStreamFile(pdfObjectReader.getObjectReader());

          //if you get null, make sure you have enabled caching and
          //file is bigger than cache
          System.out.println("file="+nameOnDisk);

          if(nameOnDisk!=null){ //just copy
            ObjectStore.copy(nameOnDisk,fileTarget.toString());
          }else{ //save out
            byte[] fileData=Fobj.getDecodedStream();

            if(fileData!=null){ //write out if in memory
              FileOutputStream fos;
              try {
                fos = new FileOutputStream(fileTarget);
View Full Code Here


    cachedValue=new String[65536];

        String CMapName=null;

    /**read encoding values*/
    PdfObject Encoding=pdfObject.getDictionary(PdfDictionary.Encoding);
    if(Encoding!=null)
    CMapName=handleCIDEncoding(Encoding);

    //handle to unicode mapping
    PdfObject ToUnicode=pdfObject.getDictionary(PdfDictionary.ToUnicode);
    if(ToUnicode!=null)
            unicodeMappings=new UnicodeReader(currentPdfFile.readStream(ToUnicode,true,true,false, false,false, ToUnicode.getCacheName(currentPdfFile.getObjectReader()))).readUnicode();

        /**read widths*/
    //@speed may need optimising - done as string for moment
    String widths=Descendent.getName(PdfDictionary.W);

        //allow for vertical
        String verticalWidths=Descendent.getName(PdfDictionary.W2);
        if(verticalWidths!=null){
            widths=verticalWidths;
        }
       
    if(widths!=null)
      setCIDFontWidths(widths);

    /**set default width*/
    int Width=Descendent.getInt(PdfDictionary.DW);
    if(Width>=0)
      defaultWidth=(Width)/1000f;

    /**set CIDtoGIDMap*/
    PdfObject CIDToGID=Descendent.getDictionary(PdfDictionary.CIDToGIDMap);
    if(CIDToGID!=null){
      byte[] stream=currentPdfFile.readStream(CIDToGID,true,true,false, false,false, null);

            if(stream!=null){

        int j=0,count=stream.length;
        int[] CIDToGIDMap=new int[count/2];
        for(int i=0;i<count;i=i+2){
          CIDToGIDMap[j]= (((stream[i] & 255)<<8)+(stream[i+1] & 255));
          j++;
        }
        glyphs.setGIDtoCID(CIDToGIDMap);
      }else{ // must be identity

        //only set if not also a /value
                if(CIDToGID.getParameterConstant(PdfDictionary.CIDToGIDMap)==PdfDictionary.Unknown)
          CMapName=handleCIDEncoding(new FontObject(PdfDictionary.Identity_H));
      }
    }

        //@sam-fonts
        //code is unfinished by MArk - I was originally going to map onto font in
        //cid.jar but now think that is wrong
        //
        //Needs researching and doing properly

    String ordering=null;
    PdfObject CIDSystemInfo=Descendent.getDictionary(PdfDictionary.CIDSystemInfo);
    if(CIDSystemInfo!=null)
      ordering=CIDSystemInfo.getTextStreamValue(PdfDictionary.Ordering);

    if(ordering!=null){
      if(CIDToGID==null && ordering.contains("Identity")){

                if(CMapName!=null && !CMapName.equals("Generic"))
            isDoubleByte=true;

      }else if(ordering.contains("Japan")){

        substituteFontFile="kochi-mincho.ttf";
        substituteFontName="Kochi Mincho";

        this.TTstreamisCID=false;

      }else if(ordering.contains("Korean")){
        System.err.println("Unsupported font encoding "+ordering);

      }else if(ordering.contains("Chinese")){
        System.err.println("Chinese "+ordering);
      }else if(ordering.equals("Identity")){
                glyphs.setIsIdentity(true);
            }

      if(substituteFontName!=null && LogWriter.isOutput())
      LogWriter.writeLog("Using font "+substituteFontName+" for "+ordering);

    }

    /**set other values*/
    if (Descendent != null) {

      PdfObject FontDescriptor = Descendent.getDictionary(PdfDictionary.FontDescriptor);

      /**read other info*/
      if(FontDescriptor!=null) {
        setBoundsAndMatrix(FontDescriptor);
        setName( FontDescriptor, fontID);
View Full Code Here

        init(fontID, renderPage);

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

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

  }
View Full Code Here

  protected void setEncoding(PdfObject pdfObject, PdfObject pdfFontDescriptor) {


    //handle to unicode mapping
    PdfObject ToUnicode=pdfObject.getDictionary(PdfDictionary.ToUnicode);

        if(ToUnicode!=null)
            unicodeMappings=new UnicodeReader(currentPdfFile.readStream(ToUnicode,true,true,false, false,false, ToUnicode.getCacheName(currentPdfFile.getObjectReader()))).readUnicode();

    //handle encoding
    PdfObject Encoding=pdfObject.getDictionary(PdfDictionary.Encoding);
   
    if (Encoding != null)
      handleFontEncoding(pdfObject,Encoding);
    else
        handleNoEncoding(0,pdfObject);
View Full Code Here

  public void createFont(PdfObject pdfObject, String fontID, boolean renderPage, ObjectStore objectStore, Map substitutedFonts) throws Exception{

    fontTypes=StandardFonts.CIDTYPE0;
    this.fontID=fontID;
   
    PdfObject Descendent=pdfObject.getDictionary(PdfDictionary.DescendantFonts);
        PdfObject pdfFontDescriptor=Descendent.getDictionary(PdfDictionary.FontDescriptor);
      
        createCIDFont(pdfObject,Descendent);

       
    if (pdfFontDescriptor!= null){

//            /**CIDSet*/
//            PdfObject CIDSet=pdfFontDescriptor.getDictionary(PdfDictionary.CIDSet);
//            System.out.println(pdfObject.getObjectRefAsString()+" "+Descendent.getObjectRefAsString());
//            if(CIDSet!=null && 1==2){
//
//                int[] bitCheck={128,64,32,16,8,4,2,1};
//                int cidReached=0;
//
//                int cidCount=CIDSet.stream.length;
//                int hits=0;
//
//                for(int ptr=0;ptr<cidCount;ptr++){
//
//                    byte pixelByte=CIDSet.stream[ptr];
//
//                    for(int bits=0;bits<8;bits++){
//
//                        //System.out.println("cid="+cidReached+" "+bits+" "+ptr);
//
//                        int bitUsed=ptr & 7;
//
//                        //if set we need to set in second array, set pixel in new array as y,x
//                        if((pixelByte & bitCheck[bitUsed])== bitCheck[bitUsed]){
//
//                            hits++;
//
//                            System.out.println(cidReached+" XX="+hits);
//                        }
//
//                        cidReached++;
//                    }
//                }
//
//                System.out.println("length="+(CIDSet.stream.length));
//
//            }length

            float[] newFontBBox=pdfFontDescriptor.getFloatArray(PdfDictionary.FontBBox);
            if(newFontBBox!=null)
            FontBBox=newFontBBox;
           
      readEmbeddedFont(pdfFontDescriptor);
    }
View Full Code Here

    init(fontID, renderPage);
   
    /**
     * get FontDescriptor object - if present contains metrics on glyphs
     */
    PdfObject pdfFontDescriptor=pdfObject.getDictionary(PdfDictionary.FontDescriptor);
   
    // get any dimensions if present (note FBoundBox if in pdfObject not Descriptor)
    setBoundsAndMatrix(pdfObject);
   
    setName(pdfObject, fontID);
View Full Code Here

        final boolean hires=true;
       
        int key,otherKey;

        PdfObject CharProcs=pdfObject.getDictionary(PdfDictionary.CharProcs);

        //handle type 3 charProcs and store for later lookup
        if(CharProcs!=null){

            T3StreamDecoder glyphDecoder=new T3StreamDecoder(currentPdfFile,hires, isPrinting);
            glyphDecoder.setParameters(false,true,7,0);

            glyphDecoder.setObjectValue(ValueTypes.ObjectStore, objectStore);

            PdfObject Resources=pdfObject.getDictionary(PdfDictionary.Resources);
            if(Resources!=null){
                try {
                    glyphDecoder.readResources(Resources,false);
                } catch (PdfException e2) {
                    e2.printStackTrace();
                }
            }

            /**
             * read all the key pairs for Glyphs
             */
            PdfKeyPairsIterator keyPairs=CharProcs.getKeyPairsIterator();

            String glyphKey,pKey;
            PdfObject glyphObj;
           
            while(keyPairs.hasMorePairs()){

                glyphKey=keyPairs.getNextKeyAsString();               
                glyphObj=keyPairs.getNextValueAsDictionary();
View Full Code Here

  public void createFont(PdfObject pdfObject, String fontID, boolean renderPage, ObjectStore objectStore, Map substitutedFonts) throws Exception{

    fontTypes=StandardFonts.CIDTYPE2;
    this.fontID=fontID;
   
    PdfObject Descendent=pdfObject.getDictionary(PdfDictionary.DescendantFonts);
        PdfObject pdfFontDescriptor=Descendent.getDictionary(PdfDictionary.FontDescriptor);

    createCIDFont(pdfObject,Descendent);

    if (pdfFontDescriptor!= null) {

            byte[] stream;
            PdfObject FontFile2=pdfFontDescriptor.getDictionary(PdfDictionary.FontFile2);
            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

   * @return boolean true if it all worked.
   */
  public boolean decipherAppObject(FormObject form) {
    //read the command from file if there is one
    String fontStr="";
    PdfObject appObj = form.getDictionary(PdfDictionary.AP).getDictionary(PdfDictionary.N);
    if(appObj!=null){
      byte[] bytes = appObj.getDecodedStream();
     
     
      if(bytes!=null){
        int startTf=-1, endTf=-1, startTj=-1, endTj=-1, end=bytes.length;
       
View Full Code Here

        int from;
        int to;
        boolean valid = false;

        public SrcPosition(FormObject arg1) {
            PdfObject A = arg1.getDictionary(PdfDictionary.A);
            try {
                if (A != null) {
                    String url = (String) A.getTextStreamValue(PdfDictionary.URI);
                    int pos = url.lastIndexOf(".ly");
                    pos = url.indexOf(":", pos);
                    int pos2 = url.indexOf(":", pos + 1);
                    line = Integer.parseInt(url.substring(pos + 1, pos2));
                    pos = pos2;
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.