Jump to content

returning a table


sschaefering

Recommended Posts

I am trying to format a string to return as a table. I keep getting this error:

Table cell margins exceed cell width; text cannot be set: Row 0, Column 0

Table cell margins exceed cell width; text cannot be set: Row 1, Column 0

Extra cell started <Line Items> row #0 - Ignoring

Table cell margins exceed cell width; text cannot be set: Row 2, Column 0

The amount of text inserted into a flow exceeds the depth

of all frames in the flow <(null)>. Text is truncated.

 

I'm using Desktop 6.21Pc on Acrobat 9. I have the treat returned strings as tagged text checked.

 

here is my code:

var returnStr = '';
var header = '';
var header1 = '';
var header2 = '';
var services = '';
var line = '';
var examplearray = '';
var oneMessage = '';
var messageContents = '';
var recordWalker = 0;

//If statement to check that user is in composition mode
if (FusionPro.Composition.isPreview == true || FusionPro.inValidation == true) {
   Rule("OnJobStart");
}

//Count the records in the external data
numRecsExtDF = externalDF.recordCount;

//Loop through data
for (recordWalker = 1; recordWalker <= numRecsExtDF; recordWalker++) {
    // <FONT style="BACKGROUND-COLOR: blue">text</FONT>
    // clear string variable 
   returnStr = 'DETAIL OF CURRENT CHARGES\n<story copyhole="DetailsTable"><table columns="2" space="above:0;below:0"'+ 
               '< column width=200 />'+
               '< column width=200 />'+
               '<z newsize=7>';

   // check for service details
   if (Field("SERVICE") != "") {
       line = Field("SERVICE");
       if (line.indexOf("|") != -1) {
           examplearray = line.split("|");
           for(x = 0; x < examplearray.length; x++) {
               value = examplearray[x];
               if(value != "") {
                   if (value.indexOf(":") != -1) {
                       oneMessage = value.split(':');
                       header = oneMessage[0];
                       header = header.replace("N          Premises Type", "Premise Type");
                       (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
                       header1 = header1.replace(/^\s+|\s+$/g, '');
                       header2 = header.substring(140, 50);
                       header2 = header2.replace(/^\s+|\s+$/g, '');
                       messageContents = oneMessage[1].split(':');
                       returnStr += '<row type="header"><cell hstraddle="4" shading="black,15" alignment="left"><p br=false quad=C>'+header1+'<cell hstraddle="4" shading="black,15" alignment="right"><p br=false quad=C>'+header2;
                   } else {
                       header = value;
                       header = header.replace("N          Premises Type", "Premise Type");
                       (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
                       header1 = header1.replace(/^\s+|\s+$/g, '');
                       header2 = header.substring(140, 50);
                       header2 = header2.replace(/^\s+|\s+$/g, '');
                       returnStr += '<row type="header"><cell hstraddle="4" shading="black,15" alignment="left"><p br=false quad=C>'+header1+'<cell hstraddle="4" shading="black,15" alignment="right"><p br=false quad=C>'+header2;
                   }
               }
           }
       } else if (value.indexOf(":") != -1) {
           oneMessage = value.split(':');
           header = oneMessage[0];
           header = header.replace("N          Premises Type", "Premise Type");
           (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
           header1 = header1.replace(/^\s+|\s+$/g, '');
           header2 = header.substring(140, 50);
           header2 = header2.replace(/^\s+|\s+$/g, '');
           messageContents = oneMessage[1].split(':');
           returnStr += '<row type="header"><cell hstraddle="4" shading="black,15" alignment="left"><p br=false quad=C>'+header1+'<cell hstraddle="4" shading="black,15" alignment="right"><p br=false quad=C>'+header2;
       } else {
           header = value;
           header = header.replace("N          Premises Type", "Premise Type");
           (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
           header1 = header1.replace(/^\s+|\s+$/g, '');
           header2 = header.substring(140, 50);
           header2 = header2.replace(/^\s+|\s+$/g, '');
           returnStr += '<row type="header"><cell hstraddle="4" shading="black,15" alignment="left"><p br=false quad=C>'+header1+'<cell hstraddle="4" shading="black,15" alignment="right"><p br=false quad=C>'+header2;
       }
   } else {
       returnStr = '<row type="header">'+'No Current Charges!';
   }
}
returnStr += '<cell rulings="right:thin,black"><p br=false quad=C><cell></table></story>';
return returnStr;

Link to comment
Share on other sites

I'm using Desktop 6.21Pc on Acrobat 9.

That's a pretty old version, but the basics of table markup haven't change too much.

 

Anyway, I think this is the problem:

for (recordWalker = 1; recordWalker <= numRecsExtDF; recordWalker++) {
    // <FONT style="BACKGROUND-COLOR: blue">text</FONT>
    // clear string variable 
   returnStr = 'DETAIL OF CURRENT CHARGES\n<story copyhole="DetailsTable"><table columns="2" space="above:0;below:0"'+ 
               '< column width=[color="Red"]200[/color] />'+
               '< column width=[color="red"]200[/color] />'+
               '<z newsize=7>';

The column width is in hundredths of points, where there are 72 points, or 7200 hundredths of points, per inch. So you're asking for columns that are 2 points, or about 1/36th of a inch, wide. Try something like 20000 (200 points, or about 3 inches) instead.

 

Also, are you sure you want to recreate the table inside the loop? That will create a new table for each row of data. I would think you would want to create a single table, outside of the loop, and add rows instead.

Link to comment
Share on other sites

I made the change with the column size and made some other changes:

for (recordWalker = 1; recordWalker <= numRecsExtDF; recordWalker++) {
    // <FONT style="BACKGROUND-COLOR: blue">text</FONT>
    // clear string variable 
   returnStr = 'DETAIL OF CURRENT CHARGES\n<story copyhole="DetailsTable"><table columns="2" space="above:0;below:0"'+ 
               '< column width=4500 />'+
               '< column width=4500 />'+
               '<z newsize=7>';

   // check for service details
   if (Field("SERVICE") != "") {
       line = Field("SERVICE");
       if (line.indexOf("|") != -1) {
           examplearray = line.split("|");
           for(x = 0; x < examplearray.length; x++) {
               value = examplearray[x];
               if(value != "") {
                   if (value.indexOf(":") != -1) {
                       oneMessage = value.split(':');
                       header = oneMessage[0];
                       header = header.replace("N          Premises Type", "Premise Type");
                       (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
                       header1 = header1.replace(/^\s+|\s+$/g, '');
                       header2 = header.substring(140, 50);
                       header2 = header2.replace(/^\s+|\s+$/g, '');
                       messageContents = oneMessage[1].split(':');
                       returnStr += '<row type="header"><cell hstraddle="4" shading="black,15" alignment="left"><p br=false quad=C>'+header1+'<cell hstraddle="4" shading="black,15" alignment="right"><p br=false quad=C>'+header2;
                   } else {
                       header = value;
                       header = header.replace("N          Premises Type", "Premise Type");
                       (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
                       header1 = header1.replace(/^\s+|\s+$/g, '');
                       header2 = header.substring(140, 50);
                       header2 = header2.replace(/^\s+|\s+$/g, '');
                       returnStr += '<row type="header"><cell hstraddle="4" shading="black,15" alignment="left"><p br=false quad=C>'+header1+'<cell hstraddle="4" shading="black,15" alignment="right"><p br=false quad=C>'+header2;
                   }
               }
           }
       } else if (value.indexOf(":") != -1) {
           oneMessage = value.split(':');
           header = oneMessage[0];
           header = header.replace("N          Premises Type", "Premise Type");
           (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
           header1 = header1.replace(/^\s+|\s+$/g, '');
           header2 = header.substring(140, 50);
           header2 = header2.replace(/^\s+|\s+$/g, '');
           messageContents = oneMessage[1].split(':');
           returnStr += '<row type="header"><cell hstraddle="4" shading="black,15" alignment="left"><p br=false quad=C>'+header1+'<cell hstraddle="4" shading="black,15" alignment="right"><p br=false quad=C>'+header2;
       } else {
           header = value;
           header = header.replace("N          Premises Type", "Premise Type");
           (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
           header1 = header1.replace(/^\s+|\s+$/g, '');
           header2 = header.substring(140, 50);
           header2 = header2.replace(/^\s+|\s+$/g, '');
           returnStr += '<row type="header"><cell hstraddle="4" shading="black,15" alignment="left"><p br=false quad=C>'+header1+'<cell hstraddle="4" shading="black,15" alignment="right"><p br=false quad=C>'+header2;
       }
   } else {
       returnStr = '<row type="header">'+'No Current Charges!';
   }
   returnStr += '<cell rulings="right:thin,black"><p br=false quad=C><cell></table></story>';
   return returnStr;
}

 

And I'm still getting the error:

"Extra cell started <Line Items> row #0 - Ignoring The amount of text inserted into a flow exceeds the depth of all frames in the flow <(null)>. Text is truncated."

Link to comment
Share on other sites

And I'm still getting the error:

Okay, but you're not longer getting the "Table cell margins exceed cell width; text cannot be set" error, right? So let's look at those other two:

Extra cell started <Line Items> row #0 - Ignoring

You have a table with two columns, but you're trying to straddle four columns with tags like these:

returnStr += '<row type="header"><cell [color="red"]hstraddle="4"[/color] shading="black,15" alignment="left"><p br=false quad=C>'+header1+'<cell [color="Red"]hstraddle="4"[/color] shading="black,15" alignment="right"><p br=false quad=C>'+header2;

Try changing that to hstraddle="2", or add more columns.

The amount of text inserted into a flow exceeds the depth of all frames in the flow <(null)>. Text is truncated."

This just means that the table has more rows than fit in the frame. Typically, a table is set in a frame that's set to overflow to another page. Either way, though, you should still see the rows that do fit in the output.

Link to comment
Share on other sites

I tried 2 and 1 for the "hstraddle". Could it be anything with the "<z newsize=7>"?

 

This is the only error now:

"The amount of text inserted into a flow exceeds the depth

of all frames in the flow <(null)>. Text is truncated."

I can't really tell exactly what's going on without seeing the job. What does the output look like? Are there any table rows at all there?

 

Also, it's possible that the message is about another frame in the job. If you name your frames in the Frame Properties palette, then the actual frame name will show up in that error message instead of "(null)".

Edited by Dan Korn
Added note about frame names.
Link to comment
Share on other sites

No its not outputting anything except the plain text at the beginning of the string. "DETAIL OF CURRENT CHARGES\n"

 

   returnStr = 'DETAIL OF CURRENT CHARGES\n<story copyhole="DetailsTable"><table columns="2" space="above:0;below:0"'+ 
               '< column width=4500 />'+
               '< column width=4500 />'+
               '<z newsize=7>';

Link to comment
Share on other sites

No its not outputting anything except the plain text at the beginning of the string. "DETAIL OF CURRENT CHARGES\n"

 

   returnStr = 'DETAIL OF CURRENT CHARGES\n<story copyhole="DetailsTable"><table columns="2" space="above:0;below:0"'+ 
               '< column width=4500 />'+
               '< column width=4500 />'+
               '<z newsize=7>';

It seems that even the first row of the table doesn't fit in the frame. Can you try making the frame larger, possibly the entire size of the page, and see if anything fits then? Or, instead of trying to fit the entire contents of the field from the data, just try to put some dummy text like "hi there" in the table instead.

 

If that doesn't help, then there's not much more I can do without seeing the job files. You could collect up the job, or at least a minimal example that includes the table, and post it here.

Link to comment
Share on other sites

I just noticed I had both string concats left in the code. My original is commented out though.

 

Would my 6.21Pc file work in the newest version?

 

Here is a modified version of my project.

Also a picture of what I am trying to make the table look like.

Okay, thanks. So first, you need to include the external data file "mail-prd.txt" in order for me to be able to reproduce your results.

 

However, your rule as written doesn't actually use the data from that external file; it just creates one table for each record in the external data file, but it uses the SERVICE field from the main data file as the data. I'm not even sure you want the external data file at all, but since I can't see it, it's hard to know for sure.

 

Anyway, for now, I just commented out the "for (recordWalker)" line and outputted one iteration. That returned this:

DETAIL OF CURRENT CHARGES
<story copyhole="DetailsTable"><table columns="2" space="above:0;below:0"< column width=4500 />< column width=4500 /><z newsize=7><row type="header"><cell hstraddle="2" shading="blue,15" alignment="left"><p br=false quad=C>"hi there"<cell hstraddle="2" shading="black,15" alignment="right"><p br=false quad=C>"hi there"<row type="header"><cell hstraddle="2" shading="blue,15" alignment="left"><p br=false quad=C>"hi there"<cell hstraddle="2" shading="black,15" alignment="right"><p br=false quad=C>"hi there"<row type="header"><cell hstraddle="2" shading="blue,15" alignment="left"><p br=false quad=C>"hi there"<cell hstraddle="2" shading="black,15" alignment="right"><p br=false quad=C>"hi there"</table></story>

This has several problems, including:

  • You need an ending bracket > for the <table> tag before the first column tag.
  • You don't need to output <story> and </story> tags; that markup is used only in tagged markup data files.
  • You don't want to mark every row as a header. Most of the rows should be non-header rows. The only potential header row I see in your screenshot is "DETAIL OF CURRENT CHARGES", which you don't have as a table row at all, but unless you have the table set to be able to overflow to a new page, then you don't need it to be part of the table anyway.
  • You don't need to straddle every cell. If you have two cells in the row, you definitely don't want to straddle both of them over the only two columns. Either have only one cell with vstraddle=2, or have two cells with no vstraddle.
  • There's no "alignment" attribute of the <cell> tag. The way to specify the horizontal alignment for a cell is with a tag such as <p br=false quad=C> after the <cell> tag (which you're already doing). (There is an "alignment" attribute for the <table> tag, to specify the alignment of the entire table within its text frame.)
  • Your columns are still too narrow. 4500 is less than one inch. From the screenshot, it looks link each column should be at least one inch (7200) wide. In any case, I would start out with wider columns, in a wider frame, just to make sure you generally have the table structure right, then adjust the sizing once that's set.

I very strongly recommend that you update to a newer version of FusionPro to be able to use the Table API instead of having to build up all the tags manually. Although, even with the older version you have, you should still be able to start with a working table, such as the "Money" table in the Frodo Travel tutorial, and work from there. And don't try to get it all working perfectly on the first shot: I would first get the basic table structure right with dummy data, then get the real data in there, and then tweak the colors and alignment and such at the end. Make one change at a time and revert back if something breaks. (I find it handy to edit the rule syntax in an external program, such as Notepad2, then paste it into the Rule Editor, Preview the output, then you can just "Undo" in Notepad2 if you need to revert your last change.)

 

Anyway, I don't have the time to fix every problem in your rule, and I don't have the data file anyway, but, in conjunction with making the frame a bit larger, I did get this to output something:

//Loop through data
// NOTE FROM DAN: I commented out the line below because I don't have the "mail-prd.txt" external data file
//for (recordWalker = 1; recordWalker <= numRecsExtDF; recordWalker++)
{
    // <FONT style="BACKGROUND-COLOR: blue">text</FONT>
    // clear string variable 
   returnStr = 'DETAIL OF CURRENT CHARGES<br><table columns="2" space="above:0;below:0">'+ 
               '< column width=14400 />'+
               '< column width=14400 />'+
               '<z newsize=7>';

   // check for service details
   if (Field("SERVICE") != "") {
       line = Field("SERVICE");
       if (line.indexOf("|") != -1) {
           examplearray = line.split("|");
           for(x = 0; x < examplearray.length; x++) {
               value = examplearray[x];
               if(value != "") {
                   if (value.indexOf(":") != -1) {
                       oneMessage = value.split(':');
                       header = oneMessage[0];
                       header = header.replace("N          Premises Type", "Premise Type");
                       (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
                       header1 = header1.replace(/^\s+|\s+$/g, '');
                       header2 = header.substring(140, 50);
                       header2 = header2.replace(/^\s+|\s+$/g, '');
                       messageContents = oneMessage[1].split(':');
                       returnStr += '<row><cell shading="blue,15"><p br=false quad=C>'+header1+'<cell shading="black,15"><p br=false quad=C>'+header2;
                   } else {
                       header = value;
                       header = header.replace("N          Premises Type", "Premise Type");
                       (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
                       header1 = header1.replace(/^\s+|\s+$/g, '');
                       header2 = header.substring(140, 50);
                       header2 = header2.replace(/^\s+|\s+$/g, '');
                       returnStr += '<row><cell shading="blue,15"><p br=false quad=C>'+header1+'<cell shading="black,15"><p br=false quad=C>'+header2;
                   }
               }
           }
       } else if (value.indexOf(":") != -1) {
           oneMessage = value.split(':');
           header = oneMessage[0];
           header = header.replace("N          Premises Type", "Premise Type");
           (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
           header1 = header1.replace(/^\s+|\s+$/g, '');
           header2 = header.substring(140, 50);
           header2 = header2.replace(/^\s+|\s+$/g, '');
           messageContents = oneMessage[1].split(':');
           returnStr += '<row><cell shading="blue,15"><p br=false quad=C>'+header1+'<cell shading="black,15"><p br=false quad=C>'+header2;
       } else {
           header = value;
           header = header.replace("N          Premises Type", "Premise Type");
           (header.indexOf("Premise Type") == -1) ? (header1 = header.substring(10, 80)) : (header1 = header.substring(0, 80));
           header1 = header1.replace(/^\s+|\s+$/g, '');
           header2 = header.substring(140, 50);
           header2 = header2.replace(/^\s+|\s+$/g, '');
           returnStr += '<row><cell shading="blue,15"><p br=false quad=C>'+header1+'<cell shading="black,15"><p br=false quad=C>'+header2;
       }
   } else {
       returnStr = '<row type="header">'+'No Current Charges!';
   }
   returnStr += '</table>';
   return returnStr;
}

Hopefully that will get you back on track.

Link to comment
Share on other sites

That was something I should have changed with the sample I posted. The link to external data is only for a record count. It was the only way I could figure out to get the record count to be able to step through each record. Unless that is code I don't need to use with "internal" data.

 

Making the 6 changes you stated got me way farther than before. Actually getting a table to display now.

 

I really appreciate your help, Dan.

Link to comment
Share on other sites

How would I add a border around the table? Is it an attribute in the javascript code or FusionPro setting? Its hard to find anything on the old table method since everyone is using the API now.

The tags for building a table are still documented where they've always been documented: in the FusionPro Tags Reference Guide that's installed with FusionPro VDP. You can open it up from the "Documentation" sub-menu under the FusionPro menu in Acrobat.

 

Specifically, in the section "Tags for Tables," it lists the "boxrules" attribute of the <table> tag. So try something like this in the tag:

<table columns="2" boxrules="left:thick,blue;top:thin,red">

That's the exact example of that parameter given in the Tags Reference Guide. The Frodo Travel tutorial also has a couple of table examples.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...