Code Monkey home page Code Monkey logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on May 23, 2024
I found what the problem looks at the function where accumulates "l" and 
commented
code, and I am now working properly.        

public function writeText ( pHeight:Number, pText:String, pLink:String='' ):void
        {
            //Output text in flowing mode
            var cw:Object = this.currentFont.cw;
            var w:Number = currentPage.w-this.rMargin-this.x;
            var wmax:Number = (w-2*this.cMargin)*1000/this.fontSize;
            var s:String = str_replace ("\r",'',pText);
            var cwAux:int = 0;
            //var s:String = ",,,"
            var nb:int = s.length;
            var sep:int = -1;
            var i:int = 0;
            var j:int = 0;
            var l:int = 0;
            var nl:int = 1;


            while( i<nb )
            {
                //Get next character
                var c:String = s.charAt(i);

                if(c=="\n")
                {
                    //Explicit line break
                    this.addCell (w,pHeight,s.substr(j,i-j),0,2,'',0,pLink);
                    i++;
                    sep=-1;
                    j=i;
                    l=0;
                    if(nl==1)
                    {
                        this.x = this.lMargin;
                        w = currentPage.w-this.rMargin-this.x;
                        wmax= (w-2*this.cMargin)*1000/this.fontSize;
                    }
                    nl++;
                    continue;
                }
                if(c==' ') sep=i;
                /*          
                    Here verify if the character is unknown I value 500 by default, because the
problem is that if the character is not in the array can not add accumulator 
"l".
                    Notice whether this solution is valid. Thanks
                */ 
                cwAux = int(cw[c]);
                if (cwAux == 0)
                {
                    cwAux = 500;
                }
                l+=cwAux;
                if(l>wmax)
                {
                    //Automatic line break
                    if(sep==-1)
                    {
                        if(this.x>this.lMargin)
                        {
                            //Move to next line
                            this.x = this.lMargin;
                            this.y += currentPage.h;
                            w = currentPage.w-this.rMargin-this.x;
                            wmax = (w-2*this.cMargin)*1000/this.fontSize;
                            i++;
                            nl++;
                            continue;
                        }
                        if(i==j) i++;
                        this.addCell (w,pHeight,s.substr(j,i-j),0,2,'',0,pLink);
                    }
                    else
                    {
                        this.addCell (w,pHeight,s.substr(j,sep-j),0,2,'',0,pLink);
                        i=sep+1;
                    }
                    sep=-1;
                    j=i;
                    l=0;
                    if(nl==1)
                    {
                        this.x=this.lMargin;
                        w=currentPage.w-this.rMargin-this.x;
                        wmax=(w-2*this.cMargin)*1000/this.fontSize;
                    }
                    nl++;
                }
                else i++;
            }
            //Last chunk
            if (i!=j) this.addCell (l/1000*this.fontSize,pHeight,s.substr(j),0,0,'',0,pLink);
        }

Original comment by [email protected] on 13 Nov 2007 at 3:31

from alivepdf.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 23, 2024
We must correct the following function to operate the 'link' correct:

        private function GetStringWidth(s:String):Number

        {

            var s:String = String ( s );
            cw = currentFont.cw
            var w:Number=0;
            var l:int = s.length;
            var cwAux:Number = 0;
            for(var i:int=0;i<l;i++)
            {
                cwAux = Number(cw[s.charAt(i)]);

                if (isNaN(cwAux))
                {
                    cwAux = 500;
                }

                w+= cwAux;              
            }

            return w*fontSize/1000;

        }

Original comment by [email protected] on 13 Nov 2007 at 4:17

from alivepdf.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 23, 2024
Hi castromatias,

Thanks for tracking, I will include that and also optimize some other things 
related
to special characters in the next version ;)

kind regards,

Thibault

Original comment by thibault.imbert on 13 Nov 2007 at 6:46

from alivepdf.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 23, 2024
Hi, I'm trying to write text (using writeText function) with special spanish
characters (same as castromatias) from an utf-8 xml but I always get wrong 
results:
Ä, Â, etc... followed by another character.

I changed /WinAnsiEncoding encoding to all the posibilities (i think) but the 
result
is the same.

When I debug code I see correct characters in Flex but when pdf is generated 
everyone
turns wrong.

Thanks,

Fer


Original comment by [email protected] on 3 Apr 2008 at 9:41

from alivepdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.