Solved

Force papersize when printing QuickReport

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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