Forum > Beginners

Printing on both sides with normal printer

(1/1)

Sprek Skik:
I came into contact with the Lazarus program at the end of last year.
Through trial and error, I have been able to create my own applications.
It is a fun challenge and if I see a problem there are my old Pascal books,
the internet and now also this forum. I am still a real beginner and have very little experience
with everything. Every now and then I have a little success.
So also with the problem of printing on both sides of an A4 sheet.
For me it was a challenge to make this a success with little information.
I hope that I especially do the beginners a favor with 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";}};} ---const  TopMargin = 400;  LeftMargin = 500;  BottomMargin = 500; procedure TfrmPrinterSetUp.PrintOddEven;var  i, Line, PageCntr, Result : Integer;beginPrinter.BeginDoc ;Printer.Canvas.Font.Name := 'MS Sans Serif';Printer.Canvas.Font.Size := 10;Printer.Canvas.Font.Color := clBlack;Line := TopMargin;PageCntr := 1;for i := 0 to Memo1.Lines.Count - 1 dobegin  Line := Line + Abs(Printer.Canvas.Font.Height);  if (Line >= Printer.PageHeight - BottomMargin) then    begin      Line := TopMargin;      PageCntr := PageCntr + 1;      if (PageCntr mod 2) = 1 then Printer.NewPage;    end;    if (PageCntr mod 2) = 1 then      Printer.Canvas.TextOut(LeftMargin, Line, Memo1.Lines[i]);end;Printer.EndDoc;lblPageCntr.Caption := IntToStr(PageCntr);// Prompt user before printing even pagesresult := MessageDlg('Even pages will be printed on the back of the paper. Switch paper now?',mtError,mbYesNo,0);if result = mrYes then  begin    Printer.BeginDoc ;    Printer.Canvas.Font.Name := 'MS Sans Serif';    Printer.Canvas.Font.Size := 10;    Printer.Canvas.Font.Color := clBlack;    Line := TopMargin;    PageCntr := 1;    for i := 0 to Memo1.Lines.Count - 1 do      begin        Line := Line + Abs(Printer.Canvas.Font.Height);        if (Line >= Printer.PageHeight - BottomMargin) then          begin            Line := TopMargin;            PageCntr := PageCntr + 1;            if (PageCntr mod 2) = 0 then Printer.NewPage;          end;     if (PageCntr mod 2) = 0 then       Printer.Canvas.TextOut(LeftMargin, Line, Memo1.Lines[i]);   end;   Printer.EndDoc;   lblPageCntr.Caption := IntToStr(PageCntr); end;end;  

jamie:
Beware that some printers can print double sided.  If you set that up, you don't have to worry about simulating it.

Navigation

[0] Message Index

Go to full version