//----------------------------------------------------------------------------------------------------------------------- void ProcessPrintCommand(DocStoragePtr docStP, UInt32 commandID) { OSStatus err = noErr; PMPrintSession printSession = NULL; if ( PMCreateSession(&printSession) == noErr ) { if (commandID == kHICommandPageSetup) { DoPageSetupDialog(printSession, &docStP->pageFormat, &docStP->flattenedPageFormat); } else if (commandID == kHICommandPrint) { if (docStP->pageFormat == NULL) { err = MyCreatePageFormat(printSession, &docStP->pageFormat); } if (DoPrintDialog(printSession, docStP->pageFormat, &docStP->printSettings) == noErr) { DoPrintLoop(docStP, printSession, docStP->pageFormat, docStP->printSettings); } } PMRelease(printSession); } else { fprintf(stderr, "PMCreateSession FAILED\n"); } } // ProcessPrintCommand
int ioPrintPreProcessing(PrintingLogicPtr printJob,int numberOfPages) { OSStatus status = noErr; UInt32 realNumberOfPagesinDoc; // Display the Print dialog. if (printJob->printSession == NULL) return -1; printJob->numberOfPages = numberOfPages; printJob->allowPostscript = false; status = DoPrintDialog(printJob); if (status == noErr) { //issues with os 9 don't do CFStringRef jobName = CFSTR("Squeak"); //issues with os 9 don't do status = PMSetJobNameCFString(printJob->printSettings, jobName); // Get the user's Print dialog selection for first and last pages to print. if (status == noErr) { status = PMGetFirstPage(printJob->printSettings, &printJob->firstPage); if (status == noErr) status = PMGetLastPage(printJob->printSettings, &printJob->lastPage); } // Check that the selected page range does not exceed the actual number of // pages in the document. if (status == noErr) { status = DetermineNumberOfPagesInDoc(&realNumberOfPagesinDoc,printJob); if (realNumberOfPagesinDoc < printJob->lastPage) printJob->lastPage = realNumberOfPagesinDoc; } // Before executing the print loop, tell the Carbon Printing Manager which pages // will be spooled so that the progress dialog can reflect an accurate page count. // This is recommended on Mac OS X. On Mac OS 8 and 9, we have no control over // what the printer driver displays. if (status == noErr) status = PMSetFirstPage(printJob->printSettings, printJob->firstPage, false); if (status == noErr) status = PMSetLastPage(printJob->printSettings, printJob->lastPage, false); if (status == noErr) status = PMSetPageRange(printJob->printSettings, 1, printJob->lastPage-printJob->firstPage+1); // Check if we can add PostScript to the spool file if (status == noErr) { CFStringRef strings[1]; CFArrayRef ourGraphicsContextsArray; OSErr err = noErr; printJob->allowPostscript = true; //IncludePostScriptInSpoolFile(printJob); // // at this point you've already created a print session // strings[0] = kPMGraphicsContextCoreGraphics; // This is important! ourGraphicsContextsArray = CFArrayCreate (kCFAllocatorDefault, (const void **)strings, 1, &kCFTypeArrayCallBacks); if (ourGraphicsContextsArray != NULL) { err = PMSessionSetDocumentFormatGeneration (printJob->printSession, kPMDocumentFormatPDF, ourGraphicsContextsArray, NULL); CFRelease (ourGraphicsContextsArray); } } // Begin a new print job. status = PMSessionBeginDocument(printJob->printSession, printJob->printSettings, printJob->pageFormat); } return status; }
void CWinApp::OnFilePrintSetup() /******************************/ { CPrintDialog dlg( TRUE ); DoPrintDialog( &dlg ); }
void CWinApp::OnFilePrintSetup() { CPrintDialog pd(TRUE); DoPrintDialog(&pd); }