Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 22nd, 2015, 03:05 PM
seymoujd seymoujd is offline
Junior Community Member
 
Join Date: Jul 2014
Posts: 40
Default Setting tabs as part of a function

Wanted to create a function that allows users to choose a style from Field A that formats the text they enter in Field B.

I came up with the following function which appears to work pretty well. My problem arrises when I come to the "Bullets" case I need bulleted text to have a tab stop of .125 in and a second line indent of 0p9. Is there a way to include this in the switch statement so that it doesn't effect all the other fields in the text frame?

Code:
function styleText(style,text){

titleFormat = '<color name="NSU green"><f name ="Interstate Black"><z newsize="28">';
subtitleFormat = '<color name="NSU green"><f name ="Interstate RegularCondensed"><z newsize="20">';

headFormat = '<color name="NSU green"><f name ="Interstate BlackCondensed"><z newsize="16"><uppercase>';
subheadFormat = '<color name="black"><f name ="Interstate RegularCondensed"><z newsize="14">';

bulletCharFormat = '<color name="nsultgreen"><f name ="Interstate Black"><z nesize="10">';
bulletTextFormat = '<color name="black"><f name ="Aldine401 BT"><z newsize="10">';

plainTextFormat ='<color name="black"><f name ="Aldine401 BT"><z newsize="10">';
    
    var result;
    
    
        
    switch (style) {
        case "Title":
            result = titleFormat+text;
            break;
            
        case "Subtitle":
            result = subtitleFormat+text;
            break;
            
        case "Head":
            result = headFormat+text;
            break;
        
        case "Subhead":
            result = subheadFormat+text;
            break;

        case "Bullets":
            var MyVar=text;
            var MyArray=MyVar.split("<p>");
            var MyString='<p>'+bulletCharFormat+'»<t>'+bulletTextFormat+MyArray[0];
            
            if (MyVar==""){
                return "";
            }else{
                for (i=1;i<MyArray.length;i++){
                    MyString+='<br><p>'+bulletCharFormat+'»<t>'+bulletTextFormat +MyArray[i];
                }
            };
            return MyString;
            break;

        case "Plain Text":
            result = plainTextFormat+text;
            break;

        default:
            result = plainTextFormat+text;
        }
    return result;
};
Reply With Quote
  #2  
Old October 22nd, 2015, 04:47 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,467
Default Re: Setting tabs as part of a function

Tabs are part of the paragraph style, specified as the "tabstops" attribute of the <p> tag. I would set up the tab stops you want in a Formatted Text Resource and use the "View Source" button to see exactly what the markup is, and of course refer to the Tags Reference Guide.

As for setting the tabs "so that it doesn't effect all the other fields in the text frame," the paragraph style is reset at the start of each new paragraph entered in the Text Editor, so that should just happen automatically.

