Go Back   Printable User Community > Software-Related Talk > The JavaScript Library > Graphic Rules

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 26th, 2009, 01:52 PM
MikeVM MikeVM is offline
Junior Community Member
 
Join Date: Sep 2008
Posts: 31
Default Supressing Graphics Frame

Hi,

I need help with following task: there is graphic frame, where customer can select image from drop-down menu (it's not a rule creating graphics resource, simple drop-down menu with images names) or leave it blank.
When customer does not choose anything the frame should be suppressed.

I understand I can wite a rule - where should I place it to work properly. TIA
__________________
FusionPro 6.0P1e Designer,
Acrobat 8.1.4 Pro
WinXP SP3
Reply With Quote
  #2  
Old May 27th, 2009, 10:07 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 466
Default Re: Supressing Graphics Frame

I'm not sure I understand the question. Where is this "drop-down menu" that you mention? If it's on a web page in FusionPro Web, and your question is about how the selection in that drop-down menu should be used in the job, then you might want to ask in the FP Web forum. As far as I know, it should become a field in the input data. If it's a list of file graphic names, then I think you can use the CreateResource function, although if it contains resource names, then you may need to use the Resource function instead.

In FP Desktop (the Acrobat plug-in), you can create a Graphic rule like so: From the menu in Acrobat, select FusionPro -> Edit Rules, then click "New", change the Rule Type to Graphic, under "Select a Rule Template" choose "Empty Rule," then click "Next." Then enter the logic for the rule; exactly what this should be obviously depends on what you're trying to do. I think you want something like this:
Code:
return CreateResource(Field("MyDropDownFieldName"));
Or, start with a Switch (Wizard) rule of type Graphic. Then click "OK" until you're out of the modal dialogs, select the Graphic frame, and in the Graphic Frame palette, in the combo box (drop-down list) second from the top, select the name of the rule you just created.

With logic like the above, if nothing is selected in the drop-down list, then the rule will throw an error, which should result in nothing being shown in the graphic frame in the output. If you want to suppress the error message in the log file, you can catch the exception and return NullResource like so:
Code:
try { return CreateResource(Field("MyDropDownFieldName")); }
catch (e) { return NullResource(); }
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Super Moderator
Printable Technologies, Inc.

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 warning messages. For font-related issues, please check your fonts.err file.

The correct spellings are JavaScript and FusionPro. Acceptable abbreviations are JS and FP. Please do not refer to JavaScript as "Java"; they are two completely different languages.

Check out the JavaScript Guide and JavaScript Reference!

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old May 27th, 2009, 12:42 PM
invaricconsulting's Avatar
invaricconsulting invaricconsulting is offline
Sr. Solutions Consultant
 
Join Date: May 2009
Location: Southern California
Posts: 10
Default Re: Supressing Graphics Frame

Something like this might work for you, assuming you have a graphic frame named "TestFrame", and the following graphic rule applied to that frame:

Code:
 
var MyPic = CreateResource(Field("VariableGraphic"), "graphic", true);
if (MyPic.exists)
{
    return MyPic;
}
else
{
    var MyFrame = FindGraphicFrame("TestFrame");
    MyFrame.suppress = true;
    return NullResource();
}
I could see this potentially being used for a case where the frame has a stroke around it that you don't want to show if the graphic is blank. However, along the lines of what Dan said, the above would be dependant upon a list of graphic file names being used.
__________________
Invaric Consulting
Winning With Web-to-Print
www.invaric.com
LinkedIn W2P Group
Reply With Quote
  #4  
Old May 27th, 2009, 12:46 PM
MikeVM MikeVM is offline
Junior Community Member
 
Join Date: Sep 2008
Posts: 31
Default Re: Supressing Graphics Frame

Thank you so much - will try tomorrow.
__________________
FusionPro 6.0P1e Designer,
Acrobat 8.1.4 Pro
WinXP SP3
Reply With Quote
  #5  
Old May 28th, 2009, 12:10 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 466
Default Re: Supressing Graphics Frame

Okay, well, you didn't mention that you wanted to suppress the frame so as to prevent text in a different frame from wrapping around it. That only came to light as a requirement in your other thread:
http://forums.printable.com/showthread.php?t=715

And the solution is the same as what invaricconsulting posted above:
http://forums.printable.com/showthre...=2316#post2316

Also, I didn't say that you had to move the post to the other forum, I just didn't understand what you were asking. So I apologize for being confused, but I was simply trying to answer the question that you actually asked, which was: "where should I place it?" A better question would have been, "How do I suppress a graphic frame to prevent text from wrapping around it when there's no graphic content?" The fact that you're getting the data from a form on FP Web doesn't really affect the answer to that question. Anyway, I think we're all on the same page now.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Super Moderator
Printable Technologies, Inc.

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 warning messages. For font-related issues, please check your fonts.err file.

The correct spellings are JavaScript and FusionPro. Acceptable abbreviations are JS and FP. Please do not refer to JavaScript as "Java"; they are two completely different languages.

Check out the JavaScript Guide and JavaScript Reference!

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #6  
Old May 28th, 2009, 12:12 PM
MikeVM MikeVM is offline
Junior Community Member
 
Join Date: Sep 2008
Posts: 31
Default Re: Supressing Graphics Frame

Dan,

thanks.
Indeed the correct question is a 90% of correct answer!
__________________
FusionPro 6.0P1e Designer,
Acrobat 8.1.4 Pro
WinXP SP3
Reply With Quote
  #7  
Old November 6th, 2009, 10:10 AM
cvblas cvblas is offline
Forum n00b
 
Join Date: Oct 2009
Location: Mt. Laurel, NJ
Posts: 1
Default Re: Supressing Graphics Frame

I am trying to use the rule suggested by Invarico above; however, it is not returning any results. I must be doing something incorrectly. I have copied the code exactly and changed the reference of the "testframe" to the name of my actual graphic frame.

The result I am trying to create is for a newsletter. We have headshots of clients with their name and contact information to the right of the image. If the photo is not present, I need the text to slide (or unwrap) to the left or edge of the text frame.

This is the code I am using (we are pulling images off our network):

Var1="MA Grid::Photo Filename";
Var2=".jpg";
Var3="G:\\Team Tools\\Digital Docs and Production\\Field Sales Photos\\MA MRC Photos";
Var4="none";


temp = '';
var_extension = '';
has_extension = '';

if (Var3 == "")
Var3 = Var3;
else
{
if (FusionPro.isMac)
Var3 = Var3 + ":";
else
Var3 = Var3 + "\\";
}

for (i=0; i<Field(Var1).length; i++)
{
temp = Mid(Field(Var1), Field(Var1).length-i,1);
var_extension = temp + var_extension;

if(var_extension == ".png" || var_extension == ".pdf" || var_extension == ".gif" || var_extension == ".eps" || var_extension == ".tif" || var_extension == ".tiff" || var_extension == ".jpg" || var_extension == ".jpeg")
{
has_extension = "true";
i=Field(Var1).length;
}
else
has_extension = "false";
}

if(has_extension == "true")
Pic = CreateResource(Var3 + Field(Var1), "graphic", true);

else
{
if(Var2 == ".jpg")
{
Pic = CreateResource(Var3 + Field(Var1) + ".jpeg", "graphic", true);
if (Pic.exists)
Pic = Pic;
else
Pic = CreateResource(Var3 + Field(Var1) + ".jpg", "graphic", true);
}


if(Var2 == ".tif")
{
Pic = CreateResource(Var3 + Field(Var1) + ".tif", "graphic", true);
if (Pic.exists)
Pic = Pic;
else
Pic = CreateResource(Var3 + Field(Var1) + ".tiff", "graphic", true);
}


if(Var2 == ".png" || Var2 == ".pdf" || Var2 == ".eps" || Var2 == ".gif")
{
Pic = CreateResource(Var3 + Field(Var1) + Var2, "graphic", true);
}

}

if (Pic.exists)
{
return Pic;
}
else
{
var MyFrame = FindGraphicFrame("MA Photo");
MyFrame.suppress = false;
return NullResource();
}


Any help you can lend would be great.

~ Christian
Acrobat 9 Professional, FP Desktop 6.1, Windows NT
Reply With Quote
  #8  
Old November 9th, 2009, 01:11 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 466
Default Re: Supressing Graphics Frame

Quote:
Originally Posted by cvblas View Post
The result I am trying to create is for a newsletter. We have headshots of clients with their name and contact information to the right of the image. If the photo is not present, I need the text to slide (or unwrap) to the left or edge of the text frame.
That sounds like you want an inline graphic in a text frame, returned from a text rule. This thread is about graphic frames and graphic rules, so most ofthe code posted herein is completely irrelevant to what you're trying to do. You need to go back to the User Guide and read about inline graphics.

Actually, I think that all you need to do is this, in a text rule:
Code:
var filename = Field("MA Grid::Photo Filename");
var pic = CreateResource(filename, "graphic", true);
if (pic.exists)
  return pic.content;

Print("Graphic not found: " + filename);
return "";
Make sure that the path to the graphic is in the Search Path in the Advanced tab of the Composition Settings dialog, and this should just work.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Super Moderator
Printable Technologies, Inc.

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 warning messages. For font-related issues, please check your fonts.err file.

The correct spellings are JavaScript and FusionPro. Acceptable abbreviations are JS and FP. Please do not refer to JavaScript as "Java"; they are two completely different languages.

Check out the JavaScript Guide and JavaScript Reference!

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
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 05:53 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
(c) 2008, Printable Technologies™, Inc.