[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1066
  • Last Modified:

Pagerect and Richedit

A while ago I found this code for printing with Richedit, but if I use it as below only have a page gets printed, and then a new one starts, and I only got to specify left and topmargin. Can you please show me how the correct settings should be for a standard A4 page with a leftmargin of 10mm, Topmargin 20mm, Bottommargin also 20mm and rightmargin of 15mm, please write it so That it works Immediate if I paste it in my code Thanks.


RichEdit1.PageRect := Rect(100, 100, Printer.PageHeight, Printer.PageWidth);
RichEdit1.Print(...);
0
hellfire052497
Asked:
hellfire052497
  • 3
  • 2
1 Solution
 
mirek071497Commented:
var
 Loff, TOff, ROff, BOff   : integer;
 XRes, YRes, XOffs, YOffs : integer;
begin
  { set your needed values in milimeters }
  LOff := 10;
  TOff := 20;
  ROff := 15;
  BOff := 20;
  { Get printer data }
  XOffs := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX ); { minimum Left offset }
  YOffs := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY ); { minimum Top offset }
  XRes := GetDeviceCaps(Printer.Handle, LOGPIXELSX); { points per inch in X }
  YRes := GetDeviceCaps(Printer.Handle, LOGPIXELSY); { points per inch in Y }
  {Change Your values to printer Units }
  LOff := Round(LOff*XRes/25.4)-XOffs; { of course You can't set margins less than min offset !!! }
  TOff := Round(TOff*YRes/25.4)-YOffs; { of course You can't set margins less than min offset !!! }
  ROff := 2490-Round(ROff*XRes/25.4)-XOffs; { changing to width, not offset !!!}
  BOff := 3510-Round(BOff*YRes/25.4)-YOffs; { changing to height, not offset !!!}
  { print RichEdit }
  RichEdit1.PageRect := Rect( LOff, TOff, ROff, BOff );
  RichEdit1.Print( 'TEST A4 ' );
end;

0
 
hellfire052497Author Commented:
I just noticed that this code is skipping a lot of text about half a page between printed pages, and also that the text when reaching the right margin doesn't get printed and gets lost.
thus giving a lot of clipping. so it isn't correct just yet
please check what is wrong
0
 
mirek071497Commented:
Ok. I will try to test this. Wait to tomorrow.
0
 
hellfire052497Author Commented:
for your information I use richedit in a fixed size of;
Height : 257
Width: 593

0
 
mirek071497Commented:
Sorry for the long time.
In My exampele all works fine. Can you send me your example ? Mayby I found what is going on.
mirek@izabell.itcomp.tpnet.pl
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now