MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   Graphic Rules (http://forums.pti.com/forumdisplay.php?f=33)
-   -   Centering Inline Graphic (http://forums.pti.com/showthread.php?t=4610)

bkurzbuch June 10th, 2016 10:36 AM

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";

step June 10th, 2016 11:46 AM

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();



All times are GMT -7. The time now is 06:40 PM.

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