8 Replies Latest reply on Jul 24, 2009 3:56 PM by Ansury

    AlivePDF setup

    Cr99 Level 1

      Does anyone here have experience with AlivePDF?  Has anyone gotten it to work?  It seems like the default answer for getting PDF generation in Flex is to use AlivePDF but their web site mostly has examples using AIR.

       

      I am using AlivePDF 0.1.4.9. in Flex (tried SDK 3.0 and 3.3) when I generate the pdf, a new browser window pops up and…nothing happens. I
      tried it with create.php, create.java, and looked into saving it with Flash Player 10 (but couldn't find any real documentation on how to make that work). I
      just get a blank new browser window. No error message, no anything.

       

      I added the swc file to my library path, used the tutorial sample code…and still nothing happens:

       

      myPDF = new PDF();
      var page:Page = new Page ( Orientation.PORTRAIT, Unit.MM, Size.A4 );
      myPDF.addPage(page);
      myPDF.lineStyle(new RGBColor(0×990000), 1,1,1);
      myPDF.drawCircle(20,20,20);
      var path:String = getBaseURL() + "/terracotta/create.php";
      myPDF.save(Method.REMOTE, path, Download.INLINE, "viewChart.pdf");

        • 1. Re: AlivePDF setup
          Cr99 Level 1

          Hmm...maybe there is another, better solution besides AlivePDF then?  Specifically, I need to export datagrids and charts as vector based pdfs instead of just turning them into an image and saving as a pdf that way.  Do I need to look at LiveCycle or something else to do this?

          • 2. Re: AlivePDF setup
            Ansury Level 3

            AFAIK that's still the most "Flex style" solution. Another answer is to generate your PDFs server side (in Java or whatever you use) and then just download it like you would normally.

             

            I think the reason most examples are AIR is because you can do this with plain Flex, but you need to stream all the data BACK to the server and then download it a second time (so the data goes across the wire three times! Who is okay with that?) because Flash player < 9 can't save directly to your machine (AIR has no such limitation).  Now from what I've heard Flash 10 can get around this problem, but I've yet to try it.. and it sounds like you know this already anyway.

             

            I know this probably doesn't help much. It's disappointing that we still have yet to see any decent production quality examples, I figured Flash 10 would have increased interest by now...

            • 3. Re: AlivePDF setup
              AKloft Level 2

              here's a discussion along the same lines as what you are looking for (pdf generation/saving/printing): http://forums.adobe.com/thread/465576?tstart=0

              • 4. Re: AlivePDF setup
                Ansury Level 3

                I'm not looking, otherwise I'd have had a more definite answer.

                 

                Oh, I have gotten it working with Flash 9, so something must be going wrong for you.  Isn't there a forum or something you can ask about examples on? I could have sworn there was one unless I'm confusing with something else.

                • 5. Re: AlivePDF setup
                  Cr99 Level 1

                  So you did get AlivePDF working then?  If so, what is causing my php script to fail?  The install seems pretty straight forward, just include the .swc into the library paths, but then the php script doesn't work.  That's why I'm confused.

                  • 6. Re: AlivePDF setup
                    Ansury Level 3

                    I'm a Flex/Java guy rather than php but did you look for any error logs it might be writing?  Can you debug the script at all?  In Java something you can do is set a debug breakpoint and step through to see what's happening, but I'm not sure what the php options are.  I think it should have worked as-is though, that's how the Java streaming was for me, I don't remember having to tamper with the code.

                    • 7. Re: AlivePDF setup
                      Cr99 Level 1

                      Actually, I'm a Java/Flex guy myself

                       

                      The only reason I mentioned the php is because it seemed to be the default "out of the box" approach for AlivePDF.  I also tried their create.java method which gave me the following error:

                       

                      java.lang.IndexOutOfBoundsException: The supplied offset + length did not fit into the supplied byte[] (offset + length = 1018 + 1018 = 2036 vs byte[].length = 1018)

                      In case you don't have he create.java, here are the relevant methods:

                      public void doPost(HttpServletRequest req, HttpServletResponse resp)

                      throws ServletException, IOException {

                      doGet(req, resp);

                      }

                       

                      public void doGet(HttpServletRequest req, HttpServletResponse resp)

                      throws ServletException, IOException {

                      int i = 0;

                      int k = 0;

                      int maxLength = req.getContentLength();

                      byte[] bytes = new byte[maxLength];

                      String method = req.getParameter("method");

                      String name = req.getParameter("name");

                       

                      ServletInputStream si = req.getInputStream();

                      while (true) {

                      k = si.read(bytes, i, maxLength);

                      i += k;

                      if (k == -1){

                      break;

                      }

                      }

                      if (bytes != null) {

                      ServletOutputStream stream = resp.getOutputStream();

                      resp.setContentType("application/pdf");

                      resp.setContentLength(bytes.length);

                      // resp.setHeader("Content-Disposition",method + ";filename=" + name);

                      stream.write(bytes);

                      stream.flush();

                      stream.close();

                      } else {

                      resp.setContentType("text");

                      resp.getWriter().write("bytes is null");

                      }

                      }

                       

                      • 8. Re: AlivePDF setup
                        Ansury Level 3

                        Sorry I can't remember back that far in time..  what I probably would have done is set breakpoints in the Java code to take a close look at exactly what's going wrong and when... look for hints of the problem.  I'll be back to looking at reporting in the next month or so prob so maybe I'll look at it again soon.  I couldn't find the example/test project that I had it working in unfortunately.  A little busy with higher priority stuff lately..