Table layout
Table layout
Hi,
I'm trying the TRichView to use in my company's applications, and i'm very satisfacted with it, but i've one problem that i couldn't solve, the tables that i import from a RTF document are non align, ther are any way to fix them?
Thanks
I'm trying the TRichView to use in my company's applications, and i'm very satisfacted with it, but i've one problem that i couldn't solve, the tables that i import from a RTF document are non align, ther are any way to fix them?
Thanks
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Hi Sergey, i was studying the code of the tables in html and i observed that there are lots of blank cells in the document. When i drag these cells the table is corrected. So i thought in destroy these cells before to print my document, but now i have another problem, when i send the document to printer i receive an error message of an index out of range. How can i solve this?
Thanks
This is my code to destroy the blank cells
Thanks
This is my code to destroy the blank cells
Code: Select all
for r := 0 to table.Rows.Count-1 do
for c := 0 to table.Rows[r].Count-1 do
begin
if(c = 0)then j := 0;
if table.Cells[r,j]<>nil then
begin
vHasContent := False;
for i := 0 to table.Cells[r,j].ItemCount - 1 do
begin
if(Trim(table.Cells[r,j].GetItemText(i)) <> '')then
begin
vHasContent := True;
end;
end;
if(not vHasContent)then
begin
table.Rows[r].Delete(j);
j := j - 1;
end;
end;
j := j + 1;
end;
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
First, about the original problem.
These tables were created quite inaccurate.
Take a closer look after loading in MS Word:
You can see that some vertical borders are slightly shifted in different rows. This shift leads to addition of extra cell (column) in this place.
TRichView did not assign width of these extra cells, because I believed that a table can be correctly resized using sizes of other cells (cells with content).
But in this case, this assumption was wrong.
So I made a fix (will be uploaded with the next update): width of such cells are defined explicitly.
Now the table looks in TRichViewEdit in this way:
Still not perfect, but as good as possible.
These tables were created quite inaccurate.
Take a closer look after loading in MS Word:
You can see that some vertical borders are slightly shifted in different rows. This shift leads to addition of extra cell (column) in this place.
TRichView did not assign width of these extra cells, because I believed that a table can be correctly resized using sizes of other cells (cells with content).
But in this case, this assumption was wrong.
So I made a fix (will be uploaded with the next update): width of such cells are defined explicitly.
Now the table looks in TRichViewEdit in this way:
Still not perfect, but as good as possible.
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I agree that these tables require fixing.
You can do it manually by resizing tables in MS Word until vertical borders becomes identical in all rows.
After loading, you can try to make a procedure for fixing it, but I am afraid it would be too difficult.
You cannot just delete the specified cell, do not call table.Rows[r].Delete(j), it the most likely produces invalid tables. You can only delete the whole column (using table.DeleteCols method).
But, unfortunately, deleting columns is not enough. On the example in the previous post, only the problem in the right rectangle can be fixed by deleting column.
You can do it manually by resizing tables in MS Word until vertical borders becomes identical in all rows.
After loading, you can try to make a procedure for fixing it, but I am afraid it would be too difficult.
You cannot just delete the specified cell, do not call table.Rows[r].Delete(j), it the most likely produces invalid tables. You can only delete the whole column (using table.DeleteCols method).
But, unfortunately, deleting columns is not enough. On the example in the previous post, only the problem in the right rectangle can be fixed by deleting column.
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
This change is included in TRichView v12.4.5 (available for registered users).
If you need to test it before ordering, let me know, I'll send you a trial for your version of Delphi.
PS: this fix made your tables look better, but still not very good, so the best way is to fix them manually in MS Word.
If you need to test it before ordering, let me know, I'll send you a trial for your version of Delphi.
PS: this fix made your tables look better, but still not very good, so the best way is to fix them manually in MS Word.