Forum > Beginners

Print Form Landscape A4

(1/1)

seghele0:
The code below works well.
Would like to get a print that fills the entire A4 (landscape).


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFMAIN.SpeedButton1Click(Sender: TObject);var  myBitMap : TBitMap;  rct: TRect;  HScaleFactor, VScaleFactor: Single;  BWidth, BHeight: Integer;  PWidth, PHeight: Integer;  RTop, RLeft, RBottom, RRight: Integer;begin  // Put "Math" in uses !!!  if not PrintDialog1.Execute then Exit;  HScaleFactor := Printer.XDPI / Screen.PixelsPerInch;  VScaleFactor := Printer.YDPI / Screen.PixelsPerInch;  try    myBitMap := TBitMap.Create;    Printer.Refresh;    Printer.Orientation:= poLandscape;    myBitMap.LoadFromDevice(FMAIN.Canvas.Handle);    BWidth  := trunc(myBitMap.Width*HScaleFactor);    BHeight := trunc(myBitMap.Height*VScaleFactor);    PWidth  := Printer.PageWidth;    PHeight := Printer.PageHeight;    RTop    := max(0, ((PHeight div 2) - (BHeight div 2)));    RLeft   := max(0, ((PWidth div 2) - (BWidth div 2)));    RBottom := min(PHeight, (RTop + BHeight));    RRight  := min(PWidth, (RLeft + BWidth));    rct := Rect(Rleft, RTop, RRight, RBottom);    Printer.BeginDoc;    Printer.Canvas.Font.Size:=12;    Printer.Canvas.StretchDraw(rct, myBitMap);  finally    Printer.EndDoc;    myBitMap.Free;  end;end;                        

howardpc:
Try this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFMAIN.SpeedButton1Click(Sender: TObject);var  myBitMap : TBitMap;begin  if not PrintDialog1.Execute then Exit;  myBitMap := TBitMap.Create;  try    Printer.Refresh;    Printer.Orientation:= poLandscape;    myBitMap.LoadFromDevice(FMAIN.Canvas.Handle);    Printer.BeginDoc;    Printer.Canvas.Font.Size := 12;    Printer.Canvas.StretchDraw(Printer.PaperSize.PaperRect.WorkRect, myBitMap);  finally    Printer.EndDoc;    myBitMap.Free;  end;end;

seghele0:
 :)
THANK YOU.
Many thanks for the solution via your code.
 ;)

Navigation

[0] Message Index

Go to full version