Change default printer in Mac

The following statement change default printer to “hp LaserJet 1320 series (FBBF32)”.

What u have to do is replace non-alphanumeric symbols with “_”.

system(“lpoptions -d hp_LaserJet_1320_series__FBBF32_”);

Code to set our printer as default printer and reset to previous one.

=================================================================

=================================================================

// Create Session for Printing Operation.

PMCreateSession(&printSession);

PMPrinter printer;

PMSessionGetCurrentPrinter(printSession, &printer);

CFStringRef availablePrinterID = (CFStringRef) PMPrinterGetID(printer);

CFRetain(availablePrinterID);

char *printerNameToLPOptions = (char *) malloc ( sizeof(char) * ( 14 + strlen(printerName)) );

strcpy(printerNameToLPOptions,”lpoptions -d “);

strcat(printerNameToLPOptions,CFStringGetCStringPtr(getPrinterID(printerName),kCFStringEncodingMacRoman));

printerNameToLPOptions[strlen(printerNameToLPOptions)] =”;

system(printerNameToLPOptions);

}

PMRelease(printSession);

char *aPrinterName = (char*)CFStringGetCStringPtr(availablePrinterID,kCFStringEncodingMacRoman);

char *printerNameToLPOptions = (char *) malloc( sizeof(char) * (14 + strlen(aPrinterName) ) );

strcpy(printerNameToLPOptions,”lpoptions -d “);

strcat(printerNameToLPOptions,aPrinterName);

system(printerNameToLPOptions);

CFRelease(availablePrinterID);

=================================================================

=================================================================

technorati tags:, , , ,

Blogged with Flock

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: