Page 1 of 1
Table layout
Posted: Thu Aug 05, 2010 2:29 pm
by Betanin
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
Posted: Thu Aug 05, 2010 2:47 pm
by Betanin
Hi again,
I forgot some details...
I'm using the version 12 of TRichView component and the TReportHelper to resize and paint the pages.
Posted: Thu Aug 05, 2010 4:13 pm
by Sergey Tkachenko
Which exactly problems you have with tables?
Can you send me a sample RTF file to show the problem to richview at gmaildotcom?
Posted: Thu Aug 05, 2010 6:13 pm
by Betanin
Thanks Sergey, i've been sent the files to svt at trichviewdotcom
Posted: Fri Aug 06, 2010 1:17 pm
by Betanin
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
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;
Posted: Sat Aug 07, 2010 10:50 am
by Sergey Tkachenko
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.
Posted: Sat Aug 07, 2010 11:09 am
by Sergey Tkachenko
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.
Posted: Mon Aug 09, 2010 12:07 pm
by Betanin
Hi Sergey,
I'm deeply grateful for your answers, i believe that your last fix making the column size explicit will solve the biggest part of the problems to me. I'll ask the buying of your component to my boss. Wich release have the last fix? Thank you again!
Posted: Mon Aug 09, 2010 6:20 pm
by Sergey Tkachenko
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.