View Single Post
  #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: 955
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