Table Printing problem
-
- Posts: 20
- Joined: Fri Sep 01, 2006 4:20 am
- Location: seoul korea
Table Printing problem
I uses TrichViewEdit ver1.9.38 for Delphi 7.
When Editing a table..it works well.
But when printing a table..
the one row line is printed two line.
My table option is..
table.BorderVSpacing := -1;
table.BorderHSpacing := -1;
table.CellBorderStyle := rvtbColor;
table.CellBorderColor := clBlack;
table.CellBorderWidth := 1;
table.CellHSpacing := -1;
table.CellVSpacing := -1;
table.CellPadding := 3;
table.BestWidth := 0;
I have changed above option's value..
But result is same..
(When any object(ex. the blank) is placed in front of table, and behind table.. the printing works well.. it's so weird)
Please answer for my question.
When Editing a table..it works well.
But when printing a table..
the one row line is printed two line.
My table option is..
table.BorderVSpacing := -1;
table.BorderHSpacing := -1;
table.CellBorderStyle := rvtbColor;
table.CellBorderColor := clBlack;
table.CellBorderWidth := 1;
table.CellHSpacing := -1;
table.CellVSpacing := -1;
table.CellPadding := 3;
table.BestWidth := 0;
I have changed above option's value..
But result is same..
(When any object(ex. the blank) is placed in front of table, and behind table.. the printing works well.. it's so weird)
Please answer for my question.
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 20
- Joined: Fri Sep 01, 2006 4:20 am
- Location: seoul korea
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 20
- Joined: Fri Sep 01, 2006 4:20 am
- Location: seoul korea
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Sorry for delay.
The problem is in OnDrawBorder event.
You use it to draw a hairline border (i.e. border having width = 1 pixel both on screen and on printer). On screen, hairline borders look exactly like normal borders (if CellBorderWidth=1).
But on printing, real width of border with CellBorderWidth=1 is calculated as Printer_Resolution/Screen_Resolution. For example, 600/96 = 6 pixels (on this printer, width=6 pixels looks like width=1 pixel on screen).
But in this event you draw border that always has width=1 pixel (so, the higher resolution printer has, the narrower this border looks)
This is the source of this problem. You draw border around each cell. But cells overlap each other (because CellHSpacing=CellVSpacing=-1), overlapping width = 1 screen pixel. On printer, this screen pixel becomes several pixels (as in the example above, 6 pixels). So you can see wrong output.
The solution is drawing only bottom and right sides of each cells (except for the cells in the top row and the left column).
The example is here:
http://www.trichview.com/support/files/ ... border.zip
Besides, I removed your OnSendingToPrinter event - it's not allowed to change document in this event.
The problem is in OnDrawBorder event.
You use it to draw a hairline border (i.e. border having width = 1 pixel both on screen and on printer). On screen, hairline borders look exactly like normal borders (if CellBorderWidth=1).
But on printing, real width of border with CellBorderWidth=1 is calculated as Printer_Resolution/Screen_Resolution. For example, 600/96 = 6 pixels (on this printer, width=6 pixels looks like width=1 pixel on screen).
But in this event you draw border that always has width=1 pixel (so, the higher resolution printer has, the narrower this border looks)
This is the source of this problem. You draw border around each cell. But cells overlap each other (because CellHSpacing=CellVSpacing=-1), overlapping width = 1 screen pixel. On printer, this screen pixel becomes several pixels (as in the example above, 6 pixels). So you can see wrong output.
The solution is drawing only bottom and right sides of each cells (except for the cells in the top row and the left column).
The example is here:
http://www.trichview.com/support/files/ ... border.zip
Besides, I removed your OnSendingToPrinter event - it's not allowed to change document in this event.
-
- Posts: 20
- Joined: Fri Sep 01, 2006 4:20 am
- Location: seoul korea
Thank you for your kindly answer.
Your sample works well.
1. But for example..when I change the cell's color to clWindow..
table.Cells[0, 0].Color := clWindow;
table.Cells[0, 1].Color := clWindow;
The first column's right line is not shown.
How can I print the table with color cells?
I just insert above code at the Button1Click on the your sample code.
2. Please test my previous sample program by this step.
1) Execute sample program.
2) Press the 'Table' button three times.
3) Press the 'Print' button.
The center table's print result is good.
Not only table object but also other objects(ex. Enter, Other characters)
lead to same result.
so..when the table is in center position by other object..
the print result is good.
Why is that?
Your sample works well.
1. But for example..when I change the cell's color to clWindow..
table.Cells[0, 0].Color := clWindow;
table.Cells[0, 1].Color := clWindow;
The first column's right line is not shown.
How can I print the table with color cells?
I just insert above code at the Button1Click on the your sample code.
2. Please test my previous sample program by this step.
1) Execute sample program.
2) Press the 'Table' button three times.
3) Press the 'Print' button.
The center table's print result is good.
Not only table object but also other objects(ex. Enter, Other characters)
lead to same result.
so..when the table is in center position by other object..
the print result is good.
Why is that?
-
- Posts: 20
- Joined: Fri Sep 01, 2006 4:20 am
- Location: seoul korea
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
The following changes should help.
1) Change OnDrawBorder
(the most important change is moving (Left, Top, Right, Bottom) rectangle to the top left by one pixel)
2) Change table parameters (it's not necessary to use overlapping borders, so -1 are changed to 0):
1) Change OnDrawBorder
(the most important change is moving (Left, Top, Right, Bottom) rectangle to the top left by one pixel)
Code: Select all
procedure TForm1.DoDrawBorder(Sender: TRVTableItemInfo;
Canvas: TCanvas; Left, Top, Right, Bottom, Width: Integer; LightColor,
Color, BackgroundColor: TColor; Style: TRVTableBorderStyle;
Printing: Boolean; VisibleBorders: TRVBooleanRect; Row, Col: integer;
var DoDefault: Boolean);
begin
if Width = 0 then exit;
dec(Left);
dec(Top);
dec(Right);
dec(Bottom);
Canvas.Pen.Color := Color;
Canvas.Pen.Style := psInsideFrame;
Canvas.Pen.Width := 1;
Canvas.Brush.Style := bsClear;
if Row<0 then
Canvas.Rectangle(Left, Top, Right, Bottom)
else begin
Canvas.MoveTo(Left, Top);
if Sender.Cells[Row, Col].VisibleBorders.Top and
((Row=0) or not Sender.Cells[Row-1, Col].VisibleBorders.Bottom) then
Canvas.LineTo(Right, Top)
else
Canvas.MoveTo(Right, Top);
if Sender.Cells[Row, Col].VisibleBorders.Right then
Canvas.LineTo(Right, Bottom)
else
Canvas.MoveTo(Right, Bottom);
if Sender.Cells[Row, Col].VisibleBorders.Bottom then
Canvas.LineTo(Left, Bottom)
else
Canvas.MoveTo(Left, Bottom);
if Sender.Cells[Row, Col].VisibleBorders.Left and
((Col=0) or not Sender.Cells[Row, Col-1].VisibleBorders.Right) then
Canvas.LineTo(Left, Top)
else
Canvas.MoveTo(Left, Top);
end;
DoDefault := False;
end;
Code: Select all
table.CellBorderStyle := rvtbColor;
table.CellBorderColor := clBlack;
table.CellBorderWidth := 1;
table.CellHSpacing := 0;
table.CellVSpacing := 0;
table.CellPadding := 3;
table.BorderVSpacing := 0;
table.BorderHSpacing := 0;
-
- Posts: 20
- Joined: Fri Sep 01, 2006 4:20 am
- Location: seoul korea
Hi.
Your solution was very useful.
Table row line is printed correctly.
But recently I found a problem.
When the table is on the page break..
so the table is splited by two page.
The first row's first horizon line of second page's table
is not printed.
It's correct result by your solution logic.
So..how can I know page break point?
-> If I know page break point, I can fix your solution.
Or..Is there other solution?
Your solution was very useful.
Table row line is printed correctly.
But recently I found a problem.
When the table is on the page break..
so the table is splited by two page.
The first row's first horizon line of second page's table
is not printed.
It's correct result by your solution logic.
So..how can I know page break point?
-> If I know page break point, I can fix your solution.
Or..Is there other solution?