Print two A5 on a A4 paper

General TRichView support forum. Please post your questions here
Post Reply
tothpaul
Posts: 42
Joined: Fri Feb 06, 2015 10:41 am

Print two A5 on a A4 paper

Post 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
tothpaul
Posts: 42
Joined: Fri Feb 06, 2015 10:41 am

Post 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
Sergey Tkachenko
Site Admin
Posts: 17267
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Does it help?
tothpaul
Posts: 42
Joined: Fri Feb 06, 2015 10:41 am

Post by tothpaul »

at least on my printer, now I have two A5 side by side instead of two overlapping A4 ;)
Post Reply