Solved

Counting the number of pages to be printed

Posted on 1998-06-28
8
455 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

22 Experts available now in Live!

Get 1:1 Help Now