Page 1 of 1

Printing to 11x17 Paper

Posted: Wed Nov 15, 2006 3:32 pm
by 9242408
Using the Chart.Print method from a preview panel how do I set it so it prints it to a 11x17 paper rather than 8.5x11?

Thanks,

Tom

Posted: Thu Nov 16, 2006 1:17 pm
by 9242408
Theres a PaperRect property, does anyone know how to use it? I dont see anything in the docs or the tutorials on it.


Thanks,

Tom

Re: Printing to 11x17 Paper

Posted: Fri Nov 17, 2006 8:15 am
by Marjan
9242408 wrote:Using the Chart.Print method from a preview panel how do I set it so it prints it to a 11x17 paper rather than 8.5x11?
Print preview panel gets it's page size from currently selected printer. To change (programatically) page size prior to showing print preview editor, you'll have to use the approach, described at Borland bdn. Link:
http://bdn.borland.com/article/15603
Here is the code I used in D2006 Win32:

Code: Select all

var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port   : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
begin
  Printer.PrinterIndex := Printer.PrinterIndex;
  Printer.GetPrinter(Device, Driver, Port, hDMode);
  if hDMode <> 0 then begin
    pDMode := GlobalLock(hDMode);
    if pDMode <> nil then begin

     {Set to 11x17}
      pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
      pDMode^.dmPaperSize := DMPAPER_11X17;
      GlobalUnlock(hDMode);
    end;
  end;
  ChartPreviewer1.Execute;
end;
Of course, this will work only if your printer supports 11x17 (you could add safeguard check before the dmPaperSize call.

Posted: Fri Nov 17, 2006 12:26 pm
by 9242408
Thank you, Thank you, Thank you.

That works wonders!!!!!!!!!!!!!!

Posted: Sun Nov 19, 2006 4:09 pm
by 9242408
Well my only issue now is trying to get the charts to be the right size on the paper. 8.5x11 worked fine, but the charts are sooo huge on the larger paper. Is there a shrink to fit or fit to page option with the above code. Of course as usual I cant find any docs on it whatsoever.

Heres how I add my charts to the preview panel:

Code: Select all

procedure TForm1.AdvToolBarButton14Click(Sender: TObject);
Var
topc,botc: Integer;
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port   : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;

begin
Printer.PrinterIndex := Printer.PrinterIndex;
  Printer.GetPrinter(Device, Driver, Port, hDMode);
  if hDMode <> 0 then begin
    pDMode := GlobalLock(hDMode);
    if pDMode <> nil then begin

     {Set to 11x17}
      pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
      pDMode^.dmPaperSize := DMPAPER_11X17;
      GlobalUnlock(hDMode);
    end;
  end;
 topc := 10;
 botc := 70;
  for i := 0 to charts - 1 do
  begin
   TeePreviewPanel1.Panels.Add(mychart[i]);
   mychart[i].PrintProportional := False;
   mychart[i].PrintMargins:=Rect(1,topc,1,botc);
   topc := topc + 20;
   botc := botc - 20;
  end;
  TeePreviewPanel1.Orientation := ppoPortrait;
  
  TeePreviewPanel1.Print;
  //ChartPreviewer1.Execute;
end;

Thanks.

Tom

Posted: Mon Nov 20, 2006 9:08 am
by narcis
Hi Tom,

I've just sent you a document which can be found at news://www.steema.net/steema.public.attachments newsgroup. It is from my colleague Pep and its title is Printing Better.

I hope this helps.