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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 27th, 2016, 08:35 AM
MarkJonesEMKT MarkJonesEMKT is offline
Junior Community Member
 
Join Date: Dec 2015
Location: Virgina
Posts: 17
Default Center Justify based on field value

Hello All,

I want to be able to change how a line or paragraph is being justified based on the value of a specific field. I'm pretty new to both FP and JavaScript so I'm still figuring out syntax for these things. Here is what I am trying to do.

Code:
if(Field("Name") != "")
      return "Centered Text" + Field("Name");
return "Left Justified Text" + Field("Name");
I thought I may be able to use the "<span>" tags and I looked through the reference guide, but I didn't see anything on this specifically. I really appreciate any help offered.
Reply With Quote
  #2  
Old January 27th, 2016, 09:38 AM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: Center Justify based on field value

Quote:
Originally Posted by MarkJonesEMKT View Post
Hello All,

I want to be able to change how a line or paragraph is being justified based on the value of a specific field. I'm pretty new to both FP and JavaScript so I'm still figuring out syntax for these things. Here is what I am trying to do.

Code:
if(Field("Name") != "")
      return "Centered Text" + Field("Name");
return "Left Justified Text" + Field("Name");
I thought I may be able to use the "<span>" tags and I looked through the reference guide, but I didn't see anything on this specifically. I really appreciate any help offered.
Try something like this. Be sure to check Treat returned strings as tagged text.

Code:
if(Field("Name") != "")
      return '<p br="false" quad="C">' + Field("Name");
return '<p br="false" quad="L">' + Field("Name");
__________________
David Miller
FusionPro VDP Creator 10.0.26
Adobe Acrobat Pro 2019.008.20074
Suitcase Fusion 20.0.0 (7653)
macOS High Sierra 10.13.6

Last edited by David Miller; January 27th, 2016 at 09:46 AM..
Reply With Quote
  #3  
Old January 27th, 2016, 09:44 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Center Justify based on field value

If the "Name" field is empty, you want to return some left-justified text and the "Name" field? That seems odd.

Either way, the tag you're looking for is the paragraph tag (page 42 of the TagsRefGuide.pdf documentation). The "quad" attribute will allow you to adjust the alignment with values of "L," "R,", "C," and "J" (left, right, centered, and justified respectively). Keep in mind that a paragraph tag by default starts a new paragraph (adding a line break) so if you want to avoid a line break, use the 'br' attribute and set it to false.

So in your situation, you just want to determine if the alignment should be a "C" or an "L" based on the value of the "Name" field:
Code:
var align = Field("Name") ? 'C' : 'L';
var str   = Field("Name") ? 'Centered Text' + Field("Name") : 'Left Justified Text';
return '<p br=false quad=' + align + '>' + str;
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #4  
Old January 28th, 2016, 06:12 AM
MarkJonesEMKT MarkJonesEMKT is offline
Junior Community Member
 
Join Date: Dec 2015
Location: Virgina
Posts: 17
Default Re: Center Justify based on field value

When I try either of these options, I am getting the following result justified however the original paragraph settings had it.

Quote:
<p br="false" quad="C">Name
Reply With Quote
  #5  
Old January 28th, 2016, 07:23 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Center Justify based on field value

Did you see this?
Quote:
Originally Posted by David Miller View Post
Be sure to check Treat returned strings as tagged text.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #6  
Old January 28th, 2016, 03:02 PM
MarkJonesEMKT MarkJonesEMKT is offline
Junior Community Member
 
Join Date: Dec 2015
Location: Virgina
Posts: 17
Default Re: Center Justify based on field value

Quote:
Originally Posted by step View Post
Did you see this?
I had seen this, that is one of the things I do by default when I create a rule because almost everything needs it. I think something was going on with the server, because when I restarted it began working. Thanks for the help!
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 01:41 AM.


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