Jump to content

Variable Graphics with Javascript


Recommended Posts

I am new to the variable graphics and javascript.

I watched the videos but I am still stuck on one thing.

When I create a rule for switching images, where or how do I put a line in the javascript to show where my images are at on my server?

I have 52 images.

 

The script I am using works if I put the images in the same folder as the PDF.

 

return (Field("fieldname") + '.eps' , graphic' , 1)

 

Thanks for any help I can get.

 

Scott

Link to comment
Share on other sites

When I create a rule for switching images, where or how do I put a line in the javascript to show where my images are at on my server?

I have 52 images.

 

The script I am using works if I put the images in the same folder as the PDF.

 

return (Field("fieldname") + '.eps' , graphic' , 1)

 

The simplest way is to add the location of the images (presumably either a UNC path on Windows, or a location under "/Volumes" representing a mounted drive on Mac) to the Search Path on the Advanced tab of the Composition Settings dialog. You don't need to modify the JavaScript rule at all with this method.

 

Another alternative is to hard-code the path in the rule itself, like so:

return CreateResource("\\\\server\\share\\subfolder\\etc\\" + Field("fieldname") + '.eps', 'graphic' , 1);

Note that because JavaScript uses backslashes as escape characters in string literals, you will need to either double them up or replace them with forward slashes in a Windows-style path.

Link to comment
Share on other sites

Dan,

 

Thank you for the tips. I was able to use the wizard to set the path.

I guess I typed it in wrong the first time when I tried to do it by hand.

Now I went to the Composition tab and copied the path from there.

 

Javascript is still very confusing to me.

 

Thanks again,

Scott Brown

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...