Hello Craig,
In Graphic rules, the CreateResource function allows you to reference
any graphic, by file name, without having to add a Graphic Resource
to the list in the Resources dialog. You can use any kind of graphic
that FusionPro supports, which is basically all common formats,
including TIF, GIF, JPG, PNG, BMP, EPS, and PDF. (In Text rules, you
can use CreateResource to return the contents of a text file.)
The first parameter to CreateResource is a string that specifies the
full name of the file on disk. It can include the full path to the
file, or it can include a relative path, or it can be just the file
name itself, in which case FusionPro will try to find it in the
search path. Since this is JavaScript, the string can either be a
literal string, like "MyGraphic.png", or it can be built from
variables, such as a field name. Also, as the example shows, the
FusionProResource object returned by CreateResource can itself be
either returned directly from a rule, or assigned to another
variable. There's a lot of flexibility, and what the examples show
may not be what you want to do in your job.
Note that the second parameter to CreateResource, the type of the
resource, is optional. If you're in a Graphic rule, it will assume
the type is "graphic". The third parameter (nonExistOK) is optional
as well; if it's not specified, it will default to false, which means
that you'll get an error if the graphic doesn't exist. If you want
to check the graphic's existence via the .exists property, as in the
example, and take some other action if it's missing, then you really
do need that third parameter in the first call. So the example rule
should look like so:
Pic = CreateResource(Field("Last Name") + ".tif", "graphic", true);
if (Pic.exists)
return Pic;
else
return CreateResource("PhotoNotAvailable.jpg");
This assumes that there's a TIF file for each "Last Name" field. For
instance, if the last name is Smith, there's a graphic called
Smith.tif, and if the last name is Jones, there's a Jones.tif, etc.
If the .tif file does not exist for the field value in a particular
record, it calls out a default placeholder picture.
If the files are JPG files instead, you could do this:
return CreateResource(Field("Last Name") + ".jpg");
Often, the full name of the graphic, including the extension, will be
specified in a data field, in which case you don't need to add the
extension in the rule; for instance:
return CreateResource(Field("customer_picture"));
If you have EPS files, they probably have the ".eps" extension
(although the extension is optional, especially on Mac), so you
probably want to do something like:
return CreateResource(Field("Name") + ".eps");
Again, this assumes that if the value of the "Last Name" field is
"Joe Johnson", there will be a graphic named "Joe Johnson.eps", in a
location where FusionPro will find it. If the graphics are not in
the same folder as the template PDF or the input file, you will
either need to add their location to the search path (in your
Composition Settings, Advanced tab) or specify the full path in the
CreateResource call. If you're on Windows, you'll need to remember
to double-escape any backslashes in the path, for instance:
return CreateResource("C:\\MailerJob\\resources\\customer pictures\
\Joe Johnson.eps");
Also, even though the example rule returns an alternate resource if
the graphic specified doesn't exist, you don't have to do this. If
your Graphic rule doesn't return a valid resource, you'll simply get
a composition warning and nothing will appear in your output.
Returning a placeholder graphic is completely optional; you may want
to do something different in your job.
If you have named resources in the Resources dialog, you would use
the Resource function instead of CreateResource, like so:
return Resource("MainLogo");
Which would return the graphic resource named "MainLogo", regardless
of the name of the graphic file it's pointing to. (For instance, you
could have a resource named "MainLogo" that points to a file named
"PrintableLogoLarge.tif".) Creating resources is handy if you want
to reference files in various locations without having to specify the
path in JavaScript. It will also ensure that the Resource files are
collected with the job, if you're uploading to FusionPro Web or
otherwise composing on a different Server machine.
You can also mix calls to Resource and CreateResource in the same
rule, as the InsertPicture rule template shows.
Also, if you're simply returning named resources from the list, you
can use the Switch Wizard to build your rules, as in the Frodo Travel
sample, in which case you don't need to use JavaScript at all.
I hope this information is helpful.
-Alex
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 14, 2008 1:54 PM
To: FusionPro Users Forum
Subject: [fusionpro] RE: [SPAM] - Setting up variable images - Email
found in subject
Not using web to print. Using a database that I created in a format as
stated before and multiple pdf's as the image files.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
FusionPro 5.0 Now Available!
Variable text on a curve and soft drop-shadows for variable text
LIMITED TIME upgrade offer of $299 per license for current customers:
http://fusionpro.printable.com/store/upgrade
New licenses available for $599 each at:
http://fusionpro.printable.com/store/
All FusionPro 5.0 customers to receive FusionPro 5.1 with
Adobe Acrobat 8 and InDesign CS3 support when released for FREE.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
--
Users of FusionPro Desktop have unlimited free email support. Contact Printable
Support at [EMAIL PROTECTED]
--
View FusionPro Knowledge Base, FusionPro Samples at
www.printable.com/vdp/desktop.htm
--
You are currently subscribed to fusionpro as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
--
--
Note: All e-mail sent to or from this address will be received or otherwise
recorded by the e-mail recipients of this forum. It is subject to archival,
monitoring or review by, and/or disclosure to someone other than the recipient.
Our privacy policy is posted on www.printplanet.com
--
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
FusionPro 5.0 Now Available!
Variable text on a curve and soft drop-shadows for variable text
LIMITED TIME upgrade offer of $299 per license for current customers:
http://fusionpro.printable.com/store/upgrade
New licenses available for $599 each at:
http://fusionpro.printable.com/store/
All FusionPro 5.0 customers to receive FusionPro 5.1 with
Adobe Acrobat 8 and InDesign CS3 support when released for FREE.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
--
Users of FusionPro Desktop have unlimited free email support. Contact Printable
Support at [EMAIL PROTECTED]
--
View FusionPro Knowledge Base, FusionPro Samples at
www.printable.com/vdp/desktop.htm
--
You are currently subscribed to fusionpro as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
--
--
Note: All e-mail sent to or from this address will be received or otherwise
recorded by the e-mail recipients of this forum. It is subject to archival,
monitoring or review by, and/or disclosure to someone other than the recipient.
Our privacy policy is posted on www.printplanet.com
--