Solved

Force papersize when printing QuickReport

Posted on 2002-05-29
4
2,741 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Comparing dates in Delphi. Greater than/ Less than 3 148
creating threads in delphi 1 101
PHP preg_replace code convert to Delphi 14 54
enhance the following code 3 29
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

9 Experts available now in Live!

Get 1:1 Help Now