Package org.jpedal.objects.raw

Examples of org.jpedal.objects.raw.PdfObject


        this.currentTextState=currentTextState;

        switch(commandID){

            case Cmd.BDC :
                PdfObject BDCobj=BDC(startCommand,  dataPointer, parser.getStream(),
                        parser.generateOpAsString(0, false),layerDecoder,gs, currentPdfFile, current,markedContentExtracted);

                //track setting and use in preference for text extraction
                actualText=BDCobj.getTextStreamValue(PdfDictionary.ActualText);

                break;

            case Cmd.BMC :
                layerDecoder.BMC();
View Full Code Here


    }

    private static PdfObject BDC(int startCommand, int dataPointer,byte[] raw,String op, LayerDecoder layerDecoder,
                          GraphicsState gs,PdfObjectReader currentPdfFile,DynamicVectorRenderer current, boolean markedContentExtracted) {

        PdfObject BDCobj=new MCObject(op);
        BDCobj.setID(PdfDictionary.BDC); //use an existing feature to add unknown tags

        int rawStart=startCommand;

        if(startCommand<1)
            startCommand=1;
View Full Code Here

    processColorToken(currentPdfFile, colorSpace);
  }

  protected void processColorToken(PdfObjectReader currentPdfFile, PdfObject colorSpace) {

        PdfObject indexed=colorSpace.getDictionary(PdfDictionary.Indexed);
        PdfObject functionObj=colorSpace.getDictionary(PdfDictionary.tintTransform);

    domain = null;

        if(colorSpace.getDictionary(PdfDictionary.Process)!=null)
            isProcess=true;

    //name of color if separation or Components if device and component count
    byte[] name=null;
    byte[][] components=null;
    if(value==ColorSpaces.Separation){
      name=colorSpace.getStringValueAsByte(PdfDictionary.Name);

            if(name!=null)
            components=new byte[][]{name};
      componentCount=1;
    }else{
      components=colorSpace.getStringArray(PdfDictionary.Components);
      componentCount=components.length;
    }

    //test values

    cmykMapping=NOCMYK;

        int[] values=new int[componentCount];
        if(components!=null){
            for(int ii=0;ii<componentCount;ii++){
                values[ii]=PdfDictionary.generateChecksum(1, components[ii].length-1, components[ii]);
            }
        }

        switch(componentCount){

            case 1:
                if(components!=null && (values[0]==Black || values[0]==PANTONE_BLACK)){
                    cmykMapping=Black;
                }

                break;

            case 2:

                if(values[0]==Cyan){
                    if(values[1]==Yellow)
                        cmykMapping=CY;
                    else if(values[1]==Magenta)
                        cmykMapping=CM;
                }else if(values[0]==Magenta && values[1]==Yellow)
                    cmykMapping=MY;

                break;

            case 3:

                if(values[0]==Magenta && values[1]==Yellow && values[2]==Black)
                    cmykMapping=MYK;
                else if(values[0]==Cyan && values[1]==Magenta && values[2]==Yellow)
                    cmykMapping=CMY;
                else if(values[0]==Cyan && values[1]==Magenta && values[2]==Black)
                    cmykMapping=CMK;
                break;

            case 4:

                if(values[0]==Cyan && values[1]==Magenta && values[2]==Yellow && values[3]==Black)
                    cmykMapping=CMYB;
                break;

            case 6:

                if(values[0]==Cyan && values[1]==Magenta && values[2]==Yellow && values[3]==Black)
                    cmykMapping=CMYK;
                break;
        }

    //hard-code myk and cmy
    if(cmykMapping!=NOCMYK){

      altCS=new DeviceCMYKColorSpace();

    }else{

      /**
       * work out colorspace (can also be direct ie /Pattern)
       */
      colorSpace=colorSpace.getDictionary(PdfDictionary.AlternateSpace);

            //System.out.println("Set uncached AlCS "+colorSpace.getObjectRefAsString()+" "+this);
            altCS =ColorspaceFactory.getColorSpaceInstance(currentPdfFile, colorSpace);

            //use alternate as preference if CMYK
            if(altCS.getID()==ColorSpaces.ICC && colorSpace.getParameterConstant(PdfDictionary.Alternate)==ColorSpaces.DeviceCMYK)
                altCS=new DeviceCMYKColorSpace();


    }

    if(name!=null){
      int len=name.length,jj=0,topHex,bottomHex;
      byte[] tempName=new byte[len];
      for(int i=0;i<len;i++){
        if(name[i]=='#'){
          //roll on past #
          i++;

          topHex=name[i];

          //convert to number
          if(topHex>='A' && topHex<='F')
            topHex = topHex - 55
          else if(topHex>='a' && topHex<='f')
            topHex = topHex - 87;
          else if(topHex>='0' && topHex<='9')
            topHex = topHex - 48;

          i++;

          while(name[i]==32 || name[i]==10 || name[i]==13)
            i++;

          bottomHex=name[i];

          if(bottomHex>='A' && bottomHex<='F')
            bottomHex = bottomHex - 55
          else if(bottomHex>='a' && bottomHex<='f')
            bottomHex = bottomHex - 87;
          else if(bottomHex>='0' && bottomHex<='9')
            bottomHex = bottomHex - 48;

          tempName[jj]=(byte) (bottomHex+(topHex<<4));
        }else{
          tempName[jj]=name[i];
        }

        jj++;
      }

      //resize
      if(jj!=len){
        name=new byte[jj];
        System.arraycopy(tempName, 0, name, 0, jj);

      }

      pantoneName=new String(name);
    }

    /**
     * setup transformation
     **/
        if(functionObj==null)
            colorSpace.getDictionary(PdfDictionary.tintTransform);

        if(functionObj==null && indexed!=null)
            functionObj=indexed.getDictionary(PdfDictionary.tintTransform);

    colorMapper=new ColorMapping(currentPdfFile,functionObj);
    domain=functionObj.getFloatArray(PdfDictionary.Domain);

  }
