7 Replies Latest reply on Mar 31, 2010 5:31 AM by Ibarim

    AlivePDF - MXML vs AS

    Ibarim Level 1

      Hi,

       

      I'm using AlivePDF, when I add an object created with AS to the pdf file it doesn't appear in the pdf file. But objects created with MXML do appear in the pdf. I wonder if this is normal situation or am I doing something wrong?

       

      Of course object created with AS is added to stage and I can see it on stage, but can't see it in pdf.

        • 1. Re: AlivePDF - MXML vs AS
          AdamBe

          Providing code sample might help people see where your code might be failing. It's a lot easier to look at than words.

          • 2. Re: AlivePDF - MXML vs AS
            Ibarim Level 1

            Sure

             

            This works:

            <mx:TextArea id="abc" text="abc" width="200" height="200"/>
            printPDF.addPage();
            printPDF.addImage(abc);

             

            And this doesn't work:

            var abc:TextArea = new TextArea;
            abc.text = "abc";
            abc.width = 200;
            abc.height = 200;
            addChild(abc);
            printPDF.addPage();
            printPDF.addImage(abc);
            

             

            There is one more thing I just found out - when I run the second (pure AS) code in debug mode it works fine.

             

            I think that it's becouse code executes slowly. And when code executes fast (without debug mode) the 'addImage' statement adds TextArea without it's properties like 'text'. But on the other hand alive pdf must add objects, which are displayed - so the code 'addChild(abc)' must be executed or else I got error that 'abc' is not on stage or something similar. And I don't get this error.

             

            I completly don't understand this

             

            Any ideas, please?

            • 3. Re: AlivePDF - MXML vs AS
              AdamBe Level 1

              I've had a similar problem with addChild before, details are very  sketchy in my mind now, but it was an extenal library and I was trying  to add a non-sprite object using addChild which was failing.

               

              Try replacing addChild with addElement and see if that works.

              • 4. Re: AlivePDF - MXML vs AS
                Ibarim Level 1

                There is no 'addElement' method. At least in my flex 3

                • 5. Re: AlivePDF - MXML vs AS
                  AdamBe Level 1

                  Could be something as simple as your text not being enclosed in string double quotes

                  abc.text = abc;
                  abc.text = "abc";

                  • 6. Re: AlivePDF - MXML vs AS
                    Ibarim Level 1

                    I see no mistakes in the code, and there is no such method in flex help system either.

                    • 7. Re: AlivePDF - MXML vs AS
                      Ibarim Level 1

                      I got some help on other foru:

                      "most component rely on RENDER event and stage.invalidate() to draw themselves on the screen for efficiency. So in this case the drawing of the actual textarea is delayed until the next RENDER event is called. That's where your problem probably lies."

                       

                      The solution was to add 'validateNow' function to textArea before sending it to pdf.

                      addChild(abc); 
                      abc.validateNow();
                      printPDF.addPage();