Go Back   PTI Marketing Technologies User Community > Software-Related Talk > The JavaScript Library > Graphic Rules

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 10th, 2016, 10:36 AM
bkurzbuch bkurzbuch is offline
Regular Contributor
 
Join Date: May 2014
Posts: 64
Default Centering Inline Graphic

I'm trying to center a inline graphic vertically to the text with no luck. Code is below. To have control over the vertical alignment should I use a subscript ratio instead and how would I add that. Currently the graphic is aligned baseline with the tex. Thanks for the help.

Code:
return Resource("Check Box") ;alignv="Center";
Reply With Quote
  #2  
Old June 10th, 2016, 11:46 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 921
Default Re: Centering Inline Graphic

I don't think you can superscript graphic files. You could, however, put your content in a table with two columns. The left column could be set to the width of your check box graphic and the right column could have a width of the remaining width of the text frame. Both cells in the row would be given a vertical alignment of "middle" so that the check box floats in the middle of the text. This would also give you a little more flexibility if you wanted to adjust the spacing between the checkbox and the text – you could just make the checkbox column wider.

Code:
var checkbox = Resource('Check Box');
var txt = Field('Your field');
var checkboxWidth = 3000; // in 1/100 pts -> 7200 = 1"

var frameWidth = FusionPro.inValidation ? 14400 : 
  GetSettableTextWidth(FindTextFrame(FusionPro.Composition.CurrentFlow.name));

var table = new FPTable();
table.AddColumns(checkboxWidth, frameWidth-checkboxWidth);
var row = table.AddRow();
var cell = row.Cells[0]
cell.VAlign = 'Middle';
row.CopyCells(0,1);
row.SetContents(checkbox, txt);

return table.MakeTags();
"Re-evaluate this rule for every text flow" and "Treat strings as tagged text" need to be checked in the rule editor. You'll also need to name your text frame.

On the other hand, if you set the width of the text frame yourself (in 100th's of a point), you don't need to name the frame or select "Re-evaluate this rule for every text flow":
Code:
var checkbox = Resource('Check Box');
var txt = Field('Your field');
var checkboxWidth = 3000; // in 1/100 pts -> 7200 = 1"
var frameWidth = 14400;   // 14400 = 2"

var table = new FPTable();
table.AddColumns(checkboxWidth, frameWidth-checkboxWidth);
var row = table.AddRow();
var cell = row.Cells[0]
cell.VAlign = 'Middle';
row.CopyCells(0,1);
row.SetContents(checkbox, txt);

return table.MakeTags();
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
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 02:29 PM.


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