Board index » delphi » Printing from a RichEdit..Fax machine problems, Ok on Printer

Printing from a RichEdit..Fax machine problems, Ok on Printer

The following code works great on printers, but on fax machines, half of the
first letter of each line gets cut off (sometimes the whole letter).  Its as
if the fax machine does not like the margins (which I have none)..

any ideas?

I tried the paragraph.Leftindent but it does not seem to work unless you
enable bullets...

procedure TForm1.Print1BtnClick(Sender: TObject);
var
  i: integer;
  PrintText: System.Text;
begin
  if PrintDialog1.Execute then begin
    AssignPrn(PrintText);
    try
      Rewrite(PrintText);
      Printer.Canvas.Font := Edit1.Font;
          for i := 1 to Edit1.Lines.Count-1 do begin
            Writeln(PrintText, Edit1.Lines[i]);
          end;
      System.Close(PrintText);
      finally;
      end;
  end;
end;

 

Re:Printing from a RichEdit..Fax machine problems, Ok on Printer


Why don't you use the printing procedure of the rich edit?? There you can
also set margins (RichEdit.Pagerect)!

Tschau!

Chuck Condron schrieb in Nachricht <7vlh83$...@forums.borland.com>...

Quote
>The following code works great on printers, but on fax machines, half of
the
>first letter of each line gets cut off (sometimes the whole letter).  Its
as
>if the fax machine does not like the margins (which I have none)..

>any ideas?

>I tried the paragraph.Leftindent but it does not seem to work unless you
>enable bullets...

>procedure TForm1.Print1BtnClick(Sender: TObject);
>var
>  i: integer;
>  PrintText: System.Text;
>begin
>  if PrintDialog1.Execute then begin
>    AssignPrn(PrintText);
>    try
>      Rewrite(PrintText);
>      Printer.Canvas.Font := Edit1.Font;
>          for i := 1 to Edit1.Lines.Count-1 do begin
>            Writeln(PrintText, Edit1.Lines[i]);
>          end;
>      System.Close(PrintText);
>      finally;
>      end;
>  end;
>end;

Re:Printing from a RichEdit..Fax machine problems, Ok on Printer


Quote
In article <7vlh83$...@forums.borland.com>, Chuck Condron wrote:
> The following code works great on printers, but on fax machines, half of the
> first letter of each line gets cut off (sometimes the whole letter).  Its as
> if the fax machine does not like the margins (which I have none)..

The fax driver you are using seems to lie on its capabilities. Do a

  ShowMessage( IntToStr( GetDeviceCaps( Printer.handle, PHYSICALOFFSETX )));

after the rewrite, what does it report on printer and fax? I would follow
Martins advice and use the richedits native Print function together with its
Printrect property. That allows you to specify margins.

er Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:Printing from a RichEdit..Fax machine problems, Ok on Printer


Thanks guys on the help...I didnt know the richedit had a print
function!..duh...IT WORKS GREAT!..but...it did not solve the fax
problem...can you show me an example for the pagerect property?  I am a very
green programmer...can you tell?????

in your debt!

Re:Printing from a RichEdit..Fax machine problems, Ok on Printer


Quote
> Thanks guys on the help...I didnt know the richedit had a print
> function!..duh...IT WORKS GREAT!..but...it did not solve the fax
> problem...can you show me an example for the pagerect property?  

Contrary to the help the Pagerect property expects device coordinates, not
twips. So we need to figure out the printers/faxes resolution to be able to
convert a margin in inches to pixels/dots.

pprocedure TForm1.Button1Click(Sender: TObject);
 var
   presX, presY: Integer;
   r: TRect;
 Begin
   with richedit1 do begin
     plaintext := true;
     lines.loadfromfile( changefileext( application.exename, '.DPR' ));
   end;
   presX := GetDeviceCaps( printer.handle, LOGPIXELSX );
   presY := GetDeviceCaps( printer.handle, LOGPIXELSY );
   with r do begin
     left := presX;  // 1 inch left margin
     top  := 3 * presY div 2;  //  1.5 inch top margin
     right := Printer.PageWidth - 3 * presX div 4; // 0.75 inch right margin
     bottom := Printer.PageHeight - presY; // 1 inch bottom margin
   end;
   with richedit1 do begin
     Pagerect := r;
     Print('Testjob');
   end;
 End;

Note that the margins in the example are relative to the printable area
of the page, not the physical page. To correct for the nonprintable
margin use GetDeviceCaps with PHYSICALOFFSETX and PHYSICALOFFSETY (this
tells you how far the page coordinate system has been shifted left and
down by Delphi to put the origin at the upper left corner of the
printable area) and PHYSICALWIDTH and PHYSICALHEIGHT to get the paper
size in device units.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads