0 Replies Latest reply on Dec 29, 2011 2:48 PM by jgrm2811

    Can't generate PDF from xdp and XML

    jgrm2811 Level 1

      Hello,

       

      I'm new to livecycle and flashbuilder.

       

      I assigned as a task to send to a  livecycle server a xdp template and a XML file with the data in order to create the pdf.

      So far, I created a class with two methods that returns as a BLOB the strings of a xdp template and the XML data to populate the template.

       

      On the main application I'm calling the generatePDFOutput method from the OutputService and as far as I know I'm supposed to get a Blob which I can manipulate to save it as a PDF.

       

      What could be my error? or how should I approach this problem? I came here since I can't find some document that shows how to create pdf from a flex app using livecycle...

       

      I appreaciate your help.

       

      I attach below the code of the main class

       

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                     xmlns:s="library://ns.adobe.com/flex/spark"

                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="initializeChannelSet();">

         

          <fx:Script>

              <![CDATA[

                  import flash.sampler.Sample;

                 

                  import mx.messaging.ChannelSet;

                  import mx.messaging.channels.AMFChannel;

                  import mx.rpc.CallResponder;

                  import mx.rpc.events.ResultEvent;

                 

                  import services.outputservice.OutputService;

                 

                  import valueObjects.BLOB;

                  import valueObjects.OutputResult;

                  import valueObjects.PDFOutputOptionsSpec;

                  import valueObjects.RenderOptionsSpec;

                 

                  private var parentResourcePath:String="/";

                  private var serverPort:String="192.168.3.46:8080";

                 

                  private function initializeChannelSet():void{

                      var cs:ChannelSet= new ChannelSet();

                      cs.addChannel(new AMFChannel("remoting-amf", "http://"+serverPort+"/remoting/messagebroker/amf"));

                      outputService.setCredentials("administrator","password");

                      outputService.channelSet=cs;

                  }

                 

                  protected function btn_clickHandler(event:MouseEvent):void

                  {

             

                  var pdf:OutputService= new OutputService();

                  var x:TestPDF= new TestPDF();

                  var wsCall:CallResponder= new CallResponder();

                  var out:PDFOutputOptionsSpec= new PDFOutputOptionsSpec();

                 

             

                 

                  out.fileURI="D:\PDF_Output\test.pdf";

                  var render:RenderOptionsSpec= new RenderOptionsSpec();

                 

                  wsCall.token=pdf.generatePDFOutput("PDF","Form.xdp","D:\\PDF_Output",out,render,TestPDF.D ata());

                 

                  var res:BLOB= wsCall.lastResult as BLOB;

                 

                  var result:ByteArray= new ByteArray();

                      result=res as ByteArray;

                 

                  var a:Number=2;

                 

              }

                 

                  protected function outputService_resultHandler(event:ResultEvent):void

                  {

                      // TODO Auto-generated method stub

                     

                  }

                 

              ]]>

          </fx:Script>

         

          <fx:Declarations>

              <!-- Place non-visual elements (e.g., services, value objects) here -->

             

              <mx:RemoteObject id="outputService" destination="OutputService" result="outputService_resultHandler(event);"/>

          </fx:Declarations>

          <s:Button id="btn" x="90" y="141" label="Button" click="btn_clickHandler(event)"/>

      </s:Application>