Expand my Community achievements bar.

SOLVED

Image Quandary

Avatar

Level 1

Hi,

I have created a Livecycle PDF form that has an image field inserted.  In this case, the user filling out the form will click that image field and insert a photograph of themselves.  Once I receive all of these filled-in forms that include photographs, I want to export field data from multiple PDFs into an Excel spreadsheet. 

When I click "embed image", and set the binding to "no data binding" since I don't want the image info imported into the Excel file, when the user inserts the photograph and saves the PDF, there is no image when the file is reopened, but all the other field info is there, and exports into Excel with no problem.  The only way I can get the image to appear after the user has filled out the form is if I have chosen "embed image" and set the binding to "Use Name".  However, the exported field info in the Excel spreadsheet contains hundreds of lines of garbage (which I assume is the BASE64 conversion of the image).

So how can I have an image inserted into the form, and still appear when the PDF is reopened, without all the gibberish showing up when I export the fields from multiple PDFs into Excel?  Thanks in advance.  Alot!!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You could try storing the image data somewhere else and on the initialise event of the imagefield load it up, this would mean that the image field does not need to be bound. 

So in the change event of the image field add following JavaScript;

xfa.datasets.assignNode("image.data", this.rawValue, 0);

This stores the image data in a data set call image, so wont impact the exported data, which is in a data set called data.

You could then load the image data in the initialise event with;

var imageData = xfa.datasets.resolveNode("image.data");

if (imageData !== null)

{

    this.rawValue = xfa.datasets.resolveNode("image.data").value;

}

There's other places to stored the image data, maybe an unbound hidden textfield.

View solution in original post

11 Replies

Avatar

Level 10

I heard it's not possible to insert images programmatically in a PDF... can you? xd

and the only metadata an image contains when it's embed its all the gibberish lines you're talking about....

I don't think there's any other way to export the image to another file... otherwise Excel is suppose to consider the gibberish lines as an image...

Avatar

Level 1

I don't want to export the image at all - I just want it embedded, and NOT export since I get the gibberish.  If I choose no binding, then the image does not embed.  Nothing is there in the image spot after the PDF is saved, and reopened.

Avatar

Level 10

I don't know what you're trying to do... but try this line if this works...

this.resolveNode("Reference_Syntax.Image1").value.image.transferEncoding = "none";

it's initially base64 so, it might help

Avatar

Correct answer by
Level 10

Hi,

You could try storing the image data somewhere else and on the initialise event of the imagefield load it up, this would mean that the image field does not need to be bound. 

So in the change event of the image field add following JavaScript;

xfa.datasets.assignNode("image.data", this.rawValue, 0);

This stores the image data in a data set call image, so wont impact the exported data, which is in a data set called data.

You could then load the image data in the initialise event with;

var imageData = xfa.datasets.resolveNode("image.data");

if (imageData !== null)

{

    this.rawValue = xfa.datasets.resolveNode("image.data").value;

}

There's other places to stored the image data, maybe an unbound hidden textfield.

Avatar

Level 1

That works perfectly BR001!!  You are my hero!  I would have never figured that out.

Avatar

Level 1

One more question BR001 - do you know if adding the script will run and all will work OK with Acrobat Reader?

Avatar

Level 10

Hi,

I wouldn't expect there to be any problem.

I've used this approach a number of times for other bits of data, and I first heard about it in 2009 ... http://blogs.adobe.com/formfeed/2009/01/transpromo_the_sequel.html

Bruce

Avatar

Level 1

Hello,

I have been looking all day for a solution to this problem! Thanks!

Anyways, I am new to this so have no idea where to copy and paste this javascript code. Where exactly do i need to put the code in LiveCycle? Do I need to alter the code to reference the ID names I have tagged to each image? (I have multiple (8) images i would need this code applied to?

Thanks in advance!


Avatar

Level 10

Hi

You will need to change the "image.data" part to be something unique for each image, so maybe "image.data1" to "image.data8".

The code editor can be selected with Ctrl+Shift+F5, so select the image field, open the code editor, select the event, change and then initialise, check the language is JavaScript and paste in the code with he modified value for your image dataset element (the bit in the line above)

Regards

Bruce

Avatar

Level 1

This is a great solution, but I'm having trouble getting it to work from a mobile device.  I'm using paid version of qPDF notes.  I can't seem to select the imagefield to take a photo with this method.  Do you have any thoughts about that?  Thanks a bunch.