Solved

Counting the number of pages to be printed

Posted on 1998-06-28
8
459 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

12 Experts available now in Live!

Get 1:1 Help Now