Jump to content

Insert Graphic if page is in use


Rebecca

Recommended Posts

I have a template that is 2 pages long, but the second page can be one of 720 differently sized pages based on user input. I have a graphic box on all these pages but when I upload an image it gets all jumbled up as it tries to insert the graphic on all 720 differently sized and shaped graphic boxes

 

Is there a way that I can make a rule so that it will only return an uploaded image from my graphic field if the page is in use, I am concerned I will have to make a separate rule for each page. Is there a way to do this as an overall rule? If so, how would I go about doing that?

 

I was also thinking that I could make all the graphic fields suppressed and if the page is in use, that graphic box would restore. I know you can make a rule to suppress the graphic box, but is there a way to have them all set to suppressed and make a rule that will only have to restore one box with 720 instances instead of having to suppress 719 boxes with 720 instances.

 

Any help would be appreciated.

-Meir Galimidi

Link to comment
Share on other sites

Good Morning,

 

I've not used this feature yet to turn on and off text and graphic boxes so I don't really know if there is a way to globally turn off all graphic boxes in the template or on a specific page, but I believe that in theory this would work. It may take up some processing time though because of the number of boxes you are referring to, but try something like this...

 

In either an OnRecordStart rule (if you are processing data files that vary in length) or an OnJobStart rule (if your data file contains only one record each time) create an array that contains all of the graphic box names. Then inside that callback rule create a loop statement (FOR, WHILE, DO...UNTIL whatever you wish to use) and go through the array elements one by one turning off all of those boxes. Then directly after this loop turn on the correct box that you wish to use. I think it would look something like this...

for (i = 0, i <= 719, i++)  {
    FindGraphicFrame(FRAMEBOX[i]).suppress = true;
}
FindGraphicFrame("Correct Frame Box").suppress = false;

I know that making an array of 720 names will be rather daunting in nature, but I've been known to kill a few flies with a sledgehammer in my time. This is just one way that I would do it...if there is not any way of globally supressing all boxes to begin with.

 

Good Luck.

.

Link to comment
Share on other sites

It's certainly possible to have a job with a large number of Unused Body Pages, and you can use one line of code to enable just the one you want with a single call to FusionPro.Composition.SetBodyPageUsage() in your OnRecordStart rule. It's also possible to use a loop such as David describes; you could always name your frames with consecutive numbers in them to avoid having to create a separate mapping. However, both of these approaches are going to be really slow.

 

There are a couple of options I can think of that might work better. You may be able to simply use an inline graphic in a text frame and control the size with the width and height attributes of the <graphic> tag. Or, you can use a table to control the position of the graphic on the page. You might also want to try the new "Proportional Fill" scaling in FusionPro 7.0 and see if that does what you need.

 

If you can attach a small sample of the job with a few of the graphics and maybe an example of the output you're expecting, then I or someone else may be able to offer more specific suggestions. A picture is worth a thousand words and all that.

Link to comment
Share on other sites

Here is a brief summary of the job: Custom Banners. The first page just shows what you ordered. The second page is a preview of the banner being ordered at the size(or scaled size) ordered, so they can proof their banner.

 

I already had my page names and graphic box names created in a way that it wasn't to hard to make rules with some copy/paste and find/replace actions to get my code made (just 48 repeats for all of them, so not to bad at all if were going with the sledgehammer method).

So here is what I have so far...

 

...    
   //first i go through every graphic frame and turn them off...
       FindGraphicFrame("045105").suppress = true
       FindGraphicFrame("045110").suppress = true
       FindGraphicFrame("045115").suppress = true
       FindGraphicFrame("045120").suppress = true

       //then i use an if function to find out what one dimension 1 is
if(Field("LongSide1") != "")    
   {
   if(Field("LongSide1") == "1")    //from here i find the 2nd dimension
       {
       FindGraphicFrame("010010").suppress = false  
//i then turn on the graphic field
       FusionPro.Composition.SetBodyPageUsage("010010",true); 
//then turn on the page and end the program
       }
   if(Field("LongSide1") == "1.5")
       {
       FindGraphicFrame("010015").suppress = false
       FusionPro.Composition.SetBodyPageUsage("010015",true);
       }
 //... it continues like this ending with a catch all for every set of if 
//statements
...else
       return "Not Valid Option"
   } 

if(Field("LongSide1_5") != "")    
   {
   if(Field("LongSide1_5") == "1.5")
       {
       FindGraphicFrame("015015").suppress = false
       FusionPro.Composition.SetBodyPageUsage("015015",true);
       }
...

 

 

I had to have multiple "longside#" fields because i needed to price based on square footage and needed to make my values able to change price as a flat or unit fee. By making each "longside#" apply to a specific selected width I can determine what the square footage in one field and price it accordingly.

 

As of now this works (albeit slowly), however there is a couple issues i am having. The enhanced view is all sorts of jumbled up, but more pressingly the image upload cropper always sets the crop size to my first image box. I am assuming this is because my boxes don't turn off until composition. How can i avoid this.

 

 

There are a couple of options I can think of that might work better. You may be able to simply use an inline graphic in a text frame and control the size with the width and height attributes of the <graphic> tag.

 

I think this idea may work pretty efficiently for my purposes, however i do not know how to adjust the size of an inline graphic. How do I make it adjustable? Can field values be cause for adjustment?

 

 

By the way, thank you Dan and Dsweet. You have been very helpful

Link to comment
Share on other sites

If I understand your code correctly, you appear to have a separate body page for each graphic frame you are suppressing.

if(Field("LongSide1") == "1.5") 
       { 
       FindGraphicFrame("010015").suppress = false 
       FusionPro.Composition.SetBodyPageUsage("010015",true); 
       }

If that is the case, you should be able to skip suppressing of graphic frames since they won't be used by default if the page itself is unused. Since that seems too obvious, I'm guessing I'm missing something in the bigger picture.

 

On a side note, you could save several keystrokes by using a switch loop instead of all the ifs. :)

