Printing to 11x17 Paper

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
tbonejo
Newbie
Newbie
Posts: 73
Joined: Wed Sep 06, 2006 12:00 am
Contact:

Printing to 11x17 Paper

Post by tbonejo » Wed Nov 15, 2006 3:32 pm

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
Tom

tbonejo
Newbie
Newbie
Posts: 73
Joined: Wed Sep 06, 2006 12:00 am
Contact:

Post by tbonejo » Thu Nov 16, 2006 1:17 pm

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
Tom

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Re: Printing to 11x17 Paper

Post by Marjan » Fri Nov 17, 2006 8:15 am

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.
Marjan Slatinek,
http://www.steema.com

tbonejo
Newbie
Newbie
Posts: 73
Joined: Wed Sep 06, 2006 12:00 am
Contact:

Post by tbonejo » Fri Nov 17, 2006 12:26 pm

Thank you, Thank you, Thank you.

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

tbonejo
Newbie
Newbie
Posts: 73
Joined: Wed Sep 06, 2006 12:00 am
Contact:

Post by tbonejo » Sun Nov 19, 2006 4:09 pm

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
Tom

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Nov 20, 2006 9:08 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply