Solved

Force papersize when printing QuickReport

Posted on 2002-05-29
4
2,665 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
Comment Utility
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
Comment Utility
0
 
LVL 1

Expert Comment

by:pnh73
Comment Utility
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
Comment Utility
Thankyou for your response.

Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now