Bernie wrote: > Peter wrote: >> I'm trying to get the available sheet sizes for a specific >> printer, so I thought I would try to adapt RP's code that is on >> the CD, but there is some thing I don't understand, well there is >> lots I don't understand, but specifically the PageFormatList does >> not seem to be in the same format as the PrinterList. ie not >> CFArrayRef. >> here is the code I've got upto now, I've dated my changes > I've never dabbled with the print manager but I think I've spotted > a couple potential problems in your code: With a few more changes, the code becomes as shown below. Robert P. '-------------------------- toolbox fn CFArrayGetCount( CFArrayRef theArray ) = CFIndex toolbox fn CFArrayGetValueAtIndex( CFArrayRef theArray, CFIndex idx ) = CFStringRef #define PMPrinter as pointer // to Opaque Object representing a printer toolbox fn PMSessionGetCurrentPrinter( PMPrintSession printSession, PMPrinter *currentPrinter ) = OSStatus toolbox fn PMPrinterGetMakeAndModelName( PMPrinter printer, CFStringRef *makeAndModel ) = OSStatus toolbox fn PMSessionCreatePageFormatList( PMPrintSession session,PMPrinter printer, CFArrayRef *pageformatlist) = OSStatus end globals local mode local fn CreateFormatList( session as PMPrintSession,printer as PMPrinter ) '~'1 dim as OSStatus ignore dim as CFArrayRef @ pageFormatList pageFormatList = 0 long if (session) ignore = fn PMSessionCreatePageFormatList( session, printer, @pageFormatList ) end if end fn = pageFormatList local mode local fn CurrentPrinterMakeAndModel$( session as PMPrintSession ) '~'1 dim as Str255 s dim as PMPrinter @ printer dim as CFStringRef @ makeAndModel dim as Boolean ok s[0] = 0 long if ( session ) if ( fn PMSessionGetCurrentPrinter( session, @printer ) ) then exit fn if ( fn PMPrinterGetMakeAndModelName( printer, @makeAndModel ) ) then exit fn ok = fn CFStringGetPascalString( makeAndModel, @s, sizeof( s ), _kCFStringEncodingMacRoman ) end if end fn = s // Main program '~'1 dim as OSStatus err dim as CFArrayRef pageFormatList dim as long j, k dim as PMPageFormat pageFormat dim as PMRect pageRect dim as PMPrinter @ printer window 1 // All Carbon printer stuff happens within a PMPrintSession. // Create session if none exists long if ( gFBPrintSession == _nil ) err = fn PMCreateSession( @gFBPrintSession ) if err then stop "PMCreateSession error " + str$( err ) end if print "Current make/model: "; fn CurrentPrinterMakeAndModel$ ( gFBPrintSession ) err = fn PMSessionGetCurrentPrinter( gFBPrintSession, @printer ) pageFormatList = fn CreateFormatList( gFBPrintSession, printer ) if ( pageFormatList == 0 ) then stop "CreateFormatList error" j = fn CFArrayGetCount( pageFormatList ) print "Number of page formats available = "; j k = 0 while ( k < j ) pageFormat = fn CFArrayGetValueAtIndex( pageFormatList, k ) err = fn PMGetUnadjustedPaperRect( pageFormat, @pageRect ) print pageRect.top, pageRect.left, pageRect.bottom, pageRect.right k++ wend // clean up CFRelease( pageFormatList ) print "Done" do HandleEvents until ( gFBQuit ) '-------------------------