View Full Code Here

                                     AcroRenderer formRenderer, float scaling, PdfObjectReader currentPdfFile, int pageIndex,
                                     boolean imageIsTransparent,
                                     String currentPageOffset) throws PdfException {

        /** read page or next pages */
        PdfObject pdfObject=new PageObject(currentPageOffset);
        currentPdfFile.readObject(pdfObject);

        BufferedImage image;
        Graphics2D g2;

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

        ObjectStore localStore = new ObjectStore();
        DynamicVectorRenderer imageDisplay = new ImageDisplay(pageIndex,false, 5000, localStore);

        PdfStreamDecoder currentImageDecoder = new PdfStreamDecoder(currentPdfFile);
View Full Code Here

        boolean isStroke = !isLowerCase;

        /**
         * work out colorspace
         */
        PdfObject ColorSpace=(PdfObject)cache.get(PdfObjectCache.Colorspaces,colorspaceObject);

        if(ColorSpace==null)
            ColorSpace=new ColorSpaceObject(StringUtils.toBytes(colorspaceObject));

        String ref=ColorSpace.getObjectRefAsString(), ref2=ref+ '-'+isLowerCase;

        GenericColorSpace newColorSpace;

        //(ms) 20090430 new code does not work so commented out

View Full Code Here

                byte[] decodeByteData= (byte[]) DecodeParmsArray[i];

                if(decodeByteData!=null){
                    String key= new String(decodeByteData);

                    PdfObject DecodeParms=new DecodeParmsObject(key);

                    if(decodeByteData[0]=='<')
                        DecodeParms.setStatus(PdfObject.UNDECODED_DIRECT);
                    else
                        DecodeParms.setStatus(PdfObject.UNDECODED_REF);

                    //must be done AFTER setStatus()
                    DecodeParms.setUnresolvedData(decodeByteData, PdfDictionary.DecodeParms);
                    ObjectDecoder objDecoder=new ObjectDecoder(objReader);
                    objDecoder.checkResolved(DecodeParms);

                    decodeParmsValues[i]=DecodeParms;
                }else
View Full Code Here

                name = BDCobj.getName(PdfDictionary.OC);

                //see if Layer defined and get title if no Name as alternative
                if(name==null){

                    PdfObject layerObj=BDCobj.getDictionary(PdfDictionary.Layer);
                    if(layerObj!=null)
                        name=layerObj.getTextStreamValue(PdfDictionary.Title);
                }

                //needed to flags its a BMC
                layerClips.put(layerLevel,null);
View Full Code Here

        this.currentPdfFile=currentPdfFile;

        if(PropertiesObj!=null)
            setupOCMaps(PropertiesObj, currentPdfFile);

        PdfObject layerDict=OCProperties.getDictionary(PdfDictionary.D);

        if(layerDict==null)
        return;

        int OCBaseState=layerDict.getNameAsConstant(PdfDictionary.BaseState);

        //if not set use default
        if(OCBaseState== PdfDictionary.Unknown)
        OCBaseState= PdfDictionary.ON;

        //read order first and may be over-written by ON/OFF
        order=layerDict.getObjectArray(PdfDictionary.Order);

        if(debug){
            System.out.println("PropertiesObj="+PropertiesObj);
            System.out.println("layerDict="+layerDict);
            System.out.println("propertyMap="+propertyMap);
            System.out.println("propertyMap="+propertyMap);
            System.out.println("refToPropertyID="+refToPropertyID);
            System.out.println("refTolayerName="+refTolayerName);

            System.out.println("OCBaseState="+OCBaseState+" (ON="+ PdfDictionary.ON+ ')');


            System.out.println("order="+order);

            showValues("ON=",PdfDictionary.ON,layerDict);

            showValues("OFF=",PdfDictionary.OFF,layerDict);

            showValues("RBGroups=",PdfDictionary.RBGroups,layerDict);

        }
        /**
         * workout list of layers (can be in several places)
         */

        addLayer(OCBaseState, order,null);

        //read the ON and OFF values
        if(OCBaseState!=PdfDictionary.ON) //redundant if basestate on
            addLayer(PdfDictionary.ON, layerDict.getKeyArray(PdfDictionary.ON),null);

        if(OCBaseState!=PdfDictionary.OFF) //redundant if basestate off
            addLayer(PdfDictionary.OFF, layerDict.getKeyArray(PdfDictionary.OFF), null);

        /**
         * handle case where layers not explicitly switched on
         */
        if(OCBaseState==PdfDictionary.ON){// && layerDict.getKeyArray(PdfDictionary.OFF)==null){
            Iterator keys=refToPropertyID.keySet().iterator();
            Object ref,layerName;
            while(keys.hasNext()){
                ref = keys.next();
                layerName=refToPropertyID.get(ref);

                refTolayerName.put(ref,layerName);

                if(! layersTested.containsKey(layerName)){
                  layersTested.put(layerName,"x");
                  layersEnabled.put(layerName,"x");
                }
            }
        }
       
        //set any locks
        setLocks(currentPdfFile,layerDict.getKeyArray(PdfDictionary.Locked));

        //any constraints
        setConstraints(layerDict.getKeyArray(PdfDictionary.RBGroups));

        //any Additional Dictionaries
        setAS(layerDict.getKeyArray(PdfDictionary.AS), currentPdfFile);


        /**
         * read any metadata
         */
        int[] keys={PdfDictionary.Name,PdfDictionary.Creator};
        String[] titles={"Name","Creator"};

        int count=keys.length;
        String val;
        for(int jj=0;jj<count;jj++){
            val= layerDict.getTextStreamValue(keys[jj]);
            if(val!=null)
                metaData.put(titles[jj],val);
        }

        //list mode if set
        val=layerDict.getName(PdfDictionary.ListMode);
        if(val!=null)
            metaData.put("ListMode",val);

    }
View Full Code Here

    private void setupOCMaps(PdfObject propertiesObj, PdfObjectReader currentPdfFile) {

        PdfKeyPairsIterator keyPairs=propertiesObj.getKeyPairsIterator();

        String glyphKey,ref;
        PdfObject glyphObj;

        while(keyPairs.hasMorePairs()){

            glyphKey=keyPairs.getNextKeyAsString();

            glyphObj=keyPairs.getNextValueAsDictionary();
            ref=glyphObj.getObjectRefAsString();

            currentPdfFile.checkResolved(glyphObj);

            byte[][] childPairs=glyphObj.getKeyArray(PdfDictionary.OCGs);

            if(childPairs!=null)
                setupchildOCMaps(childPairs, glyphKey,currentPdfFile);
            else{
                propertyMap.put(ref,glyphObj);
View Full Code Here

    }

    private void setupchildOCMaps(byte[][] keys, String glyphKey, PdfObjectReader currentPdfFile) {

        String ref;
        PdfObject glyphObj;

        int count=keys.length;
        for (byte[] key : keys) {

            ref = new String(key);
            glyphObj = new OCObject(ref);

            currentPdfFile.readObject(glyphObj);

            currentPdfFile.checkResolved(glyphObj);

            byte[][] childPairs = glyphObj.getKeyArray(PdfDictionary.OCGs);

//System.out.println(glyphKey+" === "+glyphObj+" childPropertiesObj="+childPairs);

            if (childPairs != null)
                setupchildOCMaps(childPairs, glyphKey, currentPdfFile);
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.