[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Printer analysis

Posted on 1999-01-05
2
Medium Priority
?
155 Views
Last Modified: 2010-05-18
I am trying to write a program that can detect when the attached printer (either local or on the network) starts printing a job and when it stops printing that job.  The program will then time how long it takes to complete printing the job in question.  The jobs can be from any application (eg a MS Word doc that is being printed).

How can I detect and monitor the status of a print job that has been spooled by an external program (eg MS Word) ?

I would be grateful for any help offered regarding this.

Thanks in advance

John Clarke
0
Comment
Question by:johnclarke
[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 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1354607
Hi John,

please look at winAPI EnumJobs. Sorry, have no demo sources for that, but it should be exactly what you need...

Regards, Madshi.
0
 

Accepted Solution

by:
puzhikadu earned 200 total points
ID: 1354608
const INCHES_PER_MILIMETER : Real  = 0.04;type  TOffset =   record
               X,Y: Integer;              end;
var FDeviceName : String;  {Get the name}
    FPageHeightPixel, FPageWidthPixel : Integer ;  {Page height and Page Width}
    FOrientation : TPrinterOrientation; {Orientation}
    FPrintOffsetPixels : TOffset;    FPixelsPerMMX,FPixelsPerMMY: Real;
    MMSize, FPageHeightMM : Integer;
    TheReport, TheHead, HeadLine, RecordLine, TFname, TLname :String;
procedure TMissing_Rep.GetDeviceSettings;var  retval: integer;
  PixX, PixY: Integer;begin
    FDeviceName := Printer.Printers[Printer.PrinterIndex];  {Get the name}
    FPageHeightPixel := Printer.PageHeight;                 {Page height}
    FPageWidthPixel := Printer.PageWidth;                   {Page Width}
    FOrientation := Printer.Orientation;{Orientation}
    {Get the printable area offsets}    {$IFDEF WIN32}
       FPrintOffsetPixels.X := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX);
       FPrintOffsetPixels.Y := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY);
    {$ELSE}       retval := Escape(Printer.Handle,GETPRINTINGOFFSET,
                        0, nil, @FPrintOffsetPixels);    {$ENDIF}
    {Get Pixels per Milimeter Ratio}
    PixX := GetDeviceCaps(Printer.Handle, LOGPIXELSX);
    PixY :=  GetDeviceCaps(Printer.Handle, LOGPIXELSY);
    FPixelsPerMMX := INCHES_PER_MILIMETER * PixX;
    FPixelsPerMMY := INCHES_PER_MILIMETER  * PixY;
    FPageHeightMM := Round(FPageHeightPixel/FPixelsPerMMY); end;
function TMissing_Rep.PutText(mmX,mmY: Integer; S: string; LeftAlign:
Boolean): boolean;var  X, Y: Integer;  align: WORD;begin  if LeftAlign then
    align :=  SetTextAlign(Printer.Handle,TA_BOTTOM or TA_LEFT)  else
    align :=  SetTextAlign(Printer.Handle,TA_BOTTOM or TA_RIGHT);
  result := FALSE; {Assume fail}
  X := Trunc(mmX * FPixelsPerMMX) - FPrintOffsetPixels.X;
  Y := Trunc(mmY * FPixelsPerMMY) - FPrintOffsetPixels.Y;  if X < 0 then exit;
  if Y < 0 then exit;  Printer.Canvas.TextOut(X,Y,S);  result := TRUE;end;
procedure TMissing_Rep.Print_ButClick(Sender: TObject);var PixelSize: Integer;
beginPrint_But.Enabled := False;if PrintDialog1.Execute then begin
 Printer.Canvas.Font := Missing_Rep.Font;
 PixelSize := Printer.Canvas.TextHeight('Yy');
 MMSize := Round(PixelSize/FPixelsPerMMY);
 Printer.Title := 'Breast Cancer Project Missing Report';
 Printer.BeginDoc;                        { begin to send print job to printer }
 PrintGenerator;
 Printer.EndDoc;                 { EndDoc ends and starts printing print job }
 end; Print_But.Enabled := True; end;procedure TMissing_Rep.PrintGenerator;Var
  yLoc , NumRows, TheRow :Integer;  procedure Heading;  begin   yLoc := 20;
   PutText(20, 20, TheHead, TRUE);   yLoc := yLoc + MMSize;
   PutText(20,  yLoc, StringGrid1.Cells[0,0], TRUE);
   PutText(60,  yLoc, StringGrid1.Cells[1,0], TRUE);
   PutText(100, yLoc, StringGrid1.Cells[2,0], TRUE);
   PutText(120, yLoc, StringGrid1.Cells[3,0], TRUE);
   PutText(150, yLoc, StringGrid1.Cells[4,0], TRUE);   yLoc := yLoc + MMSize;
 end;  procedure Footer;  begin
  PutText(100,FPageHeightMM,InttoStr(Printer.PageNumber), TRUE);  end;begin
   Heading;   TheRow := 1;   while (TheRow < StringGrid1.RowCount) do   begin
       if (yLoc > (FPageHeightMM - MMSize)) then         begin              Footer;
              Printer.NewPage;              Heading;           end;
       TheGauge.Progress := Round(100 * TheRow/(StringGrid1.RowCount - 1));
       PutText(20,  yLoc, StringGrid1.Cells[0,TheRow], TRUE);
       PutText(60,  yLoc, StringGrid1.Cells[1,TheRow], TRUE);
       PutText(100, yLoc, StringGrid1.Cells[2,TheRow], TRUE);
       PutText(120, yLoc, StringGrid1.Cells[3,TheRow], TRUE);
       PutText(150, yLoc, StringGrid1.Cells[4,TheRow], TRUE);       yLoc := yLoc + MMSize;
       TheRow := TheRow + 1; end;Footer;end;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

649 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