sivarajankumar / alivepdf

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

Referencing aliasNbPages macro fails due to type conversion problem. #144

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. myPDF.setAliasNbPages ( "[nb]" );
   myPDF.textStyle( new RGBColor (0,0,0), 1 );
   myPDF.setFont( FontFamily.HELVETICA, Style.NORMAL, 18 );
   // then use the alias when needed
   myPDF.addText ("There are [nb] pages in the PDF !", 150, 50);

What is the expected output? What do you see instead?
Expected:  
There are 2 pages in the PDF !

Actual:
There are null pages in the PDF !

What version of the product are you using? On what operating system?
0.1.4.8

On Windows XP, with Flex 3.0.

Please provide any additional information below.
There is an error in the PDF.createPageTree() method supplying the 'nb'
argument to findAndReplace().  Casting 'as String' does not work, should
use 'toString() instead:

// broken with 'as String'
//    for( n = 0; n<nb; n++ ) arrayPages[n].content = findAndReplace (
aliasNbPages, ( nb as String ), arrayPages[n].content );

// fixed with toString()
      for( n = 0; n<nb; n++ ) arrayPages[n].content = findAndReplace (
aliasNbPages, nb.toString(), arrayPages[n].content );

Original issue reported on code.google.com by spfied...@gmail.com on 22 Jul 2009 at 5:57

GoogleCodeExporter commented 8 years ago
Thanks for the bug and fix.

Thibault

Original comment by thibault.imbert on 23 Jan 2010 at 9:50

GoogleCodeExporter commented 8 years ago
This does not work still but if you cast the "nb" to a string before using it 
in the 
findAndReplace function it works perfectly!!!!

            var nbs:String = nb.toString();
            if( aliasNbPages != null )
            {
                 page.content = findAndReplace( aliasNbPages, nbs, page.content);
            }

Original comment by Marc...@gmail.com on 30 Jan 2010 at 9:54

GoogleCodeExporter commented 8 years ago
Neither of these fixes work for me. In both cases, when using aliasNbPages 
feature, the 1st page of my PDF fails to render, the 2nd page renders but the 
footer does not, and the rest of the pages render fine.

Original comment by devinkir...@gmail.com on 27 Oct 2013 at 1:45