I've made a form in lifecycle that will be distributed by email as a pdf, and submitted back to me as an XML file and then that data imported into the pdf form template to view the data. Issue is I have an "attach image" field on the form and in XML it gets written to a base64 encoded format. Is there convenient way to extract this code from the XML file so that I would have a workable jpeg image file that I can save and open in other apps? Thank you in advance! -Robert Tampa
Views
Replies
Total Likes
You might start with the article by John Brinkman.
http://blogs.adobe.com/formfeed/2009/08/base64_encode_a_pdf_attachment.html
Views
Replies
Total Likes
Hi, Sure you can get the image from this Base64 code.
If you are using Livecycle Server ES2 then it would be quite easy. If you are familiar with SET VALUE operation in process, then there is a function getDocFromBase64(/process_data/@strBase64Data) which returns a document of input Base64 string. Note: @strBase64Data is the process variable which holds the Base64 string coming from the PDF form. You can save this document as image file on your disk.
Hope it helps.
Thanks.
-
Abhinav
Views
Replies
Total Likes
I tried to make John Brinkman's sample working in reverse.
This script will grab an image field's value and produce an attachment (png-file), which then can be saved to the hard drive.
//Get Base64 data of the image field
var b64Data = ImageField1.value.image.value;
//Convert to a read stream
var ReadStream = util.streamFromString(b64Data);
//Decode from Base64
var DecodedStream = Net.streamDecode(ReadStream, "base64");
//Attach an empty image file
event.target.createDataObject("MyExportImage.png", "", "image/png");
//Update attached image file with stream data
event.target.setDataObjectContents("MyExportImage.png", DecodedStream);
//Show attachment pane
event.target.viewState = {overViewMode:7};
This works so far, but the produced images are always cutted off.
No idea what's the reason for this behavior.
Views
Replies
Total Likes
Hi Abhinav, thank you for the response. Unfortunately I'm not familiar with the SET VALUE operation, is that a function in Lifecycle or a coding command in XML?
Views
Replies
Total Likes
Radzmar, thank you for your response. How do I run this script? And thank you again in advance
Views
Replies
Total Likes
Just put it into the click event of a button.
As far as I could figure out, this method seems to work properly only if the image data size is less than about 100 KB.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies