Dynamic creation and streaming of binary resources or "Download of XML-dependant PDFs"

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Dynamic creation and streaming of binary resources or "Download of XML-dependant PDFs"

Thorsten Stumpf

Hi there,

 

I’ve got a question regarding the download of a PDF stream produced by an independant system.

 

We’ve got a system which creates PDFs – this system is capable to read the XML documents which are the base of our Orbeon XForms application.

These PDFs are filled out by our xforms.

 

I want to send the current state of the default xml instance to this system via post. It returns a stream with the proper PDF.

It seems to me this is quite similar to create a image that depends on the instances data which shall be displayed in the browser, isn’t it?

 

I tried a manifold of combinations of XPL pipeline, model and page-flow settings to read the stream and start a download – all end up more or less with the same:

Orbeon stops – somewhere in between – with an error regarding the type of the returned document ressource.

 

For exaple thatfor I wanted to set the media type of the returned document but – obviously – I don’t know how to do that (below my last try, which is far away from where I started) for streamed files:

 

            <p:processor name="oxf:http-serializer">
                       
<p:input name="config">
                                  
<config>

                                               <content-type>application/pdf</content-type>
                                              
<header>
                                                          
<name>Content-Disposition</name>
                                                          
<value>attachment; filename=test.pdf</value>
                                              
</header>
                                  
</config>
                       
</p:input>
                       
<p:input name="data" href="#data" debug="true"/>
           
</p:processor>

is obviously incorrect.

I tried to set the media type/serialization of the submission processors output and so on.

 

I also tried oxf:xml-converter and oxf:to-xml-converter. I see some examples for HTTP serializers and URL generators binary mode but they don’t seem applicable to me, because they are for fixed URLs/non-dynamic (XML created) content or uploaded files only.

 

 

I first tried xforms:load but that way I cant include the current default instance (in this case it’s the same as „ticket“) and I don’t want to send it by GET because it’s rather big (the same for xforms:output with appearance="xxforms:download").

In the end I tried to set up a basic prove with a transfer oft he PDF-source to the instance „PDF“ by sending via submission and replacing it’s content (and many things and twists on the wiki).

 

Model:

<xforms:submission id="print" ref="instance('ticket')" serialization="application/xml" resource="/run/bc/pdf" validate="false" method="post" replace="instance" f:url-type="resource" f:url-norewrite="true" includenamespaceprefixes="#default" xxforms:target="_blank" xxforms:instance="pdf">

 

bc/pdf.xpl:

      <p:param type="input" name="instance" debug="true"/>

     
<!--<p:processor name="oxf:xslt">
            <p:input name="data" href="#instance"/>
            <p:input name="config" href="getJourneytypeConfig.xsl"/>
            <p:output name="data" id="cms-request" debug="true"/>
      </p:processor>-->

     
<p:processor name="oxf:xforms-submission">
           
<p:input name="submission">
                 
<!-- FIXME: auf live ändern -->
                 
<xforms:submission method="post" action="http://srm-nt30.studiosus.loc:8080/pdf/test.pdf?xsl=booking.xsl"/>

</p:input>
     
<p:input name="request" href="#instance" xsi:type="xs:base64Binary"/>
     
<p:output name="response" id="response" debug="true"/>
</p:processor>
     
<p:processor name="oxf:xml-converter">
     
<p:input name="config">
           
<config>
                 
<encoding>utf-8</encoding>
           
</config>
     
</p:input>
     
<p:input name="data" href="#response"/>
     
<p:output name="data" id="data"/>
</p:processor>

<p:processor name="oxf:http-serializer">
     
<p:input name="config">
           
<config>
                 
<!-- This makes sure that the correct content type is sent to the client. In this particular case, this is not strictly necessary, as the content type provided by the input document would be used anyway. -->
                 
<content-type>application/pdf</content-type>
                 
<header>
                       
<name>Content-Disposition</name>
                       
<value>attachment; filename=test.pdf</value>
                 
</header>
           
</config>
     
</p:input>
     
<p:input name="data" href="#data" debug="true"/>
</p:processor>

 

page-flow.xml:

    <page path-info="/run/bc/pdf" model="bc/pdf.xpl" default-submission="ticket.bcml">
       
<setvalue ref="//stml:request//bcml:configuration/@opsid" parameter="ops_id"/>
       
<setvalue ref="//stml:request//bcml:configuration/@termin" parameter="termin_id"/>
       
<setvalue ref="//stml:request//bcml:configuration/@room" parameter="zimmer"/>
   
</page>
   
Anyhow: Can a streamed binary resource be send to the browser by orbeon to start an file download?

What do I have to change, what else can I try?

 

Did anyone accomplish a similar task?

 

I know there is an option to call a FOP within Orbeon but unfortunately this isn’t a viable option for us.

 

Thanks in advance,

 

Thorsten



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws