chengse66 / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

Non-cp1252 characters and unicode support #317

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
First of all, I really appreciate your work.

The PDF class in 0.1.5RC contains a method

        protected function write( content:String ):void
        {
            if ( currentPage == null )
                throw new Error ("No pages available, please call the addPage method first.");
            if ( state == PDF.STATE_2 )
                currentPage.content += content+"\n";
            else
            {
                if ( !isLinux )
                    buffer.writeMultiByte( content+"\n", "windows-1252" );
                else
                {
                    var contentTxt:String = content.toString();
                    var lng:int = contentTxt.length;
                    for(var i:int=0; i<lng; ++i)
                        buffer.writeByte(contentTxt.charCodeAt(i));
                    buffer.writeByte(0x0A);
                }
            }
        }

with hard-coded "windows-1252" character set. This causes problems for everyone 
who is using any charset including non-cp1252 characters (in my case czech 
alphabet characters like ř,ť,...

        [Embed(source="../font/verdana.ttf", mimeType="application/octet-stream")]
        private var fontStream:Class;

        [Embed(source="../font/verdana.afm", mimeType="application/octet-stream")]
        private var afmStream:Class;

        setFont(new EmbeddedFont(new fontStream(), new afmStream(), CodePage.CP1250));

The font codepage should be somehow reflected.

I also found the unicode support in 0.1.5RC not working properly (UnicodePDF...)

Most people working in flex environment don't really want to take care about 
character sets. One would expect the usage of alivepdf much more 
straightforward and there should be some built-in default unicode font 
available if you are not interested any details.

Original issue reported on code.google.com by jan.kabr...@gmail.com on 25 May 2011 at 1:29