Solved

Force papersize when printing QuickReport

Posted on 2002-05-29
4
2,807 Views
Last Modified: 2013-11-22
Hi Experts,

I'm having a nasty problem with QuickReport reports in my application:

I designed all reports with papersize A4. So, the Page.Papersize property of all QuickReport reports shows A4. So far, no problem.

Now, in my company, there are several HP DeskJet printers which seems not to use this QuickReport papersize. With laserjet printers there's no problem, even if the laserjet driver has i.e. papersize Letter selected, the reports is printed as A4. That's OK.
Some DeskJets however seem to use their own current papersize setting. Even if the user selects A4 in the printer dialog (that is launched by a QuickReport.Printersetup method), the report is printed with Letter papersize on the DeskJet. Therefore a part of the report is missing !
When I print i.e. using MS-Word on the DeskJet, there's no problem. In Word's print dialog you can change the size Letter to A4, and the MS-Word print comes out correct.

Because all reports are A4 reports (and all printers in my company have A4 paper loaded), I would like to force the printer papersize before every print to A4, but I don't know how to do this.
I tried QuickReport.Page.Papersize := A4 and QuickReport.PrinterSettings.Papersize := A4, but the compiler does'nt accept this.

So, my question is: how can I force the papersize of the QuickReport print to A4, and overrule all settings of the driver? The QuickRep.PrinterSetup method (where you also can select a papersize) does'nt seem to have effect on some HP DeskJets.
Or is there perhaps another way to get rid of this problem?

Hope someone can help.

Thanks,
JDN
0
Comment
Question by:JDN
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
ginsonic earned 50 total points
ID: 7046224
Maybe you must set the size through code :

procedure TForm1.Button1Click(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 := 100 {SomeValueInTenthsOfAMillimeter};
      pDMode^.dmPaperLength := 100 {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(100,100, 'Test 1');
  Printer.EndDoc;
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7046226
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9010354
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from ginsonic

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9011171
Thankyou for your response.

Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 188
Delphi Ado Query To Converts Joined Columns Into Rows Based on Primary Key 4 82
IP without any Dots 1 60
Delphi Firemonkey : user drawing in window 3 29
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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