rjohns Posted March 4, 2016 Share Posted March 4, 2016 Is there a way to set global paragraph and character styles in FusionPro? I know that I can set paragraph attributes inline within my rules, but it’d be great it I could define these globally and then call them when needed. I looked through the available documentation and searched the community forum and couldn’t find an answer. I’m assuming you can since there’s a way since I’ve seen <p style=“Head1”> in the documentation, but I don’t see information about how to do that globally. Any information would be appreciated – thank you! Quote Link to comment Share on other sites More sharing options...
step Posted March 4, 2016 Share Posted March 4, 2016 Is there a way to set global paragraph and character styles in FusionPro? I know that I can set paragraph attributes inline within my rules, but it’d be great it I could define these globally and then call them when needed. What did you have in mind? You could definitely create a global variable to hold inline paragraph styles that you could then call from other rules: heading = '<p style="Header" br=false leading=140 quad="C">'; body = '<p style="Body" leading=120 quad="L">'; Then your text rules would look like: return heading + 'This is a Centered Header' + body + 'This is left justified body text'; Then you'll be able to adjust the values of those tags by editing the variables in the "JavaScript Globals" rather than modifying them in each of your text rules. For that matter, you could create functions that formatted your text with font styles and sizes if you wanted to: function Header(str) { return '<p style="Header" br=false leading=140 quad="C"><span font="Arial" pointsize="12">' + str + '</span>'; } Then just call it from your text rules: return Header('This is a Centered Header in Arial 12pt'); Quote Link to comment Share on other sites More sharing options...
rjohns Posted March 4, 2016 Author Share Posted March 4, 2016 This is exactly what I was looking for –*thank you!! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted March 4, 2016 Share Posted March 4, 2016 If you export from InDesign, all of the paragraph styles from InDesign are brought over and can be invoked with the style attribute of the <p> tag. So if you have a style named "Body" in InDesign, you can indeed use a tag such as <p style="Body"> in the exported FusionPro template. Quote Link to comment Share on other sites More sharing options...
rjohns Posted March 8, 2016 Author Share Posted March 8, 2016 Dan: I don't know how I've gotten this far without knowing that FusionPro picks up the InDesign styles! This is awesome – it should make life much easier now. :-D I've got a related question ... I created a function using the methodology that Ste recommended: function Header(str) { return '<p style="CV Section" leading=40 leadafter=200><color name="PANTONE 361 C">' + str + '</color></p>'; } Now, I need to swap the color based on the value of another field. The way I approached this was defining a variable with a complex if statement and adding that variable to the function. But I'm getting an undefined error. if (Field("Color") == "Plum") var accentColor = '<color name="PANTONE 5195 C">'; else if (Field("Color") == "Orange") var accentColor = '<color name="PANTONE 153 C">'; else if (Field("Color") == "Red") var accentColor = '<color name="PANTONE 704 C">'; else if (Field("Color") == "Green") var accentColor = '<color name="PANTONE 361 C">'; else var accentColor = '<color name="PANTONE 5425 C">'; function Header(str) { return '<p style="CV Section" leading=40 leadafter=200>' + accentColor + str + '</color></p>'; } Is this the way I should be going about it? Or is there an easier way? Thanks again for the help! Quote Link to comment Share on other sites More sharing options...
step Posted March 8, 2016 Share Posted March 8, 2016 Now, I need to swap the color based on the value of another field. The way I approached this was defining a variable with a complex if statement and adding that variable to the function. But I'm getting an undefined error. Is this the way I should be going about it? Or is there an easier way? Thanks again for the help! The problem is that you've defined 'accentColor' outside the scope of the 'Header' function. That if statement needs to be within the function: function Header(str) { if (Field("Color") == "Plum") var accentColor = '<color name="PANTONE 5195 C">'; else if (Field("Color") == "Orange") var accentColor = '<color name="PANTONE 153 C">'; else if (Field("Color") == "Red") var accentColor = '<color name="PANTONE 704 C">'; else if (Field("Color") == "Green") var accentColor = '<color name="PANTONE 361 C">'; else var accentColor = '<color name="PANTONE 5425 C">'; return '<p style="CV Section" leading=40 leadafter=200>' + accentColor + str + '</color></p>'; } Or if you'd like to shorten things up a little bit: function Header(str) { var color = { 'Plum' : '5195', 'Orange': '153', 'Red' : '704', 'Green' : '361' }[Field('Color')] || '5425'; return '<p style="CV Section" leading=40 leadafter=200><color name="PANTONE ' + color + ' C">' + str + '</color></p>'; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.