Topic
  • 2 replies
  • Latest Post - ‏2010-07-01T11:34:05Z by andy_wilkins
andy_wilkins
andy_wilkins
21 Posts

Pinned topic Return PDF to web browser

‏2010-06-22T08:06:19Z |
Hi

We have a multi-prootocol gateway which sends a message to a Adobe Forms service, the service then returns a base64 encoded PDF file. The MPG has been called using an HTTP POST from a web browser and I would like to return the PDF on the response so that the PDF opens in the web browser.

Can anyone suggest how I can do this in DataPower ?

thanks in advance.

Andy
Updated on 2010-07-01T11:34:05Z at 2010-07-01T11:34:05Z by andy_wilkins
  • HermannSW
    HermannSW
    6394 Posts

    Re: Return PDF to web browser

    ‏2010-06-30T21:41:22Z  
    > ...
    > We have a multi-prootocol gateway which sends a message to a Adobe Forms service, the service then returns a base64 encoded PDF file. The MPG has been called using an HTTP POST from a web browser and I would like to return the PDF on the response so that the PDF opens in the web browser.
    >
    > Can anyone suggest how I can do this in DataPower ?
    >

    There are two services in attached export:
    1) simulateAdobeForms simulates Adobe Forms by just fetching a base64 encoded PDF file from local

    2) base64toPDF is what you requested
    The request rule is paththru, the response rule is Non-XML.
    The first xform sets the Content-Type of the response to "application/pdf".
    Ther second binary xform action does the decoding of the base64 data received from simulateAdobeForms.

    Now open this webpage in your browser (adapt "yourbox") and click on "submit", and as a result you will get the decoded PDF displayed in your browser (it shows the application layout of the export).
    <html>
      <body>
        <form action="http://yourbox:2063">
          <input type="submit" value="submit"/>
        </form>
      </body>
    </html>
    
    Updated on 2014-03-25T03:42:53Z at 2014-03-25T03:42:53Z by iron-man
  • andy_wilkins
    andy_wilkins
    21 Posts

    Re: Return PDF to web browser

    ‏2010-07-01T11:34:05Z  
    • HermannSW
    • ‏2010-06-30T21:41:22Z
    > ...
    > We have a multi-prootocol gateway which sends a message to a Adobe Forms service, the service then returns a base64 encoded PDF file. The MPG has been called using an HTTP POST from a web browser and I would like to return the PDF on the response so that the PDF opens in the web browser.
    >
    > Can anyone suggest how I can do this in DataPower ?
    >

    There are two services in attached export:
    1) simulateAdobeForms simulates Adobe Forms by just fetching a base64 encoded PDF file from local

    2) base64toPDF is what you requested
    The request rule is paththru, the response rule is Non-XML.
    The first xform sets the Content-Type of the response to "application/pdf".
    Ther second binary xform action does the decoding of the base64 data received from simulateAdobeForms.

    Now open this webpage in your browser (adapt "yourbox") and click on "submit", and as a result you will get the decoded PDF displayed in your browser (it shows the application layout of the export).
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><html> <body> <form action="http://yourbox:2063"> <input type="submit" value="submit"/> </form> </body> </html> </pre>
    Thank you very much for the solution.

    Having something to actually look at has been very useful and I have already worked it in to my solution.