Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Changing the papersize of a print job.


How can I change the papersize of my print job?   

    One way to change printer settings at the start of a print job is to change the printer's devicemode structure. See: TDEVMODE in the Delphi .02 help file or DEVMODE in the Delphi 2.0 help file for other settings you can change (providing the print driver supports the change). The following example, contains code to change the papersize and the paper bin that is used:

    procedure TForm .Button Click(Sender: TObject);
    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 legal}
          pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
          pDMode^.dmPaperSize := DMPAPER_LEGAL;
         {Set to custom size}
          pDMode^.dmFields := pDMode^.dmFields or 
                              DM_PAPERSIZE or
                              DM_PAPERWIDTH or
                              DM_PAPERLENGTH;
          pDMode^.dmPaperSize := DMPAPER_USER;
          pDMode^.dmPaperWidth :=  00 {SomeValueInTenthsOfAMillimeter};
          pDMode^.dmPaperLength :=  00 {SomeValueInTenthsOfAMillimeter};
         {Set the bin to use}
          pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
          pDMode^.dmDefaultSource := DMBIN_MANUAL;
          GlobalUnlock(hDMode);
        end;
      end;
      Printer.PrinterIndex := Printer.PrinterIndex;
      Printer.BeginDoc;
      Printer.Canvas.TextOut( 00, 00, 'Test  ');
      Printer.EndDoc;
    end;
    

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use