Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Adobe Livecycle Remove Image Nodes from a form

Avatar

Level 1

So I've created a MS Access database to dynamically create PDF questionnaire forms for different organizations in my company which get filled out by a interviewer and then ingested back into the Access database to generate statistics.

The problem is that the base template PDF for the questionnaires has all of the logos for the different orgs embedded onto the form which in turn gets transferred down to all the questionnaires that get created. That means a full megabyte of space being put to waste per new questionnaire. Now I'm looking into alternative routes other than storing all these questionnaires, but for now I'm hoping to find a way to delete the unused logos.

Below is my attempt but it's doesn't seem to be working because the file size remain the same when a new questionnaire is created. Can anyone tell me where I'm going wrong? I suspect it's with this line " xfa.form.form1.Page1.Header.nodes.remove(delArray.pop()); " but I'm not sure how it should be formatted.

function changeLogo(logoID){

     var hNodes = form1.Page1.Header.nodes;

     var logoName = "";

     switch(logoID){

          case 1:logoName = "parentOrg";break;

          case 2:logoName = "org1";break;

          case 3:logoName = "org2";break;

          case 4:logoName = "org3";break;

          case 5:logoName = "org4";break;

     }

     var delArray = [];

     for(var i = 0; i < hNodes.length;i++){

          var tNode = hNodes.item(i);

          if (tNode.ui.oneOfChild.className == "imageEdit"){

               if (tNode.name == logoName){

                   tNode.presence = "visible";

               }else{

                    delArray.push(tNode);

               }

          }

     }

     while(delArray.length > 0){

          xfa.form.form1.Page1.Header.nodes.remove(delArray.pop());

     }

}

Much appreciate any help I can get.

Sincerely,

Jake

1 Accepted Solution

Avatar

Correct answer by
Level 10

The crux is, that the template DOM of a XFA form is read only so you can't delete anything of it. What you can manipulate is the form DOM, which is the current representation of the form created from the combination of the template and data. However, this won't solve your problem. What you can do to reduce the file size is to reduce the image sizes by reducing the resolution and colors. For a 50 × 30 mm sized logo the image has to be only 590 × 354 pixels to have 300 dpi. If it has only one or a few colors, reduce the colors (indexed colors) in the image file to 16 or less. This can reduce the size often about 90 %. And finally, do not select the checkbox to embed the image in the form, because then it will get stored as a Base64-encodes string in the template DOM which is around 30 % larger that the hex-encoded stream object it will get stored in the PDF otherwise.

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

The crux is, that the template DOM of a XFA form is read only so you can't delete anything of it. What you can manipulate is the form DOM, which is the current representation of the form created from the combination of the template and data. However, this won't solve your problem. What you can do to reduce the file size is to reduce the image sizes by reducing the resolution and colors. For a 50 × 30 mm sized logo the image has to be only 590 × 354 pixels to have 300 dpi. If it has only one or a few colors, reduce the colors (indexed colors) in the image file to 16 or less. This can reduce the size often about 90 %. And finally, do not select the checkbox to embed the image in the form, because then it will get stored as a Base64-encodes string in the template DOM which is around 30 % larger that the hex-encoded stream object it will get stored in the PDF otherwise.

Avatar

Level 1

Thank you for responding.

It wasn't the answer I was hoping for but it was the answer I was needing.

Avatar

Level 1

Hey there, I tried out your suggestions and it cut down the file size from 3.8 MB to around 890 KB, and as soon as I get around to cleaning up my code it might get reduced a smidge more. Graphic design is not my strong suit but this worked a treat.

Thanks again for your help.