Table width ignores style
Table width ignores style
I have a big table (3 cols, 309 rows) in a topic that only targets PDF output. I have read here that width: 100% and setting the width of the first two columns should make the last column take the remaining space. The column width on my printed page is about 540px, but the MadCap:lastWidth in the <html> tag is 949, which is about how wide it is making my 100% width table.
Opening the topic with the Internal browser (or an external one) respects the 100% width. Printing the topic with MadCap Flare does not--the table runs off the right margin and the 3rd column is completely hidden. Opening in the XML Editor and specifying Layout: Print and Medium: Print shows me about what I get in the PDF. I've tried to resize the columns in the XML Editor, but it displays some arbitrary pixel size (338px) and doesn't let me drag it smaller.
I also notice that it's ignoring my stylesheet. I manually included my print stylesheet (that is, generally, working for all my PDF targets), and the large table has an id. The XML Editor apparently isn't seeing styles that select based on that id. (I've tried it using classes, too, with no luck. This table is a singularity, so id made sense.) My stylesheet left-aligns thead tr th items, and they are centered (apparently a Madcap default) in the XML Editor, left-aligned in the PDF output.
Any ideas? I've cleaned up the XML markup to just tags, no attributes (except the table id). I have one .css file. It tells that table id to be width: 100%. Flare says "Right, 949 pixels." Help!
/alastair/
Opening the topic with the Internal browser (or an external one) respects the 100% width. Printing the topic with MadCap Flare does not--the table runs off the right margin and the 3rd column is completely hidden. Opening in the XML Editor and specifying Layout: Print and Medium: Print shows me about what I get in the PDF. I've tried to resize the columns in the XML Editor, but it displays some arbitrary pixel size (338px) and doesn't let me drag it smaller.
I also notice that it's ignoring my stylesheet. I manually included my print stylesheet (that is, generally, working for all my PDF targets), and the large table has an id. The XML Editor apparently isn't seeing styles that select based on that id. (I've tried it using classes, too, with no luck. This table is a singularity, so id made sense.) My stylesheet left-aligns thead tr th items, and they are centered (apparently a Madcap default) in the XML Editor, left-aligned in the PDF output.
Any ideas? I've cleaned up the XML markup to just tags, no attributes (except the table id). I have one .css file. It tells that table id to be width: 100%. Flare says "Right, 949 pixels." Help!
/alastair/
Re: Table width ignores style
If you open the topic in the Internal Text Editor and look for the col tags inside the table, do you see an actual width specified for the third column? If so, remove that width attribute. If there is no width attribute there, then the XML Editor could just be showing you an approximation of the width of the column based on the current view in the XML Editor.
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Re: Table width ignores style
Thanks for the fast reply, Lisa. I had taken out the <col> tags. When I drag the column separator in the XML Editor, it pins to a minimum value (~310px) but lets me make the first column wider (366px). Saving that change creates three <col> tags and the first has style="width: 366px;". If I edit that to be "width: 200px;" nothing changes (either in the XML Editor or in the PDF output).
I should have mentioned, by the way, that I am using Flare V6.1.0.
/alastair/
I should have mentioned, by the way, that I am using Flare V6.1.0.
/alastair/
Re: Table width ignores style
Keep in mind that the XML Editor is an approximation of what the output will look like, so the final standard should always be the final output, not how it appears in the XML Editor. Likewise, the Stylesheet Editor sometimes doesn't show you accurate values, so if in doubt, open the stylesheet file in the Internal Text Editor and double-check the actual values in that file.
Also, I recommend setting the table width for print outputs to inches or some other print-specific unit of measure instead of 100%. You can set the width of that table class in the default medium to 100% because browser widths are adjustable, but set the table width in the print medium to 6.5 in or whatever width you set for your content in the page layout. You also need to double-check that there isn't an inline width set on the table tag when viewing it in the Internal Text Editor, as that inline width will override the stylesheet file.
Also, I recommend setting the table width for print outputs to inches or some other print-specific unit of measure instead of 100%. You can set the width of that table class in the default medium to 100% because browser widths are adjustable, but set the table width in the print medium to 6.5 in or whatever width you set for your content in the page layout. You also need to double-check that there isn't an inline width set on the table tag when viewing it in the Internal Text Editor, as that inline width will override the stylesheet file.
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
-
nickatwork
- Sr. Propeller Head
- Posts: 457
- Joined: Thu Sep 16, 2010 6:31 am
- Location: London
Re: Table width ignores style
I had to battle this one a few times before I got it working right.
Heres some example code for a 2 column table, the XML editor will show the last column as being 'auto' wide. This makes the last column expand to the width setting of the page, whether it is print or online.
<table style="width: 100%;" class="table_whatever">
<col style="width: 30px;" />
<col />
Heres some example code for a 2 column table, the XML editor will show the last column as being 'auto' wide. This makes the last column expand to the width setting of the page, whether it is print or online.
<table style="width: 100%;" class="table_whatever">
<col style="width: 30px;" />
<col />
Re: Table width ignores style
Thanks, Lisa and Nick, for the helpful replies. I've experimented with, it seems, the full matrix of possibilities. The problem still exists; I have a deadline, so I'm solving it by putting the table in a standalone document.
Converting XHTML to PDF requires a rendering engine. Unless Flare uses a standard like Webkit, I have to conclude that, to paraphrase the movie title, There Will Be Bugs. My table is ignoring column widths and growing too wide for the page based on cell content. I don't think Flare's engine supports table-layout: fixed. At all.
I've found a similar problem that I have to lay on the table rendering engine. It does a very nice thing with proper <thead> and <tbody> sections--it repeats the thead after each page break. This is excellent, but it doesn't work well with rowspan. I have some legacy tables that rowspan the heck out of the first column of three, then go for N rows with just two columns. If a page break happens, the rows following the break are shifted left--they don't remember the rowspanned column and so are out of alignment. Because the thead is repeated, we get the wrong headings on the information. Insult on injury.
These are serious bugs. I'm forced to consider making complex tables in other tools and inserting them as illustrations. I'm using 6.1; maybe 7 is all better.
/alastair/
Converting XHTML to PDF requires a rendering engine. Unless Flare uses a standard like Webkit, I have to conclude that, to paraphrase the movie title, There Will Be Bugs. My table is ignoring column widths and growing too wide for the page based on cell content. I don't think Flare's engine supports table-layout: fixed. At all.
I've found a similar problem that I have to lay on the table rendering engine. It does a very nice thing with proper <thead> and <tbody> sections--it repeats the thead after each page break. This is excellent, but it doesn't work well with rowspan. I have some legacy tables that rowspan the heck out of the first column of three, then go for N rows with just two columns. If a page break happens, the rows following the break are shifted left--they don't remember the rowspanned column and so are out of alignment. Because the thead is repeated, we get the wrong headings on the information. Insult on injury.
These are serious bugs. I'm forced to consider making complex tables in other tools and inserting them as illustrations. I'm using 6.1; maybe 7 is all better.
/alastair/
Re: Table width ignores style
So try removing that attribute from the table. I've never used it and I've never had trouble with table widths rendering in online or PDF outputs.adallas wrote:I don't think Flare's engine supports table-layout: fixed. At all.
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Re: Table width ignores style
Lisa,
The problem is that my table cells contain long text (java.properties.and.file.names.that-are-formatted.like.this). Browsers that support table-layout: fixed (all of them, since CSS2) will break that text to maintain the specified column width. Without that property, you get HTML 1.0 behavior, namely, the column width is treated as a minimum, not a maximum value. If Flare supported table-layout: fixed, I'd have chopped up text, but at least column 3 would be on the page.
Since we're on the subject, I think width: 100% should be a bit magical for Flare when it is rendering PDF output. It should treat the page layout right margin as 100% from wherever the element started. The style width: 100% never, ever, means "run off the right side of the page if you think you should." Maybe, if you specify width: 200% or no width at all, but 100% means 100% to me.
The problem is that my table cells contain long text (java.properties.and.file.names.that-are-formatted.like.this). Browsers that support table-layout: fixed (all of them, since CSS2) will break that text to maintain the specified column width. Without that property, you get HTML 1.0 behavior, namely, the column width is treated as a minimum, not a maximum value. If Flare supported table-layout: fixed, I'd have chopped up text, but at least column 3 would be on the page.
Since we're on the subject, I think width: 100% should be a bit magical for Flare when it is rendering PDF output. It should treat the page layout right margin as 100% from wherever the element started. The style width: 100% never, ever, means "run off the right side of the page if you think you should." Maybe, if you specify width: 200% or no width at all, but 100% means 100% to me.
Re: Table width ignores style
If you have such long content, then the 100% width will be sacrificed to get the content to appear in the cell. I'm not sure if setting a hard width of 6.5" or something like that would take care of the issue or not. I normally set the specific width just because it's easier for me to get a handle on it conceptually, and because it seems to set the print view of the XML Editor closer to what it will actually be in the output, so it's easier to see if I need to manually break up a long block of text.
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Re: Table width ignores style
We also experience the problem with table widths being ignored when there are long lines of text with no spaces in them. The issue appears to be that Flare does not support character wrapping so that it can enforce a width or max-width setting for tables.
Re: Table width ignores style
I think it is not so much Flare but a behaviour of CSS, as it will only wrap text at spaces/punctuation, and will not break in the middle of words (as you wouldn't normally want it to). I would suggest using Google to search for ways to force words to break; I think there are properties like word-wrap and word-break, although I'm not sure if there is a standard used by all browsers.Kleb wrote:We also experience the problem with table widths being ignored when there are long lines of text with no spaces in them. The issue appears to be that Flare does not support character wrapping so that it can enforce a width or max-width setting for tables.