Go Back   PTI Marketing Technologies User Community > Software-Related Talk > Getting Started

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 21st, 2014, 02:26 PM
ChuckBrodeur ChuckBrodeur is offline
Junior Community Member
 
Join Date: Aug 2014
Location: Atlanta, GA
Posts: 28
Default Font Size Changes

New to Javascript but I have to write a rule that returns a string in which part of the string will be arial narrow 6 pt and another part will be arial narrow bold 10pt. Not sure how to write that. What I have so far returns the font size calls as well as the string text.

if(Field("***") !="3") {
return <font size="6"."Size "</font> + <font size="10">Field("SIZE"),/font>;
} else {
return " ";
}

I expect it to end up looking like:

Size 7 or something like that.

I haven't even started on the attributes for bold and font name until i can figure this out.

Thanks.
Reply With Quote
  #2  
Old October 21st, 2014, 03:09 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,225
Default Re: Font Size Changes

Those aren't valid markup tags for FusionPro. Just because FusionPro uses JavaScript as a scripting engine doesn't mean that you use the same markup tags that you would use in HTML.

The way to change point size in FusionPro markup is with a tag such as <z newsize=10>. To change the font name, you need a tag like <f name="Arial">. Bold and italic styles are requested with <b> and <i> tags. Please refer to the FusionPro Tags Reference manual for more information.

Here's a handy trick to be able to see what tagging FusionPro uses: Open the Resources dialog, click Add, select "Formatted Text" in the Type drop-down, click Edit, type some text, select whatever formatting you want with the controls, or in the Paragraph Formatting dialog, then click OK in the Text Editor dialog, and back in the Resource Editor dialog, click "View Source." This will show you all of the markup that corresponds to the selections you made in the GUI.

Also, if you're trying to output a data field value with some tagging, your JavaScript syntax is wrong. You need to do something like this:
Code:
return '<z newsize="6">Size <z newsize="10">' + Field("SIZE");
Note that you need to end the running literal text string with the tags with an ending quote, then append the Field function call with a plus sign.
__________________
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@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

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 October 22nd, 2014, 11:36 AM
ChuckBrodeur ChuckBrodeur is offline
Junior Community Member
 
Join Date: Aug 2014
Location: Atlanta, GA
Posts: 28
Default Re: Font Size Changes

I tried changing my return line to look like this:

return '<f name="Arial Narrow">',"Size ",'</f>' + '<z newsize="10"><b>',Field("Size"),'</b>';

But the value returned when I click the validate button is </b>. I have tried it without the quotation marks and without the commas, but keep getting syntax errors saying I am "missing ; before the statement". When I put in ; where the gray is showing in my script then validation only returns <f name="Arial Narrow">.

Not sure what to do next, I can't find in the guide doesn't where it covers this.
Reply With Quote
  #4  
Old October 22nd, 2014, 01:19 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,225
Default Re: Font Size Changes

Quote:
Originally Posted by ChuckBrodeur View Post
I tried changing my return line to look like this:

return '<f name="Arial Narrow">',"Size ",'</f>' + '<z newsize="10"><b>',Field("Size"),'</b>';

But the value returned when I click the validate button is </b>. I have tried it without the quotation marks and without the commas, but keep getting syntax errors saying I am "missing ; before the statement". When I put in ; where the gray is showing in my script then validation only returns <f name="Arial Narrow">.

Not sure what to do next, I can't find in the guide doesn't where it covers this.
This is no longer an issue of getting the FusionPro markup tags right; it's an issue of your JavaScript syntax. It looks like you're trying to use commas to concatenate strings together, but the actual string concatenation operator in JavaScript is + (the plus sign). So you need to replace those commas with plus signs, like so:
Code:
return '<f name="Arial Narrow">' + "Size " + '</f>' + '<z newsize="10"><b>' + Field("Size") + '</b>';
Although most of the plus signs between string literals can be removed by simply combining those literals:
Code:
return '<f name="Arial Narrow">Size </f><z newsize="10"><b>' + Field("Size") + '</b>';
And there is actually one other possibility, although you'll only see the actual field value when you compose, not when you click Validate:
Code:
return '<f name="Arial Narrow">Size </f><z newsize="10"><b><variable name="Size"></b>';
__________________
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@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

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)});

Last edited by Dan Korn; October 22nd, 2014 at 01:23 PM.. Reason: added <variable> tag example
Reply With Quote
  #5  
Old October 22nd, 2014, 01:42 PM
ChuckBrodeur ChuckBrodeur is offline
Junior Community Member
 
Join Date: Aug 2014
Location: Atlanta, GA
Posts: 28
Default Re: Font Size Changes

This is still not working, if I put the +'s in then I get the whole string printing out including the font tags.

Sorry this is so rudimentary, but if I write the line like this:

return "Size " + Field("Size");

It prints correctly (Size 7, for example).

But the second I try to tag it to make the 7 bigger and bold is when I get into my problem. From reading the tag guide and looking at your examples the code you wrote should work. Should I be using a different operator other than return? Does it make a difference that I am using FusionPro VDP Producer (API) 9.3.5 on a pc running XP SP3?
Reply With Quote
  #6  
Old October 22nd, 2014, 01:48 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,225
Default Re: Font Size Changes

Quote:
Originally Posted by ChuckBrodeur View Post
This is still not working, if I put the +'s in then I get the whole string printing out including the font tags.
You need to check the "Treat returned strings as tagged text" box, near the top of the Rule Editor dialog.

Technically, when you do that, you should account for markup-like characters in the data as well, by using the TaggedTextFromRaw or TaggedDataField functions. So the ultimate solution is to check that box, and do this:
Code:
return '<f name="Arial Narrow">Size </f><z newsize="10"><b>' + TaggedDataField("Size") + '</b>';
__________________
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@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

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
  #7  
Old October 22nd, 2014, 02:27 PM
ChuckBrodeur ChuckBrodeur is offline
Junior Community Member
 
Join Date: Aug 2014
Location: Atlanta, GA
Posts: 28
Default Re: Font Size Changes

That seemed to work when I do the preview template but the validation window still shows the string of code so it was confusing and making me think it wasn't working.

Thanks for all your help on this!
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 09:18 AM.


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