Link to comment
Share on other sites

yea i plan to switch to a loop once i fully understand what needs to be done (and learn a little more about loops).

 

I am not sure, but I'm willing to bet you are correct about the whole suppressing graphic when the page isn't in use statement, that is what i originally thought, but it seems the graphic frames still effect my printable interface even though their page wont be in use. :confused:

 

I originally just had the restore page part. I just added the suppress graphic part in an effort to fix an effect that appears to be the first graphic frame's fault.

 

When I upload the template, I have an image uploader with crop option. But when I upload an image the crop sets to the 18"x18" proportion (the dimension of my first versioned page/graphic box) and I need to be able to crop to whatever the dimension is of the active graphic field. Any input on how I can effect this?

 

Also, how can you change the dimensions of an inline graphic?

Link to comment
Share on other sites

i do not know how to adjust the size of an inline graphic. How do I make it adjustable?

With the width and height attributes of the <graphic> tag, as documented in the FusionPro Tags Reference Guide, in the section titled, "Graphic Tag Inside Story Tag."

Can field values be cause for adjustment?

Sure, you can do this easily with JavaScript, for example:

return '<graphic file="mygraphic.jpg" width="' + Field("GraphicWidth") + '" height="' + Field("GraphicHeight") + '">';

The graphic tag from the rule gets returned to a variable, which you can use inside (inline with) a text frame. You can use other tagging to control the position of the graphic within the frame. For instance, you can use a <leading> tag for vertical space, like so:

return '<leading newsize=1000><graphic file="mygraphic.jpg" width="10000">';

And you can use tabs for horizontal space. Or you can use a table.

Link to comment
Share on other sites

so i think i am starting to wrap my head around this but i still need some clarifications.

 

for the code you suggested

return '<graphic file="mygraphic.jpg" width="' + Field("GraphicWidth") + '" height="' + Field("GraphicHeight") + '">';

what units are the dimensions in. I would assume it is in hundredths of a point, but i would like to set them to inches or feet if possible. Is there a way to do that?

 

Also, how would I do this for a customer uploaded graphic that i would not know the name of. I tried it like this so far, but no graphic shows up when in use.

 

varGraphic=Field("Graphic")  //set graphic to variable

if (Field("Height") == "1")  //find height
   {
   var1="LongSide1" //define variable for length field used with selected height
   varH=86400;          //define height in points
   }
if (Field("Height") == "1.5")
   {
   var1="LongSide1_5"
   varH=129600;
   }
if (Field("Height") == "2")
   {
   var1="LongSide2"
   varH=172800;
   }
if (Field("Height") == "2.5")
   {
   var1="LongSide2_5"
   varH=216000;
   }
if (Field("Height") == "3")
   {
   var1="LongSide3"
   varH=259200;
   }
else
   return "invalid Height";


if (Field(var1) == 1)   //find length
   {
   varL=86400;     //define length in points
   }
if (Field(var1) == 1.5)
   {
   varL=129600;
   }
if (Field(var1) == 2)
   {
   varL=172800;
   }
if (Field(var1) == 2.5)
   {
   varL=216000;
   }
if (Field(var1) == 3)
   {
   varL=259200;
   }
else
   return "invalid width";


return '<graphic file=varGraphic width="' + varL + '" height="' + varW + '">';

 

any suggestions on how to fix this so it works?

Link to comment
Share on other sites

what units are the dimensions in. I would assume it is in hundredths of a point,

Yes, this is documented in the FusionPro Tags Reference Guide, in the section titled, "Graphic Tag Inside Story Tag."

but i would like to set them to inches or feet if possible. Is there a way to do that?

Well, sure, there are 100 "hundredths of an point" in an point, and 72 points in an inch, and 12 inches in a foot, so you would do something like this:

return '<graphic file="mygraphic.jpg" width="' + (Int(Field("GraphicWidthInches")) * 7200) + '">';                      

Or even:

return '<graphic file="mygraphic.jpg" width="' + (Int(Field("GraphicWidthFeet")) * 7200 * 12) + '">';                      

Although if you're doing things measured in many feet, you probably want to compose something smaller and scale it up on your large-format printer.

Also, how would I do this for a customer uploaded graphic that i would not know the name of. I tried it like this so far, but no graphic shows up when in use.

 

//...
return '<graphic file=varGraphic width="' + varL + '" height="' + varW + '">';

any suggestions on how to fix this so it works?

Yes. There are a couple of problems with that last line. If you click "Validate," you should see what each one one is

 

The first problem is that you're mixing up your variable names; I think that "varW" should be "varH" to match the rest of the rule.

 

Once you fix that, if you click "Validate" again, you'll see that you're returning a tag such as:

 

<graphic file=varGraphic width="259200" height="259200">

 

Obviously you want the actual filename instead calling out a file named "varGraphic." You also probably want to use quotes in case there's a space in the name. So I think you want to do this:

return '<graphic file="' + varGraphic + '" width="' + varL + '" height="' + varL + '">';

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...