Hi Experts,
Need Help.
Environment:
LiveCycleDesigner : 8.0 with reader extension.
Problem:
I have a requirement in which the filled in dynamic form, has to be
attached to a webservice on click of a event, with all the data in the form and as a pdf to the
webservice, using JAVA SCRIPT.
Am able to execute the webservice, but am unable to attach pdf(itself) to the
webservice.
Hope you guys would be able to help me out.
Regards,
NVRS
Solved! Go to Solution.
Views
Replies
Total Likes
You can use Collab.documentToStream(event.target) to get the PDF contents as a stream object. I assume you are currently submitting attachments as stream objects so it will be the same from then on. The Collab class is discribed in the "JavaScript for Acrobat API Reference" document.
Bruce
Views
Replies
Total Likes
A typical implementation for this would be for the form to submit XML data using HTTPS back to a LiveCycle ES server. You can then use a LiveCycle orchestration to re-constitute the PDF and invoke the web service.
If you have no option but to call the web service directly from the form, then you can send the data and the web service provider would need to reconstitute the PDF. I know of a trick to send attached documents to a web service, but not the PDF itself. Perhaps, someone else on the forum knows of a way?
To send the data to a web service, using the WSDL data connection, you populate a hidden field, which is bound to the web service input element, with the form data and invoke the web service.
To send the data to a web service, using the AcroJS SOAP object, you would programatically add the form data to the web service invocation.
In both cases, the JavaScript for retrieving form XML data as a string is:
var formData = xfa.data.saveXML();
Ben Walsh
Thank you Ben.
I am able to attach other files and send them to the Webservice.
The problem is loading the same pdf which would execute the webservice.
I am not able to get a reference object to the the current file. And I have to
send binary data to the WSDL and not XML.
I hope there is some answer out there.
Regards,
NVRS
Views
Replies
Total Likes
Can't be done. There is no way to get the PDF programatically to attach to the web service. You can submit all of the data but the entire PDF cannot be retrieved from inside of the form. As Ben points out you can post the PDF to an intermeadiary and have that program call the web service but that is it.
Paul
Thank you Paul, but it is very disheartening .
I always thought that it was possible, as a email submit button does the same
thing but to an email attachment ( am talking about the button able to get handle
of the same document and convert it to a pdf attachment).
As you know, you cannot see the code for the click event of an email submit button,
but am still optimistic that we should be able to do it.
Thanks for your valuable replies.
Not giving up!
NVRS
Views
Replies
Total Likes
You can use Collab.documentToStream(event.target) to get the PDF contents as a stream object. I assume you are currently submitting attachments as stream objects so it will be the same from then on. The Collab class is discribed in the "JavaScript for Acrobat API Reference" document.
Bruce
Views
Replies
Total Likes
Thats the idea Bruce, I did think of that, but was not sure to
convert the stream to base64 to attach, got the solution to that as well,
I suppose....would be something like this.
var encodedStream = Net.streamEncode(documentStream, "base64");
I hope this is gonna work, would be trying it out tomorrow, D'day
Will surely let you know what happened.
10er for you Bruce, for being on the same page
Regards,
NVRS
Views
Replies
Total Likes
I didn't think you coudl get the PDF programmatically from the doc you were working on. I created this sample to show how it works. The xml file is my LiveCycle Web Service that will take the inbound PDF (base64 encoded) and write it to the file system. The PDF file is the working document. It is simple but functional. The WS will return a message and I display that message as an alert in the form (to indicate that the submission was successful).
Thanks to BR001 for pointing out that method.
Paul
Views
Replies
Total Likes
I would just like to add that I've had problems with using base64 encoding. I did raise this as a bug with Adobe so it might have been fixed as I've still using Acrobat 8.0, but if you are targeting Acrobat/Reader 8 then I would use hex encoding, even though it adds 30% (??) percent to the size.
In the JavaScript Debugger console if you try;
SOAP.stringFromStream(Net.streamEncode(SOAP.streamFromString('sampletext'), 'base64'))
I get "c2FtcGxldGV4dA==" ... which is fine.
But if you try
SOAP.stringFromStream(Net.streamEncode(SOAP.streamFromString('sample\x00text'), 'base64'))
You get "c2FtcGxl" ... it seems to stop at the first null characters and in a binary file (like a PDF) you could to get a null character somewhere.
This is my C# code for converting a hex encoded character if that helps;
<summary>
///
Converts a hex-encoded character to a byte.
///
</summary>
private byte HexUnescape(char digit1, char digit2)
{
if ((((digit1 < '0') || (digit1 > '9')) && ((digit1 < 'A') || (digit1 > 'F'))) && ((digit1 < 'a') || (digit1 > 'f')))
{
throw new System.ArgumentException("Invalid Hex digit {0}", "digit1");
}
if ((((digit2 < '0') || (digit2 > '9')) && ((digit2 < 'A') || (digit2 > 'F'))) && ((digit2 < 'a') || (digit2 > 'f')))
{
throw new System.ArgumentException("Invalid Hex digit {0}", "digit2");
}
int num = (digit1 <= '9') ? (digit1 - '0') : (((digit1 <= 'F') ? (digit1 - 'A') : (digit1 - 'a')) + 10);
return (byte)((num << 4) + ((digit2 <= '9') ? (digit2 - '0') : (((digit2 <= 'F') ? (digit2 - 'A') : (digit2 - 'a')) + 10)));
}
Views
Replies
Total Likes
Hi NVRS... do mind share your answer regarding this solution? I'm searching how to send a pdf with attachment thru webservice...
Views
Replies
Total Likes
Hi NVRS,
I also came across the same requirement.
Please do sharing your solution for this.
Reagrds,
Ram
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies