mPageSeqFrame->GetNumPages(&numPages); if (fromPage > numPages) { return PR_TRUE; } if (toPage > numPages) { toPage = numPages; }  PRINT_DEBUG_MSG4("****** Printing Page %d printing from %d to page %d\n", pageNum, fromPage, toPage);
DocumentViewerImpl::PrintPage(nsIPresContext* aPresContext,                              nsIPrintOptions* aPrintOptions){  nsresult rv;  NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);  if (NS_SUCCEEDED(rv) && printService) {    PRBool isCancelled;    printService->GetIsCancelled(&isCancelled);    if (isCancelled) {      printService->SetIsCancelled(PR_FALSE);      return PR_TRUE;    }  }  PRInt32 pageNum;  PRInt32 curPage;  PRInt32 endPage;  mPageSeqFrame->GetCurrentPageNum(&pageNum);  PRBool donePrinting = PR_FALSE;  PRBool isDoingPrintRange;  mPageSeqFrame->IsDoingPrintRange(&isDoingPrintRange);  if (isDoingPrintRange) {    PRInt32 fromPage;    PRInt32 toPage;    mPageSeqFrame->GetPrintRange(&fromPage, &toPage);#if defined(DEBUG_rods) || defined(DEBUG_dcone)    printf("****** Printing Page %d printing from %d to page %d\n", pageNum, fromPage, toPage);#endif    donePrinting = pageNum >= toPage;    curPage = pageNum - fromPage;    endPage = toPage - fromPage;  } else {    PRInt32 numPages;    mPageSeqFrame->GetNumPages(&numPages);#if defined(DEBUG_rods) || defined(DEBUG_dcone)    printf("****** Printing Page %d of %d page(s)\n", pageNum, numPages);#endif    donePrinting = pageNum >= numPages;    curPage = pageNum;    endPage = numPages;  }  if (mPrintListener) {    // Make sure the Listener gets a "zero" progress at the beginning    // so it can initialize it's state    if (curPage == 1) {      mPrintListener->OnProgressPrinting(0, endPage);     }    mPrintListener->OnProgressPrinting(curPage, endPage);   }  mPageSeqFrame->PrintNextPage(aPresContext, aPrintOptions);  return donePrinting;}