Page 1 of 1

Print two A5 on a A4 paper

Posted: Wed Oct 19, 2016 3:59 pm
by tothpaul
Hello,

I've made a little change in TPrintableRV to support what I've called a "TwinMode", the call to Printer.NewPage is replaced by a call to TwinPage

Code: Select all

procedure TPrintableRV.TwinPage(PageNo: Integer);
var
  XFORM: tagXFORM;
begin
  if not TPrintableRVData(RVdata).TwinMode then
  begin
    if PageNo > 1 then
      Printer.NewPage;
    Exit;
  end;
  if (PageNo > 1) and (PageNo and 1 = 1) then
    Printer.NewPage;
  with Printer.Canvas do
  begin
    if PageNo and 1 = 1 then
    begin
      if Printer.Orientation = poPortrait then
      begin
        MoveTo(0, Printer.PageHeight div 2);
        LineTo(Printer.PageWidth, Printer.PageHeight div 2);
      end else begin
        MoveTo(Printer.PageWidth div 2, 0);
        LineTo(Printer.PageWidth div 2, Printer.PageHeight);
      end;
    end;
   // x' = x * eM11 + y * eM21 + eDx
   // y' = x * eM12 + y * eM22 + eDy
    XFORM.eM11 :=  0;
    XFORM.em12 := -(210/297); // A4 (210x297) -> A5 (148x210)
    XFORM.em21 := +(210/297);
    XFORM.em22 :=  0;
    if Printer.Orientation = poPortrait then
    begin
      XFORM.eDx  := 0;
      XFORM.eDy  := Printer.PageHeight;
      if PageNo and 1 = 0 then
      begin
        XFORM.eDy := XFORM.eDy / 2;
      end;
    end else begin
      XFORM.eDx  := 0;
      XFORM.eDy  := Printer.PageHeight;
      if PageNo and 1 = 0 then
      begin
        XFORM.eDx := Printer.PageWidth / 2;
      end;
    end;
    SetGraphicsMode(Handle, GM_ADVANCED);
    SetWorldTransform(Handle, XFORM);
  end;

end;
it works fine on the XPS Windows vitutal printer driver, but on my Samsung printer, the page is printed without any transformation.

Do you know why this doesn't work ?

The other solution is to lie about the printer specifications, but the code seems a little complex to deal with that. Can you point me to some key functions that I could play with ?

I've tried to change Printer orientation and scale down the device part of sad:TRVScreenAndDevice...it doesn't seems to change anything :(

Regards

Posted: Thu Oct 20, 2016 8:15 am
by tothpaul
that's insane !!!

do not use SetWorldTransform on a printer canvas

Code: Select all

//    SetWorldTransform(Handle, XFORM);
     ModifyWorldTransform(Handle, XFORM, MWT_IDENTITY); // Reset
     ModifyWorldTransform(Handle, XFORM, MWT_LEFTMULTIPLY); // Apply change

Posted: Thu Oct 20, 2016 12:37 pm
by Sergey Tkachenko
Does it help?

Posted: Thu Oct 20, 2016 12:44 pm
by tothpaul
at least on my printer, now I have two A5 side by side instead of two overlapping A4 ;)