Jump to content

new FPTable behaves differently in MarcomCentral vs FusionPro, help?


CCS_Printing

Recommended Posts

I am very new to JavaScript code and FusionPro and have been working to use a table to create a grid of prices. I can get the behavior I need in Acrobat/FusionPro but when the Product is imported into MarcomCentral the Product behavior is different.

 

I need the prices to have a superscript dollar "$" sign and cents. The price also needs to center into the area it is printing without wrapping.

 

Please see the attached screen captures and my code below (please be gentle, I'm really just learning JS)

 

FusionPro Preview:

http://forums.pti.com/picture.php?albumid=26&pictureid=46

 

MarcomCentral Preview:

http://forums.pti.com/picture.php?albumid=26&pictureid=47

 

// FPTable with Vars - v04 - cat
//----------------------------------------------------------------
var symbol = '<superscript>'+"$"+'</superscript>';

// Prices
var col01 = symbol + Field("column01_DOLLAR") + '<superscript>' + Field("column01_CENT") + '</superscript>';
var col02 = symbol + Field("column02_DOLLAR") + '<superscript>' + Field("column02_CENT") + '</superscript>';
var col03 = symbol + Field("column03_DOLLAR") + '<superscript>' + Field("column03_CENT") + '</superscript>';
var col04 = symbol + Field("column04_DOLLAR") + '<superscript>' + Field("column04_CENT") + '</superscript>';
var col05 = symbol + Field("column05_DOLLAR") + '<superscript>' + Field("column05_CENT") + '</superscript>';
var col06 = symbol + Field("column06_DOLLAR") + '<superscript>' + Field("column06_CENT") + '</superscript>';
var col07 = symbol + Field("column07_DOLLAR") + '<superscript>' + Field("column07_CENT") + '</superscript>';
var col08 = symbol + Field("column08_DOLLAR") + '<superscript>' + Field("column08_CENT") + '</superscript>';
var col09 = symbol + Field("column09_DOLLAR") + '<superscript>' + Field("column09_CENT") + '</superscript>';

//----------------------------------------------------------------
// Table
var table = new FPTable;
var Tmar = 50
var Bmar = 50
var MinH = 2880


table.AddColumns(3499.2, 3499.2, 3499.2, 3499.2, 3499.2, 3499.2, 3499.2, 3499.2, 3499.2);
table.AddRows(19);
table.Rows[0].minHeight = MinH;
table.Rows[0].Cells[0].HAlign = "Center";
table.Rows[0].Cells[0].VAlign = "Middle";
table.Rows[0].Cells[0].Margins = new FPTableMargins; 
table.Rows[0].Cells[0].Margins.Top = Tmar;
table.Rows[0].Cells[0].Margins.Bottom = Bmar;
//table.Rows[0].Cells[0].Bold="On"; table.Rows[0].CopyCells(0,1,2,3,4,5,6,7,8);
table.Rows[0].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[1].minHeight = MinH;
table.Rows[1].Cells[0].Margins = new FPTableMargins;
table.Rows[1].Cells[0].Margins.Top = Tmar;
table.Rows[1].Cells[0].Margins.Bottom = Bmar;
table.Rows[1].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[2].minHeight = MinH;
table.Rows[2].Cells[0].Margins = new FPTableMargins;
table.Rows[2].Cells[0].Margins.Top = Tmar;
table.Rows[2].Cells[0].Margins.Bottom = Bmar;
table.Rows[2].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[3].minHeight = MinH;
table.Rows[3].Cells[0].Margins = new FPTableMargins;
table.Rows[3].Cells[0].Margins.Top = Tmar;
table.Rows[3].Cells[0].Margins.Bottom = Bmar;
table.Rows[3].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[4].minHeight = MinH;
table.Rows[4].Cells[0].Margins = new FPTableMargins;
table.Rows[4].Cells[0].Margins.Top = Tmar;
table.Rows[4].Cells[0].Margins.Bottom = Bmar;
table.Rows[4].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[5].minHeight = MinH;
table.Rows[5].Cells[0].Margins = new FPTableMargins;
table.Rows[5].Cells[0].Margins.Top = Tmar;
table.Rows[5].Cells[0].Margins.Bottom = Bmar;
table.Rows[5].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[6].minHeight = MinH;
table.Rows[6].Cells[0].Margins = new FPTableMargins;
table.Rows[6].Cells[0].Margins.Top = Tmar;
table.Rows[6].Cells[0].Margins.Bottom = Bmar;
table.Rows[6].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[7].minHeight = MinH;
table.Rows[7].Cells[0].Margins = new FPTableMargins;
table.Rows[7].Cells[0].Margins.Top = Tmar;
table.Rows[7].Cells[0].Margins.Bottom = Bmar;
table.Rows[7].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[8].minHeight = MinH;
table.Rows[8].Cells[0].Margins = new FPTableMargins;
table.Rows[8].Cells[0].Margins.Top = Tmar;
table.Rows[8].Cells[0].Margins.Bottom = Bmar;
table.Rows[8].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[9].minHeight = MinH;
table.Rows[9].Cells[0].Margins = new FPTableMargins;
table.Rows[9].Cells[0].Margins.Top = Tmar;
table.Rows[9].Cells[0].Margins.Bottom = Bmar;
table.Rows[9].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[10].minHeight = MinH;
table.Rows[10].Cells[0].Margins = new FPTableMargins;
table.Rows[10].Cells[0].Margins.Top = Tmar;
table.Rows[10].Cells[0].Margins.Bottom = Bmar;
table.Rows[10].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[11].minHeight = MinH;
table.Rows[11].Cells[0].Margins = new FPTableMargins;
table.Rows[11].Cells[0].Margins.Top = Tmar;
table.Rows[11].Cells[0].Margins.Bottom = Bmar;
table.Rows[11].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[12].minHeight = MinH;
table.Rows[12].Cells[0].Margins = new FPTableMargins;
table.Rows[12].Cells[0].Margins.Top = Tmar;
table.Rows[12].Cells[0].Margins.Bottom = Bmar;
table.Rows[12].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[13].minHeight = MinH;
table.Rows[13].Cells[0].Margins = new FPTableMargins;
table.Rows[13].Cells[0].Margins.Top = Tmar;
table.Rows[13].Cells[0].Margins.Bottom = Bmar;
table.Rows[13].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[14].minHeight = MinH;
table.Rows[14].Cells[0].Margins = new FPTableMargins;
table.Rows[14].Cells[0].Margins.Top = Tmar;
table.Rows[14].Cells[0].Margins.Bottom = Bmar;
table.Rows[14].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[15].minHeight = MinH;
table.Rows[15].Cells[0].Margins = new FPTableMargins;
table.Rows[15].Cells[0].Margins.Top = Tmar;
table.Rows[15].Cells[0].Margins.Bottom = Bmar;
table.Rows[15].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[16].minHeight = MinH;
table.Rows[16].Cells[0].Margins = new FPTableMargins;
table.Rows[16].Cells[0].Margins.Top = Tmar;
table.Rows[16].Cells[0].Margins.Bottom = Bmar;
table.Rows[16].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[17].minHeight = MinH;
table.Rows[17].Cells[0].Margins = new FPTableMargins;
table.Rows[17].Cells[0].Margins.Top = Tmar;
table.Rows[17].Cells[0].Margins.Bottom = Bmar;
table.Rows[17].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

table.Rows[18].minHeight = MinH;
table.Rows[18].Cells[0].Margins = new FPTableMargins;
table.Rows[18].Cells[0].Margins.Top = Tmar;
table.Rows[18].Cells[0].Margins.Bottom = Bmar;
table.Rows[18].SetContents(col01, col02, col03, col04, col05, col06, col07, col08, col09);

return table.MakeTags();

Link to comment
Share on other sites

First, I can't resist taking your code, which is quite repetitive, and using some for loops to significantly reduce it, like so:

// FPTable with Vars - v04 - cat
//----------------------------------------------------------------
var symbol = '<superscript>'+"$"+'</superscript>';

var table = new FPTable;

// Prices
var col = new Array(10); // col[0] unused; 1-9 used
for (var i = 1; i <= 9; i++)
{
   table.AddColumn(3499.2);

   var num = "0" + i;
   col[i] = symbol + Field("column" + num + "_DOLLAR") + '<superscript>' + Field("column" + num + "_CENT") + '</superscript>';
}

//----------------------------------------------------------------
// Table
var Tmar = 50;
var Bmar = 50;
var MinH = 2880;

for (var r = 0; r < 19; r++)
{
   var row = table.AddRow();
   row.minHeight = MinH;

   for (var c = 0; c < 9; c++)
   {
       var cell = row.Cells[c];
       cell.HAlign = "Center";
       cell.VAlign = "Middle";
       cell.Margins = new FPTableMargins; 
       cell.Margins.Top = Tmar;
       cell.Margins.Bottom = Bmar;
       cell.Content = col[c + 1];
   }
}

return table;

As to why this is composing differently in MarcomPortal, as Thomas notes, that's hard to say without more information.

 

My guess is that you're using the rich text editor in Marcom to add formatted text, which is adding a tag such as <z newsize=10> to your data fields, causing the price data fields to be in a different font size than in the flat file data you're using in the FusionPro Creator composition (in Acrobat).

 

Or perhaps it's something more fundamental, such as a mismatch in the collected template files you've uploaded to MarcomCentral.

 

At any rate, I would start by getting the composition log file from the online composition. You can do this by viewing the output in the web browser, then going to the browser's address bar and changing the extension at the end of the URL from .pdf to .msg.

Link to comment
Share on other sites

How do you define fonts and font properties in Rules?

In my version of the rule above, in the loop:

        cell.Font = "Arial";
       cell.PointSize = 10;

Though if the data has formatting tags in it (such as from the rich text editor in MarcomCentral), those tags will take precedence over the font and size set in the rule.

Link to comment
Share on other sites

Mr Korn,

 

You rock!

I'm not really a coder but I'm learning as a go, and I have a lot to lear (obviously).

 

Functions, for loops, and object definitions (lions, tigers, and bears.. Oh my!) are still "magic fairy dust" concepts at this point, so my code is way bulkier than it really needs to be.

 

Add to that, that I'm coming from a Python environment and things get "interesting" :D

 

I'm still researching the other information you suggested I look for...

Link to comment
Share on other sites

Mr Korn,

 

I could not see a place to view the Preview pdf in the browser as you described, but the Composition ".msg" file had the following (which to even my un-practiced eye looks a little bad)

file name: "1zvnutsd.msg" (I've attached the Print Proof packaged file)

 

 

Unknown Tag DataSource_FPWE ignored.
Unknown Tag DataSource_FPWE ignored.
Job started 07:06:06 - 1667484366.
Creator: FusionPro(R) VDP Server 12.1.2
Computer Name: LVPFPI02
Current working folder: D:\US\ImageServer\bin
Temporary files folder: C:\Users\Public\Documents\PTI\FusionPro\TEMP\TEMP_6624\
Template File: \\lvpfsc02.dc.pti.com\tempvol\tmp\1zvnutsd.dif
Input File: \\lvpfsc02.dc.pti.com\tempvol\tmp\1zvnutsd.xml
Job Config File: \\lvpfsc02.dc.pti.com\tempvol\tmp\1zvnutsd.cfg
Rule "KeylineGraphicRULE": Function does not return a value.
Composing record #1, input record 1
Font <Helvetica> is not a loaded font.  Using default instead.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
Word <29> does not fit in frame after line 0.
Word <39> does not fit in frame after line 0.
Word <69> does not fit in frame after line 0.
Word <22> does not fit in frame after line 0.
Word <109> does not fit in frame after line 0.
Word <99> does not fit in frame after line 0.
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <>.  Text is truncated.

Job ended 07:06:06 - 1667484366.
Total Job Time: 

Product_107_1zvnutsd_Composition_1zvnutsd.zip

Link to comment
Share on other sites

Mr Korn,

 

I could not see a place to view the Preview pdf in the browser as you described, but the Composition ".msg" file had the following (which to even my un-practiced eye looks a little bad)

file name: "1zvnutsd.msg" (I've attached the Print Proof packaged file)

Thanks, that's exactly what I need to look at.

 

I tried your job, and the dollar and cents amounts simply don't fit into those narrow little cells without wrapping, at least not when they're longer text with two or three digits for the dollar amount and two digits for cents. I'm not sure how it's working at all in your FP Preview, though it looks from the picture like those cells are wider.

 

I see that you have copyfitting (Adjust text to fit) turned on for the frame, but I don't think that does what you think. Tables don't really get copyfitted like non-tables do. The whole idea of a table is that each row will grow taller to accommodate the content (of the tallest cell in the row) wrapping the text to multiple lines as needed, rather than the content shrinking to fit a cell of a fixed size. You can set the minimum height for a row, which you are, but not a maximum.

 

Likewise, the entire table will grow in height as more rows (or larger rows) are added, so tables aren't usually expected to fit into a frame of a particular height; usually there will be an overflow page to accommodate tables with variable numbers or rows, such as in a bill statement.

 

So, to make this work, you need to change the point size of the text, to make it smaller. You can simply change the point size in the text frame where you're calling out the table rule. When I set it to 8 points it all seemed to fit just fine.

 

If you do really want to adjust the size of the content to fit into the table cell without wrapping to multiple lines, you can do that with a call to a function such as CopyfitLine. That's getting more complicated, and I'm not sure whether it's worth getting into until we're sure that's the effect you want.

Link to comment
Share on other sites

I think the real issue here is the lack of left and right margins being set in the code. I modified Dan's code to include a copyfit function with the proper margins set and it seems to work great.

 

function cf(formatted_text_content, frame_width)
{
fptm = new FusionProTextMeasure;
fptm.CalculateTextExtent(formatted_text_content);

   frame_width -= 500; //add some padding so content doesn't fill entire width

if (fptm.textWidth > frame_width)
{
	var magnify = Math.floor((frame_width / fptm.textWidth) * 100.0);

	return '<span><magnify type="textwidth" factor="' + magnify + '">' + formatted_text_content + '</magnify></span>';
}
   else return formatted_text_content;
}


// FPTable with Vars - v04 - cat
//----------------------------------------------------------------
var font_format = '<f name="BrownStd"><z newsize=12>';
var symbol = '<superscript>'+"$"+'</superscript>';

var table = new FPTable;
var col_width = 3499.2;

// Prices
var col = new Array(10); // col[0] unused; 1-9 used
for (var i = 1; i <= 9; i++)
{
   table.AddColumn(col_width);

   var num = "0" + i;
   col[i] = cf(font_format + '<b>' + symbol + Field("column" + num + "_DOLLAR") + '<superscript>' + Field("column" + num + "_CENT") + '</superscript></b>', col_width);
}

//----------------------------------------------------------------
// Table
var MinH = 2880;

for (var r = 0; r < 19; r++)
{
   var row = table.AddRow();
   row.minHeight = MinH;

   for (var c = 0; c < 9; c++)
   {
       var cell = row.Cells[c];
       cell.HAlign = "Center";
       cell.VAlign = "Middle";
       cell.Margins = new FPTableMargins; 
       cell.Margins.Top = 0;
       cell.Margins.Bottom = 0;
       cell.Margins.Left = 0;
       cell.Margins.Right = 0;
       cell.Content = col[c + 1];
   }
}

return table;

Link to comment
Share on other sites

Thomas,

 

You rock! That code did it!

 

Now I just need to get to the point that I totally understand how this is built so that I can get to a place where I can build this on my own!

 

Thank you Dan and Thomas!!

 

http://forums.pti.com/picture.php?albumid=26&pictureid=48

 

:eek::D

Edited by CCS_Printing
Adding image
Link to comment
Share on other sites

×
×
  • Create New...