0 Replies Latest reply on May 25, 2010 3:33 PM by alexbariv

    AdobeAIR + Javascript + AlivePDF = PDF Page Size Question

    alexbariv

      Hi everybodoy.

       

      I finally managed to get Air + Javascript + AlivePDF rendering documents but now i have a problem, i need a custom size of the generated pdf, a document of 20cm per 20cm.

       

      This is the code that im using, but not working:

       

       

      var p1 = new Array(500,500);
      var p2 = new Array(11,11);
      var p3 = new Array(200,200);

       

          var customSize = new alivePDF.Size(p1, "myFavoriteSize", p2,p3 )

       

          var PDF = new alivePDF.PDF(alivePDF.Orientation.LANDSCAPE, alivePDF.Unit.MM, customSize);

       

          PDF.setDisplayMode(alivePDF.Display.FULL_PAGE,alivePDF.Layout.SINGLE_PAGE);

       

          PDF.addPage();

       

          PDF.addMultiCell(300,4,"This is a simple test of calling the AlivePDF library from AdobeAir with JS. Thanks AlivePDF!");

       

          var dump = PDF.save(alivePDF.Method.LOCAL);
          try {
              var f = air.File.applicationStorageDirectory.resolvePath("Test.pdf");
              var fs = new air.FileStream();
              fs.open(f, air.FileMode.WRITE);
              fs.writeUTFBytes(dump);
              fs.close();
          } catch (e) {
              alert("There was an error writing the PDF file.");
          }

       


          var initOptions = new runtime.flash.display.NativeWindowInitOptions();
          var bounds      = new runtime.flash.geom.Rectangle(10, 10, 1000, 600);
          var myHtml      = runtime.flash.html.HTMLLoader.createRootWindow(true, initOptions, false,bounds);
          var urlReq      = new runtime.flash.net.URLRequest("app-storage:/Test.pdf");
          myHtml.load(urlReq);

       

      Thanks in advance for all your help.