Solved

Counting the number of pages to be printed

Posted on 1998-06-28
8
471 Views
Last Modified: 2010-04-04
I am working on a kiosk program. I would like to be able to provide printing capability but I need to be able to count the number of pages that will be printed before it starts printing in order to inform the user of the cost. Any suggestion on how I could do this ?
0
Comment
Question by:yvesmail
8 Comments
 
LVL 1

Expert Comment

by:michaue
ID: 1356178
Are you using quick report ??
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1356179
Or you already using a sort of report-printer, or do you have to make one yourself?
0
 
LVL 3

Expert Comment

by:vladika
ID: 1356180
You can preview report and count the number of pages manually :)
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 3

Expert Comment

by:Matvey
ID: 1356181
Also you know the printer page height and width, and your fond height and width, so you can count ho much space it needs.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1356182
-Font
0
 
LVL 3

Accepted Solution

by:
vladika earned 150 total points
ID: 1356183
If you use QuickReport ...

I read it in the QuickReport help

Declaration
property Data : TQRSysDataType

Purpose
The data property is used to select what system data item the TQRSysData component will print.

Value      Meaning
qrsPageCount      Displays the total number of pages in the report. Note that this requires that the report is prepared as a two pass report (TQuickRep.Options.TwoPass). This might take significantly longer time.

But I cannot find such Value, I think it's not implemented.

So, we can self write two pass report.
1) In QuickRep form create property PageCount as
  TForm1 = class(TForm)
    QuickRep1: TQuickRep;
    QRLabel1: TQRLabel;
//   ....................... other controls ..........
    procedure QRLabel1Print(sender: TObject; var Value: String);
  private
    FPageCount: Integer;
  public
    procedure FirstPass;
    property PageCount: Integer read FPageCount write FPageCount;
  end;

2) Set on form QRLabel - it will print PageCount

3) write QRLabel.OnPrint handler as
procedure TForm1.QRLabel1Print(sender: TObject; var Value: String);
begin
  Value := IntToStr(PageCount);  // print PageCount
end;

4) write method which will emaluate first pass
procedure TForm1.FirstPass;
begin
  PageCount := 0;
  QuickRep1.Prepare; // first pass
  PageCount := QuickRep1.PageNumber;  // set PageCount
  QuickRep1.QRPrinter.Free;  // free QRPrinter as write in help
  QuickRep1.QRPrinter := nil;
end;

5) before print or preview we can first call method FirstPass
for preview
  Form1.FirstPass;
  Form1.Preview;
for print
  Form1.FirstPass;
  Form1.Print;

or if you only want to count the number of pages
call FirstPass and read property PageCount


0
 

Author Comment

by:yvesmail
ID: 1356184
Isn't Quick Report for used to create database reports ? I wish to pront data displayed in a Web browser (I am using Internet Explorer ActiveX component). So this is to pront web pages.
0
 
LVL 3

Expert Comment

by:vladika
ID: 1356185
Reject my answer. I did not want autograde.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 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