Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Force papersize when printing QuickReport

Posted on 2002-05-29
4
Medium Priority
?
2,968 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
ginsonic earned 150 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

610 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