Jump to content

Supressing Graphics Frame


MikeVM

Recommended Posts

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

Link to comment
Share on other sites

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:

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:

try { return CreateResource(Field("MyDropDownFieldName")); }
catch (e) { return NullResource(); }

Link to comment
Share on other sites

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

 

 
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.

Link to comment
Share on other sites

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/showthread.php?p=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.

Link to comment
Share on other sites

  • 5 months later...

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

Link to comment
Share on other sites

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:

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.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...