Trouble accessing the PDF

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Trouble accessing the PDF

jaybee
Hi,

I have an website that call orbeon forms to gather data. When a user clicks send on orbeon forms it saves the form and then navigates back to my website and passes it the document id and another field called linkid.

The properties are as follows

property  as="xs:string"  name="oxf.fr.detail.buttons.*.*"  value="send pdf summary"/>

<property  as="xs:string"  name="oxf.fr.detail.process.send.DPUK.*">  require-valid then save then navigate(uri="http://localhost:62013/Review/OrbeonTest?orbeonid={xxf:instance('fr-parameters-instance')//document}&linkid={.//linkid}")</property>

From my website I would like to use the document ID to get the pdf.

In theory I would navigate to an  address like this

http://localhost:8080/Orbeon/fr/service/DPUK/Stage1/pdf/0ba03a9a08a5a2f943c78c8ffa5c5afa732394f9/a3bf7264aac151c65638e6b9a84139125722a2bf.pdf

However although I know the first guid which is the document id I don't know the second which has .pdf on the end. Can you advice how I can get a copy of the pdf from my external website.

Cheers

Reply | Threaded
Open this post in threaded view
|

Re: Trouble accessing the PDF

mabu
Hi,

You have to call xf:send("fr-pdf-service-submission") before navigate and then pass the pdf-url from xxf:instance('fr-pdf-url-instance') as parameter.

Martin
Reply | Threaded
Open this post in threaded view
|

Re: Trouble accessing the PDF

jaybee
Cheers. Works great
Reply | Threaded
Open this post in threaded view
|

Re: Trouble accessing the PDF

jaybee
Actually I've encountered a new problem.

I get the url back which is great. I then try and download the file using .net WebClient and it's file download function. I've also tried open the file as stream using requests and responses in net.

However it is always zero bites.

I've tested the url in a browser and it does indeed work so not sure why I can't download it programtically

Justin
Reply | Threaded
Open this post in threaded view
|

Re: Trouble accessing the PDF

Erik Bruchez
Administrator
Justin,

The second UUID is the id of the unique form session. You can get i with:

    xxf:document-id()

(It's a different "document id" from the other document id. I realize it's a bit confusing.)

You could also send the PDF URL to your service using the `pdf-url` token:

    http://doc.orbeon.com/form-runner/advanced/buttons-and-processes/actions-form-runner.html#sending-a-pdf-url

However if you call back that URL, you need to also pass the proper session cookie back to Orbeon Forms.

Another way, since you save the data to the database first, is to call a URL of the shape:

    http://localhost:8080/Orbeon/fr/DPUK/Stage1/pdf/0ba03a9a08a5a2f943c78c8ffa5c5afa732394f9

That doesn't require the form session id at all because that retrieves the PDF via the data saved to the database.

But note that here too your HTTP callback will have to be properly authenticated for the request to succeed.

We have an RFE to send the PDF binary directly, which should make things easier:

    https://github.com/orbeon/orbeon-forms/issues/1835

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Trouble accessing the PDF

jaybee
How would I go about making sure the session cookie is passed back from orbeon forms when I click send? I know how to send it back to orbeon forms from my web service once I've got when calling the pdf but don't know how to access to send it from orbeon to my web service

Justin
Reply | Threaded
Open this post in threaded view
|

Re: Trouble accessing the PDF

Erik Bruchez
Administrator
I think that if you the `oxf.http.forward-cookies` property as follows:

  <property
    as="xs:string"
    name="oxf.http.forward-cookies"
    value="JSESSIONID"/>

your service will receive the JSESSIONID cookie.

Note that this is currently a global option so that enables cookie forwarding for any outgoing HTTP connection. This might be insecure.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Trouble accessing the PDF

jaybee
Cheers. All working great now
Reply | Threaded
Open this post in threaded view
|

Re: Trouble accessing the PDF

Erik Bruchez
Administrator
Great, thanks for confirming. -Erik