The other trick with <p> tags (which you can see with that "View Source" button") is that you can use the attributes br=false and override=true to override the running paragraph's style, without actually starting a new paragraph. (Also, you can use the <br> tag as a "soft return" to start a new line without actually starting a new paragraph.)

The other thing you need is an indent, which is also an attribute of the <p> tag; in this case, it's "lindent" for all lines after the first. (The "fiindent" attribute applies to the first line.)

At any rate, DSweet has already provided almost exactly the markup you need in this post:
http://forums.pti.com/showpost.php?p=442&postcount=5
__________________
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 23rd, 2015, 07:52 AM
seymoujd seymoujd is offline
Junior Community Member
 
Join Date: Jul 2014
Posts: 40
Default Re: Setting tabs as part of a function

That worked! Thank you.

I have one more question. For some reason the bullet character for the first paragraph in each list is larger that the rest. What is causing that?

I have attached a screen shot to show what is happening. Here is my updated code

Code:
function styleText(style,text){

titleFormat = '<p linespacing=".75"><color name="NSU green"><f name ="Interstate Black"><z newsize="28">'; //
subtitleFormat = '<color name="NSU green"><f name ="Interstate RegularCondensed"><z newsize="20">';

headFormat = '<p leadafter="450"><color name="NSU green"><f name ="Interstate BlackCondensed"><z newsize="16"><uppercase>'; 
subheadFormat = '<p leadafter="450"><color name="black"><f name ="Interstate RegularCondensed"><z newsize="14">';

bulletCharFormat = '<p style="(no style)" br="false" override="true" quad="L" linespacing="1" findent="0" lindent="0" rindent="0" leadbefore="0" leadafter="450" keeplines="true" widows="2" kerning="true" hyphenate="false" skipifempty="false" skipifemptyvar="false" noparabreakoncopyfit="false" tabstops="0;R900,Left"><color name="nsultgreen"><f name ="Interstate Bold"><z nesize="10">';
bulletTextFormat = '<p style="(no style)" br="false" override="true" quad="L" linespacing="1" findent="0" lindent="1800" rindent="0" leadbefore="0" leadafter="450" keeplines="true" widows="2" kerning="true" hyphenate="false" skipifempty="false" skipifemptyvar="false" noparabreakoncopyfit="false" tabstops="0;R900,Left"><color name="black"><f name ="Aldine401 BT"><z newsize="10">';

plainTextFormat ='<color name="black"><f name ="Aldine401 BT"><z newsize="10">';
    
    var result;
    
    
        
    switch (style) {
        case "Title":
            result = titleFormat+text;
            break;
            
        case "Subtitle":
            result = subtitleFormat+text;
            break;
            
        case "Head":
            result = headFormat+text;
            break;
        
        case "Subhead":
            result = subheadFormat+text;
            break;

        case "Bullets":
            var MyVar=text;
            var MyArray=MyVar.split("<p>");
            var MyString= bulletCharFormat+'»<t>'+bulletTextFormat+MyArray[0];
            
            if (MyVar==""){
                return "";
            }else{
                for (i=1;i<MyArray.length;i++){
                    MyString+='<br><p>'+bulletCharFormat+'»<t>'+bulletTextFormat +MyArray[i];
                }
            };
            return MyString;
            break;

        case "Plain Text":
            result = plainTextFormat+text;
            break;

        default:
            result = plainTextFormat+text;
        }
    return result;
};
Attached Images
File Type: png Screen Shot 2015-10-23 at 9.30.47 AM.png (38.1 KB, 10 views)

Last edited by seymoujd; October 23rd, 2015 at 09:24 AM..
Reply With Quote
  #4  
Old October 23rd, 2015, 09:52 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,467
Default Re: Setting tabs as part of a function

Quote:
Originally Posted by seymoujd View Post
I have one more question. For some reason the bullet character for the first paragraph in each list is larger that the rest. What is causing that?
The problem is highlighted in Red here (you may need to scroll to the right):
Code:
bulletCharFormat = '<p style="(no style)" br="false" override="true" quad="L" linespacing="1" findent="0" lindent="0" rindent="0" leadbefore="0" leadafter="450" keeplines="true" widows="2" kerning="true" hyphenate="false" skipifempty="false" skipifemptyvar="false" noparabreakoncopyfit="false" tabstops="0;R900,Left"><color name="nsultgreen"><f name ="Interstate Bold"><z nesize="10">';
bulletTextFormat = '<p style="(no style)" br="false" override="true" quad="L" linespacing="1" findent="0" lindent="1800" rindent="0" leadbefore="0" leadafter="450" keeplines="true" widows="2" kerning="true" hyphenate="false" skipifempty="false" skipifemptyvar="false" noparabreakoncopyfit="false" tabstops="0;R900,Left"><color name="black"><f name ="Aldine401 BT"><z newsize="10">';
That should be <z newsize="10">, not <z nesize="10">.

In fact, if you compose and look in the composition log (.msg) file, there's probably a warning message saying something like "Unknown attribute nesize."

You also don't need to specify every attribute of the <p> tag every time, especially for values that already match the defaults, like zero indents. This should work just as well:
Code:
bulletCharFormat = '<p br="false" override="true" leadafter="450" lindent="1800" keeplines="true" kerning="true" hyphenate="false" tabstops="0;R900,Left"><color name="nsultgreen"><f name ="Interstate Bold"><z newsize="10">';
bulletTextFormat = '<f name ="Aldine401 BT"><z newsize="10">';
And you can take out the <p> tag after the <br> in case "Bullets" as well.

Another thing to know is that you can set up character and paragraph styles in InDesign; then when you export from InDesign, you can use those named paragraph styles in your <p> tags in FusionPro, such as <p name="Head">.
__________________
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
Reply

Tags
styling text, switch statement, tabs

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 10:48 PM.


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