Go Back   PTI Marketing Technologies User Community > Software-Related Talk > The JavaScript Library > Graphic Rules

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 10th, 2015, 11:16 AM
mjlongo mjlongo is offline
Junior Community Member
 
Join Date: Jul 2013
Location: Rochester NY
Posts: 29
Default Multiple Business Card back images rule

Hello,

I have a business card that allows a customer to upload anywhere from one to five different images for the back of the card. I have created a fusion pro document that contains the front of the card then back one, the front of the card then back two, etc for a total of ten pages.

For each of the 5 backs of the cards, I have created an image box that covers the entire back. Each one of these graphic boxes are labeled "Graphic1", "Graphic2", "Graphic3", etc.

In the same folder as my fusionPro document, I have five sample graphic files. They are all named "sample1.jpg", "sample2.jpg", etc. Each graphic file is assigned a matching resource within the fusion pro document. For example I have a resource called image1 that is assigned sample1.jpg, etc for all five resources.

So, this is what I am trying to do: If a customer uploads just one image file, I want that file to be applied to all backs . If a customer uploads image 1 and then uploads image 2, I want image 1 to stay on back 1 but then image 2 should apply to backs 2,3,4 and 5. Likewise if a customer uploads image 1, image 2 and then image 3. I want image 1 on back 1, image 2 on back 2 and then image 3 on backs 3,4 and 5. And so forth. Note that there will be a default image if nothing is uploaded at all.

To accomplish this, I have been trying to get the following script to work. The script is inside an OnRecordStart.


Code:
var frame1 = FindGraphicFrame("Graphic1");
var frame2 = FindGraphicFrame("Graphic2");
var frame3 = FindGraphicFrame("Graphic3");
var frame4 = FindGraphicFrame("Graphic4");
var frame5 = FindGraphicFrame("Graphic5");

frame1.SetGraphic(Field("Image1"));
frame2.SetGraphic(Field("Image1"));
frame3.SetGraphic(Field("Image1"));
frame4.SetGraphic(Field("Image1"));
frame5.SetGraphic(Field("Image1"));


if (Field("Image2") != "")
    {
        frame2.SetGraphic(Field("Image2"));
        frame3.SetGraphic(Field("Image2"));
        frame4.SetGraphic(Field("Image2"));
        frame5.SetGraphic(Field("Image2"));
    }
    
if (Field("Image3") != "")
    {
        frame3.SetGraphic(Field("Image3"));
        frame4.SetGraphic(Field("Image3"));
        frame5.SetGraphic(Field("Image3"));
    }
    
if (Field("Image4") != "")
    {
        frame4.SetGraphic(Field("Image4"));
        frame5.SetGraphic(Field("Image4"));
    }
    
if (Field("Image5") != "")
    {
        frame5.SetGraphic(Field("Image5"));
    }

The problem is, that it is just not working. I am getting blank pages. I am also getting the following errors on compose: "Graphic is not found or is not processed properly: image1". That error appears for each graphic resource. I do not have that error if I omit the script and then place "image1" resource directly into the graphics box. Therefore I cannot see why there would be an issue finding the resource. Should I be placing the images in some other location?

I'm also curious to see if there may be some better ideas or solutions to this type of business card and what I'm trying to do. I'm open to any and all ideas.

Thanks!
Reply With Quote
  #2  
Old August 10th, 2015, 11:57 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 3,980
Default Re: Multiple Business Card back images rule

I think you just need to call either Resource or CreateResource on the field value, like so:
Code:
frame1.SetGraphic(Resource(Field("Image1")));
The repetetive logic could also be reduced quite a bit with a for loop such as "for (var i = 1; i <= 5; i++)", but I'll leave that as an exercise for others.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@pti.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@PTI.com. Paid consulting work may be required to fulfill your template-building needs. Please do not post proprietary font files to this forum.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old August 10th, 2015, 12:23 PM
mjlongo mjlongo is offline
Junior Community Member
 
Join Date: Jul 2013
Location: Rochester NY
Posts: 29
Default Re: Multiple Business Card back images rule

Thank you for the response. Your suggestion of using the "resource" worked when I replace the lines you mention and compose the document. However, when I upload the document and place it on MarcomCentral where someone can upload the images backs, it fails to work. The card will not apply the uploaded image and/or in some cases, it is using the resource from the library of images.
Reply With Quote
  #4  
Old August 10th, 2015, 01:39 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 3,980
Default Re: Multiple Business Card back images rule

Quote:
Originally Posted by mjlongo View Post
Thank you for the response. Your suggestion of using the "resource" worked when I replace the lines you mention and compose the document. However, when I upload the document and place it on MarcomCentral where someone can upload the images backs, it fails to work. The card will not apply the uploaded image and/or in some cases, it is using the resource from the library of images.
Okay, this is now a MarcomCentral-specific question, which really should be asked on the MarcomCentral forum.

That said, I suspect that the problem is that the uploaded image files have different file names than the file names associated with your resources. So if you want to support arbitrary uploaded file names, you need to forgo the named resources, put file names instead of resource names in your data file, and then use CreateResource on those file names, like so:
Code:
frame1.SetGraphic(CreateResource(Field("Image1", "graphic")));
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@pti.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@PTI.com. Paid consulting work may be required to fulfill your template-building needs. Please do not post proprietary font files to this forum.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #5  
Old August 10th, 2015, 02:34 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 921
Default Re: Multiple Business Card back images rule

If the backs are variable, it seems to me you could achieve the same thing by having a two-paged template that is repeated by the number of backs that have been uploaded. I'm not sure what's the point of returning a 10 page preview if all of the fronts and backs are identical (i.e. they uploaded 1 or 0 custom backs). Instead you could count the number of backs that they've uploaded, repeat the record that many times and change the graphic on the back page for each time the record repeats itself:
Code:
var backs = [Field("Image1"),Field("Image2"),Field("Image3"),Field("Image4"),Field("Image5")].filter(String).map(function(s){ return CreateResource(s, 'graphic');});
FusionPro.Composition.repeatRecordCount = backs.length;
var back = backs[FusionPro.Composition.repeatRecordNumber-1] || CreateResource("DefaultBack.pdf", 'graphic');
FindGraphicFrame("Graphic1").SetGraphic(back);
In the above code, the "backs" array contains the 5 "custom back" fields. The array is filtered and the empty fields are removed. Then the record is repeated by the length of the array. As it repeats the record, it steps through the "backs" array and assigns the contents to the graphic frame on the back page. If "backs" is empty, it assigns a default image to the back page.

If for some reason you need to return a 10 page preview (5 cards) regardless of how many unique backs there are, you could do so like this:
Code:
var back = 'DefaultBack.pdf';
var backs = [Field("Image1"),Field("Image2"),Field("Image3"),Field("Image4"),Field("Image5")].map(function(s){ back = (s) ? s : back; return CreateResource(back,'graphic');});
FusionPro.Composition.repeatRecordCount = 5;
FindGraphicFrame("Graphic1").SetGraphic(backs[FusionPro.Composition.repeatRecordNumber-1]);
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #6  
Old August 10th, 2015, 02:58 PM
mjlongo mjlongo is offline
Junior Community Member
 
Join Date: Jul 2013
Location: Rochester NY
Posts: 29
Default Re: Multiple Business Card back images rule

Thank you for the reply STEP. I will give your suggestions a try on another test card to see if I can streamline the process.

At the moment, I got the card to work with some changes to the script. I had to employ the "CreateResource" methods as described earlier. The remaining issues are now with MarcomCentral (the crop tool in particular) and I am working with their support team on those issues.

Thanks!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:39 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.