Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text


Thread Tools Search this Thread Display Modes
Old February 17th, 2010, 04:42 PM
EricC EricC is offline
Regular Contributor
Join Date: Nov 2008
Posts: 87
Exclamation Formatting text based on special characters

i am building a printOne web template.

i want to offer one large, multi-line text box which will allow the user to enter something like this:

notice the following:
the "time" is always 38 point bold.
the "description" that appears below it is always 36 point.
the "text" is always three columns, and always 22 point.

how do i allow the user to determine the font name and size?

i don't think printable's on-line rich-text editor allows this much flexibility, so here's what i was thinking ...

IF the user types a pound sign (#), followed by the actual text ...
whatever he/she types on that line will appear in 38 point bold text.

IF the user types a dollar sign ($), followed by the actual text ...
whatever he/she types on that line will appear in 36 point text.

IF the user types a plus sign (+), followed by the actual text ...
whatever he/she types on that line will be preceded with a bullet character, and will appear in 22 point text.

so, in the multi-line text box, the user would type something like this:

#8:00–9:00 a.m.
$Here is a description of what happens between 8 and 9:
+text a text g text m
+text b text h text n
+text c text i text o
+text d text j text p
+text e text k text q
+text f text l text r

Can you help me write a rule which will do this?
(replace "#" with "<font size=36 ...>", etc)

Also, how would I address the three columns of bulleted text?
Reply With Quote
Old February 18th, 2010, 06:13 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Formatting text based on special characters

I started playing with the logic for setting something up for your example, but don't have the time to totally flesh out a solution. I'm including my commented code below for you to possibly build upon.

Personally, I think it would be easier to provide separate text fields for user input to pre-separate values rather than trying to force the user to input text via some wiki-like formatting system. It would also help simplify the back-end code.

I'm also uncertain how allowing the end user to pick a custom font would affect output since each font comes with it's own spacing issues. At the very least, I would allow only a set number of font choices, perhaps in a dropdown list.

// input bulleted items as single entries (+textA \n +textB \n +textC \n...)
// rather than 3-item lines (+textA textG textM \n...)

// create array of input text splitting on new lines (or line breaks "<br>")
var input = Field("inputText").split("\n");

// split previous array into separate arrays for each entry type
var timeEntry = [];
var descriptionEntry = [];
var bulletEntry = [];
for (i=0; i<input.length; i++) {
	if (Left(input[i],1) == "#") { 
	} else if (Left(input[i],1) == "$") {
	} else if (Left(input[i],1) == "+") {
		if (input[i+1] == "") {
		} else {
	} else return FusionPro.ReportWarning("text input is not formatted correctly");

// Join bulletArray into one string and then split twice to create new array:
// * once by "%NEW%" to have separate value for each section
// * split those values into a sub-array by "+" for each bullet

// set static font names as they would appear in FP text editor
// if you plan to let end-user choose one of several fonts,
// you will have to generate FP font name based on contents of field
// perhaps via a function using a switch statement?
var TimeFont = ;
var DescriptionFont = ; 
var TextFont = ;

// generate table structure and populate cells with data from
// previous arrays
var timeTag = "<font size=\"38\" name=\"" + TimeFont + "\">";
var descriptionTag = "<font size=\"36\" name=\"" + DescriptionFont + "\">";
var textTag = "<font size=\"22\" name=\"" + TextFont + "\">";

Set up embedded loops to cycle through each array's data as table tags are
var table = "<table>\n";
table += ; //...

// make sure tagged text option is checked
return table;
Eric Smith
Content Developer
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
Old February 18th, 2010, 06:37 AM
EricC EricC is offline
Regular Contributor
Join Date: Nov 2008
Posts: 87
Default Re: Formatting text based on special characters

the user can potentially add any number of headlines (8:00-9:00 am), any number of sub-headlines (Here is a description...) and any number of body text lines.

in order to accommodate that i would have to have a potentially large number of text boxes.

so i thought it would be best to just give the user one big text box and let them enter whatever they want, and control the formatting by using special characters.

i'm not sure this is the way to go and i wish printable would one day expand the capabilities of their on-line rich text editor.

in the meantime i have a huge project that requires this functionality.

thanks for your help.
i'll try it now and post the results...
Eric Carbone
IT/Project Manager, MOR Printing Inc.

Windows 10 |Adobe Acrobat XI | FusionPro 9
Reply With Quote
Old February 14th, 2011, 10:46 AM
dcb_creative dcb_creative is offline
Junior Community Member
Join Date: Jan 2011
Posts: 15
Default Re: Formatting text based on special characters

Most of the templates I create would benefit from expanded functionality in the rich text editor due to the exact same reason: to create flexibility. The ability to have drop down styles to apply to text in the rich text editor would solve so many issues. I would want to have control over the styles and then let the end user of the template apply them to their text at will.

I do not know how many times someone will want to use certain styles (in EricC's case: Time, Description, and Text), so I want them to be able to select the text and apply that style instead of filling out an entry box. I would have to otherwise create a template with a silly number of entry fields which they would then have to fill out in order to make it output they way they want. That is a completely unrealistic solution.

While I'm at it, adding in bullets would be a bonus. I find it funny that the WYSYWYG editor of this forum has it (including other features such as indent and numbered list) but the templates do not.
Reply With Quote

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 01:15 PM.

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