Package org.jpedal.objects.raw

Examples of org.jpedal.objects.raw.PdfObject


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

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

                int jj=0,newLen=newData.length;
                boolean hasArray=false;
                while(jj<newLen){
View Full Code Here


            isAES=true;

            String CFkey;

            PdfObject CF=encyptionObj.getDictionary(PdfDictionary.CF);

            //EFF=encyptionObj.getName(PdfDictionary.EFF);
            //CFM=encyptionObj.getName(PdfDictionary.CFM);

            if(v==4){
                isMetaDataEncypted=encyptionObj.getBoolean(PdfDictionary.EncryptMetadata);
            }
           
            //now set any specific crypt values for StrF (strings) and StmF (streams)
            isAESIdentity=false;
            String key=encyptionObj.getName(PdfDictionary.StrF);

            if(key!=null){

                isAESIdentity=key.equals("Identity");

                stringsEncoded=true;

                PdfKeyPairsIterator keyPairs=CF.getKeyPairsIterator();

                while(keyPairs.hasMorePairs()){

                    CFkey=keyPairs.getNextKeyAsString();

                    if(CFkey.equals(key))
                        StrFObj=keyPairs.getNextValueAsDictionary();

                    //roll on
                    keyPairs.nextPair();
                }
            }

            key=encyptionObj.getName(PdfDictionary.StmF);

            if(key!=null){

                isAESIdentity=key.equals("Identity");

                PdfKeyPairsIterator keyPairs=CF.getKeyPairsIterator();

                while(keyPairs.hasMorePairs()){

                    CFkey=keyPairs.getNextKeyAsString();
View Full Code Here

            String algorithm="RC4",keyType="RC4";
            //SecOP java ME - removed to remove additional package secop1_0.jar in java ME
            IvParameterSpec ivSpec = null;

            //select for stream or string
            PdfObject AESObj ;
            if(!isString){
                AESObj=StmFObj;
            }else{
                AESObj=StrFObj;
            }

            /**
             * reset each time as can change
             * (we can add flag later if slow)
             */
            if(certificate!=null){
                setPasswordFromCertificate(AESObj);

                //ensure value set so code below works
                AESObj.setIntNumber(PdfDictionary.Length,16);
            }

            //AES identity
            if(!alwaysUseRC4 && AESObj==null && isAESIdentity)
                return data;

            //use RC4 as default but override if needed
            if(AESObj!=null){

                //use CF values in preference

                int AESLength=AESObj.getInt(PdfDictionary.Length);
                if(AESLength!=-1)
                    keyLength=AESLength;

                String cryptName=AESObj.getName(PdfDictionary.CFM);

                if(cryptName!=null && !alwaysUseRC4 && ((cryptName.equals("AESV2")|| (cryptName.equals("AESV3"))))){

                    cipher=null; //force reset as may be rsa

View Full Code Here

    public static void sh(String shadingObject,PdfObjectCache cache, GraphicsState gs,
                          boolean isPrinting, Map shadingColorspacesObjects, int pageNum,
                          PdfObjectReader currentPdfFile,
                          PdfPageData pageData, DynamicVectorRenderer current) {

        PdfObject Shading= (PdfObject) cache.localShadings.get(shadingObject);
        if(Shading==null){
            Shading= (PdfObject) cache.globalShadings.get(shadingObject);
        }

        //workout shape
        Shape shadeShape=null;
        /**if(gs.CTM!=null){
         int x=(int)gs.CTM[2][0];
         int y=(int)gs.CTM[2][1];
         int w=(int)gs.CTM[0][0];
         if(w==0){
         w=(int)gs.CTM[1][0];
         }
         if(w<0)
         w=-w;

         int h=(int)gs.CTM[1][1];
         if(h==0)
         h=(int)gs.CTM[0][1];
         if(h<0)
         h=-h;
         shadeShape=new Rectangle(x,y,w,h);
         }/**/
        if(shadeShape==null)
            shadeShape=gs.getClippingShape();

        if(shadeShape==null && gs.CTM!=null && gs.CTM[0][1]>0 && gs.CTM[0][0]==0 && gs.CTM[1][1]==0){ //special case

            int x=(int)gs.CTM[2][0];

            int y=(int)gs.CTM[2][1];

            int w=(int)gs.CTM[0][0];
            if(w==0)
                w=(int)gs.CTM[0][1];

            if(w<0)
                w=-w;
            int h=(int)gs.CTM[1][1];
            if(h==0)
                h=(int)gs.CTM[1][0];
            if(h<0)
                h=-h;

            //don't understand but works on example I have!
            if(gs.CTM[1][0]<0){
                x=x+(int)gs.CTM[1][0];
                x=-x;
                w=(int)gs.CTM[2][0]-x;
            }
            shadeShape=new Rectangle(x,y,w,h);
        }

        /**
         * corner case for odd rotated shading
         */
        if(shadeShape==null && gs.CTM[0][1]<0 && gs.CTM[1][0]<0){
            int x=(int)-gs.CTM[0][1];

            int y=(int)(gs.CTM[2][1]+gs.CTM[1][0]);

            int w=(int)gs.CTM[2][0]-x;
            int h=(int)-gs.CTM[1][0];

            shadeShape=new Rectangle(x,y,w,h);

            //System.out.println(">>"+tokenNumber+" "+shadingObject+" "+gs.getClippingShape());

        }

        /**
         * corner case for odd rotated shading
         */
        if(shadeShape==null && gs.CTM[0][0]>0 && gs.CTM[1][1]<0){
            int x=(int)gs.CTM[2][0];
            int h=(int)gs.CTM[1][1];

            int y=(int)(gs.CTM[2][1]);

            int w=(int)gs.CTM[0][0];

            shadeShape=new Rectangle(x,y,w,h);


        }

        /**
         * corner case for odd rotated shading
         */
        if(shadeShape==null && gs.CTM[0][0]<0 && gs.CTM[1][1]>0){
            int x=(int)gs.CTM[2][0];
            int h=(int)gs.CTM[1][1];

            int y=(int)(gs.CTM[2][1]);

            int w=(int)gs.CTM[0][0];

            shadeShape=new Rectangle(x,y,w,h);

            // System.out.println(">>"+shadeShape.getBounds());

        }

        if(shadeShape==null)
            shadeShape=new Rectangle(pageData.getMediaBoxX(pageNum),pageData.getMediaBoxY(pageNum),pageData.getMediaBoxWidth(pageNum),pageData.getMediaBoxHeight(pageNum));

        /**
         * generate the appropriate shading and then colour in the current clip with it
         */
        try{

            /**
             * workout colorspace
             **/
            PdfObject ColorSpace=Shading.getDictionary(PdfDictionary.ColorSpace);

            GenericColorSpace newColorSpace= ColorspaceFactory.getColorSpaceInstance(currentPdfFile, ColorSpace, shadingColorspacesObjects);

            newColorSpace.setPrinting(isPrinting);

View Full Code Here

    int functionCount=0;
    if(keys!=null)
      functionCount=keys.length;

    PDFFunction[] functions=null;
    PdfObject function;
    if(keys!=null){
     
      PdfObject[] subFunction=new PdfObject[functionCount];
     
      String id;
View Full Code Here

        subFont=null;

        int fontType= PdfDictionary.Unknown;
        origfontType=PdfDictionary.Unknown;

        PdfObject descendantFont=pdfObject.getDictionary(PdfDictionary.DescendantFonts);

        boolean isEmbedded= isFontEmbedded(pdfObject);
        boolean isFontBroken=true; //ensure enters once

        while(isFontBroken){ //will try to sub font if error in embedded
            isFontBroken=false;

            /**
             * handle any font remapping but not on CID fonts or Type3 and gets too messy
             **/
            if(FontMappings.fontSubstitutionTable!=null && !isEmbedded &&
                    pdfObject.getParameterConstant(PdfDictionary.Subtype)!= StandardFonts.TYPE3)
                fontType = getFontMapping(pdfObject, font_id, fontType, descendantFont);

            //get subtype if not set above
            if(fontType==PdfDictionary.Unknown){
                fontType=pdfObject.getParameterConstant(PdfDictionary.Subtype);

                /**handle CID fonts where /Subtype stored inside sub object*/
                if (fontType==StandardFonts.TYPE0) {

                    //get CID type and use in preference to Type0 on CID fonts
                    PdfObject desc=pdfObject.getDictionary(PdfDictionary.DescendantFonts);
                    fontType=desc.getParameterConstant(PdfDictionary.Subtype);

                    origfontType=fontType;

                    //track non-embedded, non-substituted CID fonts
                    if(!isEmbedded && subFont==null) {
View Full Code Here

    }

    private static int scanForOpenType(PdfObject pdfObject, PdfObjectReader currentPdfFile, int fontType) {

        if(fontType==StandardFonts.CIDTYPE2){
            PdfObject desc=pdfObject.getDictionary(PdfDictionary.DescendantFonts);

            if(pdfObject!=null){
                PdfObject FontDescriptor=desc.getDictionary(PdfDictionary.FontDescriptor);

                if(FontDescriptor!=null){
                    PdfObject FontFile2=FontDescriptor.getDictionary(PdfDictionary.FontFile2);
                    if(FontFile2!=null){ //must be present for OTTF font

                        //get data
                        byte[] stream=currentPdfFile.readStream(FontFile2,true,true,false, false,false, FontFile2.getCacheName(currentPdfFile.getObjectReader()));

                        //check first 4 bytes
                        if(stream!=null && stream.length>3 && stream[0]==79 && stream[1]==84 && stream[2]==84 && stream[3]==79)
                            fontType= StandardFonts.CIDTYPE0; //put it through our TT handler which also does OT

                    }
                }
            }
        }else{
            PdfObject FontDescriptor=pdfObject.getDictionary(PdfDictionary.FontDescriptor);
            if(FontDescriptor!=null){

                PdfObject FontFile3=FontDescriptor.getDictionary(PdfDictionary.FontFile3);
                if(FontFile3!=null){ //must be present for OTTF font

                    //get data
                    byte[] stream=currentPdfFile.readStream(FontFile3,true,true,false, false,false, FontFile3.getCacheName(currentPdfFile.getObjectReader()));

                    //check first 4 bytes
                    if(stream!=null && stream.length>3 && stream[0]==79 && stream[1]==84 && stream[2]==84 && stream[3]==79)
                        fontType= StandardFonts.TRUETYPE; //put it through our TT handler which also does OT
View Full Code Here

        int fontType=pdfObject.getParameterConstant(PdfDictionary.Subtype);
        if (fontType==StandardFonts.TYPE0)
            pdfObject=pdfObject.getDictionary(PdfDictionary.DescendantFonts);


        PdfObject descFontObj=pdfObject.getDictionary(PdfDictionary.FontDescriptor);


        if(descFontObj==null)
            return false;
        else
            return descFontObj.hasStream();
    }
View Full Code Here

     * read FDF
     */
    final public PdfObject readFDF() throws PdfException{


        PdfObject fdfObj;

        try{

            byte[] fileData=objectReader.readFDFData();

View Full Code Here

                bookmarkPage=decode_pdf.getIO().convertNameToRef(bookmark);

                if(bookmarkPage!=null){

                    //read the object
                    PdfObject namedDest=new OutlineObject((String)bookmarkPage);
                    decode_pdf.getIO().readObject(namedDest);

                    //still needed to init viewer
                    if(fileCanBeOpened)
                        currentCommands.processPage();
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.