Jump to content

Dynamic Text Frame Width


RickG

Recommended Posts

Hey All,

 

New to FP with only 1 project under my belt so please be gentle...

 

I've got a text frame with multiple lines of text using 2 different point sizes and I need the frame to only be as wide as the longest line of text with the point size taken into account. Point sizes are applied within the text frame, not on the values to be displayed (eg - not using code to apply pointSize attributes to the text).

 

I've seen a few postings regarding similar situations (such as this one: http://forums.printable.com/showthread.php?t=1923), but I'm not sure that is the right path as my needs are not quite the same.

 

Can someone point me in the right direction for this challenge?

 

Thanks in advance...

Link to comment
Share on other sites

Ok, so I stumbled across the width attribute (right after posting of course) and see that the value is read-only. Fair enough...so I'm assuming that tables is the right path on this.

 

Following the information provided in this post: http://forums.printable.com/showthread.php?t=1923

 

...its referring to the use of FPTable which is new to version 7.x, but I'm unable to find any reference in the User/Tag/Rules guides for FPTable.

 

Can anyone provide me with a link that contains the details of the various attributes of FPTable? Examples would be nice too.

 

Specifically looking for:

 

  • Vertical alignment of the table within the text frame
  • Table/Cell padding? Although I need the table vertically aligned as it is top-aligned now, its not flush with the top of the text frame so I'm assuming there is some padding I need to get rid of or the vertical alignment wouldn't be correct.
  • Adding borders to the table/cells for troubleshooting
  • Given the following snippet...

table.AddColumns(43200,0,7200);

...the 1st number is the column width, 2nd is the gutter, 3rd is..?

 

Anyone? Anyone? Bueller? Bueller?

 

Thanks in advance...

Link to comment
Share on other sites

Can anyone provide me with a link that contains the details of the various attributes of FPTable? Examples would be nice too.

Sorry, we don't have any formal documentation of the FPTable object. However, the Frodo Travel Tutorial contains a fairly comprehensive example (in OnRecordStart), from which you should be able to extrapolate.

Specifically looking for:

 

  • Vertical alignment of the table within the text frame

That's controlled by the VAlign property of the FPTableCell object. It can be either "top", "middle", or "bottom". For example:

mytable.text.Rows[1].Cells[2].VAlign = "middle";

  • Table/Cell padding? Although I need the table vertically aligned as it is top-aligned now, its not flush with the top of the text frame so I'm assuming there is some padding I need to get rid of or the vertical alignment wouldn't be correct.

That's probably just a matter of how you're bringing in the table into its text frame. You might just need to move the text frame a bit. An example might be helpful here, as in a picture of what you want to accomplish.

  • Adding borders to the table/cells for troubleshooting

That's controlled by the SetBorders method of FPTableCell. The values are the same as what's listed for the "rulings" attribute of the <cell> tag in the Tags Reference Guide. Here's the example from the Frodo Travel Tutorial:

    text.Rows[b].Cells[a].SetBorders("Thin", "Black", "Top", "Bottom", "Left", "Right");

  • Given the following snippet...
    table.AddColumns(43200,0,7200);

    ...the 1st number is the column width, 2nd is the gutter, 3rd is..?

Those are all widths of columns. I'm not sure why you would have a column with zero width, although sometimes (as in the example in that other thread) a narrow column can be effectively used as a "gutter" between other columns. Nevertheless, it's still a valid column in the table, and takes up one of the cells in each table row.
Link to comment
Share on other sites

Thank for the feedback Dan...

 

Re: Vertical Alignment - Can you please check this code that you provided. It errors out the code so nothing is displayed at all.

 

mytable.text.Rows[1].Cells[2].VAlign = "middle";

...for the record, yes, I changed "mytable" to the name of the table I'm using within my code. :).

 

I'm attaching a snapshot of what I'm seeing when I add boarders as the text placement appears way off. There is an intentional blank line between TestCo Inc and 123 Somewhere Street (cell content is nbsp). All margins in the table are set to 0 using the CellMargin.<Top|Bottom|Left|Right> properties.

 

Any thoughts in regards to why it the vertical alignment of the text seems to place it outside the cell?

 

Thanks in advance...

IssueExample.jpg.aeb653832155f1a2e7ff8255b3d9faa3.jpg

Link to comment
Share on other sites

Re: Vertical Alignment - Can you please check this code that you provided. It errors out the code so nothing is displayed at all.

 

mytable.text.Rows[1].Cells[2].VAlign = "middle";

...for the record, yes, I changed "mytable" to the name of the table I'm using within my code. :).

 

Sorry, that was a typo. It should be:

mytable.Rows[1].Cells[2].VAlign = "middle";

Like I said in the other thread, without the actual job, I'm kind of trying things in the dark, just typing here on the forum, as I can't really validate the examples in the Rule Editor anyway. But the error message should give you a hint as to what's wrong.

Any thoughts in regards to why it the vertical alignment of the text seems to place it outside the cell?

Again, your explanation is great, but it's hard to troubleshoot without having the job to try it out myself.

Link to comment
Share on other sites

Thanks Dan...

 

Is there a way that I can send you the job without it being available for public consumption? If not, I'll need to create a job that doesn't have client-specific information.

 

I tried the modified VAlign code and it had no effect. The text alignment is exactly the same.

 

In the other thread I think I replied to myself by accident regarding the quibble...

 

Thanks again...

Link to comment
Share on other sites

Is there a way that I can send you the job without it being available for public consumption?

You can always send it to Support, but that's not necessarily going to go to me, and it might get into the area of paid consulting. You're pretty much getting my help for free here, but the price is that everything is public so that other users might be able to learn from the job as well. And so that others might be able to pitch and help. ;)

If not, I'll need to create a job that doesn't have client-specific information.

That would be fine.

I tried the modified VAlign code and it had no effect. The text alignment is exactly the same.

Are you sure you're applying it to the cell you want? What does the generated tagging look like?

Link to comment
Share on other sites

Thanks to your guidance, 99% of the issues are resolved, less the vertical alignment in the cells...

 

Here is a snippet on how I'm configuring and populating the table cells (VAlign is being applied to all cells the same way)...

 

.
.
dispDept    =   "<p><z newsize=10><tracking newsize=50>" + dept;
.
.
table.Rows[0].Cells[0].SetBorders("Thin","Black","Top","Bottom","Left","Right");
table.Rows[0].Cells[0].Margins = CellMargins;
table.Rows[0].Cells[0].VAlign = "middle";
table.Rows[0].Cells[0].Content = dispDept;

...and here is the validation output where it doesn't appear that the alignment attribute is being applied...

 

<table columns=1>
 <column width=8351>
 <row><cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black" margins=Top:0;Bottom:0;Left:0;Right:0><p><z newsize=10><tracking newsize=50>undefined
 <row><cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black" margins=Top:0;Bottom:0;Left:0;Right:0><z newsize=6><tracking newsize=50> </tracking>
 <row><cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black" margins=Top:0;Bottom:0;Left:0;Right:0><tracking newsize=50>undefined
 <row><cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black" margins=Top:0;Bottom:0;Left:0;Right:0><tracking newsize=50>undefined
</table>

Attached is the a screen shot of the preview. Please let me know your thoughts on this.

 

Thank you in advance...

AlignmentIssue.JPG.951fb79c9f98ac3a056a0544778d5463.JPG

Link to comment
Share on other sites

I've finally been able to find the time to create a sample project that has the same code as the production project and shows the vertical alignment issue I'm seeing. Thrilled to see that the table width issue resurfaced too.

 

Files:

 

  • Zip - Collected project that includes CSV file of sample input
  • TXT - File used to take the user input (department) and look up the address information. Expected path is in the OnRecordStart callback.

The font is Weiss Extra Bold, let me know if you need me to upload the fonts also.

 

Please let me know your thoughts on this and thank you in advance for your time.

FPEnvelopeSample.zip

EnvelopeAddressList.txt

Link to comment
Share on other sites

Thanks. All I can really tell you with regard to the vertical alignment is that that's just how tables work. If you want more space in the cells around the text, you need to do what the Frodo Travel Tutorial does in its tables and set margins on the cells, by adding code like this right before the final "return" line in your rule:

for (var a = 0; a < rowCount; a++)
{
   table.Rows[a].Cells[0].SetBorders("Thin", "Black", "Top", "Bottom", "Left", "Right");
   table.Rows[a].Cells[0].Margins = new FPTableMargins;
   //table.Rows[a].Cells[0].Margins.Top = 60;
   table.Rows[a].Cells[0].Margins.Bottom = 40;
   //table.Rows[a].Cells[0].Margins.Left = 600;
   //table.Rows[a].Cells[0].Margins.Right = 600;
}

Alternately, you can just add more text to each cell, by changing each line like so:

// adjust the "newsize" parameter to control the amount of space
table.Rows[0].Cells[0].Content = dispDept + "<br><z newsize=4> \n";

I'm not sure what you mean by "the table width issue resurfaced too."

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...