-1

I am calling GetJob() to get the document name and the TotalPages. I always get the TotalPages as Zero. I saw MSDN, it is said if Page Delimiting information is missing, this value will be zero. Is there a way that I can get the TotalPages or PagesPrinted from GetJob(with any extra settings)

Thanks Santhi

santhiR
  • 41
  • 1
  • 5
  • 1
    Can you share the code that is not working pls – user1793036 May 23 '14 at 03:55
  • I am getting the jobID from StartDoc, BOOL result = OpenPrinter(pDCInfo->PrinterName, &hPrinter, NULL); if (result) { DWORD dwCNeeded = 0; BOOL bStatus = GetJob(hPrinter, pJobID, 2, 0, 0, &dwCNeeded); if (!bStatus && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { pJobBuf = new BYTE[dwCNeeded]; } bStatus = GetJob(hPrinter, pJobID, 2, pJobBuf, dwCNeeded, &dwCNeeded); if (bStatus) { pJobData = (PJOB_INFO_2)pJobBuf; driveData.FileSize = pJobData->PagesPrinted; } } – santhiR May 23 '14 at 12:46
  • all other values I am getting from the struct except TotalPages & PrintedPages. I used JOB_INFO_1 & JOB_INFO_2 both – santhiR May 23 '14 at 12:48
  • Please edit your question and put the code in there. It does not belong in a comment. – Remy Lebeau May 23 '14 at 16:05

1 Answers1

2

I got it working, I was hooking the StartDoc and getting the JobID & try to call GetJob. At this time the number of pages were zero. I tried hooking the EndJob & call the GetJob just before ending, I got the right number for TotalPages & PagesPrinted. Hope this information helps, if any of you see the same problem.

santhiR
  • 41
  • 1
  • 5