Solved

Can I change the Paper size at runtime?

Posted on 2000-04-19
4
195 Views
Last Modified: 2010-04-04
I want to change a Qreport from A3 to A4, How can I do that at runtime?

thanks
0
Comment
Question by:kelvinyu
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
ronvp earned 50 total points
ID: 2733591
To set the report paper size just do like this:
         
aReport.Page.PaperSize := A4
or back

aReport.Page.PaperSize := A3;

Note that when you change paper size that your controls may not always prinht correctly..

also here is a tip.. If you design reports in Landscape A4, and then change to Portrait A3, you will keep your report looking good and get more records on a page..

Switching from landscape to portrait is done like this:
 
aReport.Page.Orientation := poPortrait;

Before you switch from A4 to A3 from within your code, you may check if the printer actually supports A3 like this:

(function returns TRUE if the printer supports A3 or 11" x 17"

Function PrinterHasA3: Boolean;
var Device, Driver, Port: array[0..255] of char;
    ADevMode: THandle;
    Rslt: integer;
    i: integer;
    PN: Array of Word;
Begin
   Screen.Cursor := crHourGlass;
   Result := False;
   with Printer do
       GetPrinter(Device, Driver, Port, ADevMode);
   // Get the number of paper names
   Rslt := DeviceCapabilitiesA(Device, Port, DC_PAPERS, nil, nil);
   if Rslt > 0 then begin
     SetLength(PN, Rslt);
     try
       // Retrieve the list of names into memory
       if DeviceCapabilitiesA(Device, Port, DC_PAPERS, Pointer(PN), nil) = - 1 then
          raise Exception.Create('Device capabilites error');
       // Check the paper names
       for i := 0 to Rslt - 1 do
          If (PN[i] = DMPAPER_11X17) or (PN[i] = DMPAPER_A3) then begin
             Result := True;
             Break;
          end;
     finally
       PN := NIL;
    end;
  end;
  Screen.Cursor := crDefault;
end;

0
 

Author Comment

by:kelvinyu
ID: 2733669
ronvp:

I have tried this method before, while complie the program ,it met a error message - "Undeclared Indentifier:'A4'"
Should I use some UNITs?
0
 
LVL 1

Expert Comment

by:ronvp
ID: 2734987
Kelvinyu,

You must have QRPrntr in your uses clause..

Ron
0
 

Author Comment

by:kelvinyu
ID: 2742586
The Report Size can be changed now
Thanks you
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question