Setting column width in RTF

I have, for what I hope, a simple question!

I create a simple RTF table, which subsequently opens in MS Word. The table generates a fine, but the width of the columns is a little small and causes some word wrap (not what I want).

The RTF code that I generate is for a two-row table with three columns and has the following form:

\trowd \trautofit1 \intbl \cellx1 \cellx2 \cellx3 {a\cell b\cell c\cell }{\trowd \trautofit1 \intbl \cellx1 \cellx2 \cellx3 \row} \trowd \trautofit1 \intbl \cellx1 \cellx2 \cellx3 {d\cell e\cell f\cell }{\trowd \trautofit1 \intbl \cellx1 \cellx2 \cellx3 \row} 

What do I need to add to set the column width? I tried to change the width of the column in the word and then examine the result, but it is a bit unclear, to say the least!

+4
source share
4 answers

The problem is that you set a very small width for the column:

 \cellx1 \cellx2 \cellx3 

To set the column width in RTF, there is the keyword '\ cellxN', where N is the column width in tweets. 15 twips - 1px.

So, if you want to create a simple RTF table with 1 row and 3 columns of 100 pixels each, use this syntax:

 \trowd\cellx1500\cellx3000\cellx4500 \intbl A\cell B\cell C\cell\row 

You will get a simple table with a size of 300 pixels, 3 columns - 100 pixels each, with invisible borders.

Cheers, Max

+7
source

The control words you are looking for are \clwWidthN and \clftsWidthN

Microsoft RTF v1.9.1 specification :

 - \clwWidthN Preferred cell width. Overrides \trautofitN. - \clftsWidthN Units for \clwWidthN: - 0 : Null. Ignore \clwWidthN in favor of \cellxN (Word 97 style of determining cell and row width). - 1 : Auto, no preferred cell width, ignores \clwWidthN if present; \clwWidthN will generally not be written, giving precedence to row defaults. - 2 : Percentage (in 50ths of a percent). - 3 : Twips. 

Thus, in your case, you can simply use \clftsWidth1 (automatically set the width) or set your preferred percentages yourself, for example. \clwWidth2\clwWidth2500 (2500 = 50%)

Auto Width

 \trowd \trautofit1 \intbl \clftsWidth1\cellx1 \clftsWidth1\cellx2 \clftsWidth1\cellx3 {a\cell b\cell c\cell } 

40% - 30% - 30%

 \trowd \trautofit1 \intbl \clftsWidth2\clwWidth2000\cellx1 \clftsWidth2\clwWidth1500\cellx2 \clftsWidth2\clwWidth1500\cellx3 {a\cell b\cell c\cell } 
+8
source

You need to either use cellx0 to apply the autofit tag, or explain the number specified by the number by the number of twips from the left border. In your example, you use 1 2 and 3, which explains that the column width is very skinny. For example, something like:

\ cellx5125 \ Cellx6000 \ Cellx8000

Note that these numbers are offsets from the left margin.

If you are going to do any RTF, I highly recommend O'Rielly’s Pocket PC Guide

+2
source

Mark this link

http://joseluisbz.wordpress.com/2014/04/26/working-rtf-html-css-and-script-files-with-my-own-packages-java-and-php/

You can create your own file.

  TblData = new RTFTable(4,4); //4 Columns, 4 Rows TblData.setWideCols(1000); //Width of 2000 to put all columns TblData.setWideCol(0,3000); //Width of 3000 to Column 0 
0
source

Source: https://habr.com/ru/post/1342985/


All Articles