Matching output color from Preview with PDFKit
Matching output color from Preview with PDFKit
- Subject: Matching output color from Preview with PDFKit
- From: Chris Backas <email@hidden>
- Date: Mon, 22 Aug 2011 16:22:53 -0400
Hello all,
I am trying to setup an internal application that prints PDF documents
in an automated fashion to a set of known internal printers. I have
played with the various vendor settings in the Print dialog in Preview
long enough to get a saved set of print options that produce the color
output we want, and I'm now trying to apply these settings to my Cocoa
output. I have the printer writing the settings it receives on the
sides of the document, so I know that both my program and Preview are
setting the same driver options as desired; however, the color output
from my program is significantly different than Preview's, and I'm
hoping someone can shed some light on this discrepancy.
Here's the code I'm currently working testing with. (Yes, I know
getPrintOperationForPrintInfo:autoRotate: is a private method. This
isn't going to be a shipping application)
-(IBAction)test1:(id)sender
{
NSDictionary* printerPresets = [NSDictionary
dictionaryWithContentsOfFile:@"/Users/cbackas/Library/Preferences/
com.apple.print.custompresets.plist"];
NSMutableDictionary* ourPrinterSettings = [NSMutableDictionary
dictionaryWithDictionary:[[printerPresets objectForKey:@"Test
TrueColor Printing"] objectForKey:@"com.apple.print.preset.settings"]];
// Remove 'Apple' saved settings as they interfere with the Print
Settings we try to set below (Page Ranges etc)
NSEnumerator* keyCursor = [ourPrinterSettings keyEnumerator];
NSMutableArray* appleKeys = [NSMutableArray array];
NSString* oneKey = nil;
while (oneKey = [keyCursor nextObject])
{
if ([oneKey hasPrefix:@"com.apple"] && ![oneKey
contains:@"Color"]) // Preserve keys relating to Color operation
{
[appleKeys addObject:oneKey];
}
}
[ourPrinterSettings removeObjectsForKeys:appleKeys];
// Create the print settings.
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
[printInfo setTopMargin:0.0];
[printInfo setBottomMargin:0.0];
[printInfo setLeftMargin:0.0];
[printInfo setRightMargin:0.0];
[printInfo setHorizontalPagination:NSFitPagination];
[printInfo setVerticalPagination:NSFitPagination];
NSPrinter* thePrinter = [NSPrinter printerWithName:@"Odin"];
[printInfo setPrinter:thePrinter];
[[printInfo printSettings]
addEntriesFromDictionary:ourPrinterSettings];
PMPrintSettings printSystemSettings = [printInfo PMPrintSettings];
PMSetPageRange(printSystemSettings,1,kPMPrintAllPages);
PMSetFirstPage(printSystemSettings,1,true);
PMSetLastPage(printSystemSettings,kPMPrintAllPages,true);
PMPrintSettingsSetJobName(printSystemSettings,(CFStringRef)@"Test
Job");
PMSetCopies(printSystemSettings,1,true);
PMSetDuplex(printSystemSettings,kPMDuplexNoTumble);
PMSetCollate(printSystemSettings,true);
[printInfo updateFromPMPrintSettings];
// Create the document reference.
PDFDocument *pdfDocument = [[[PDFDocument alloc] initWithURL:[NSURL
URLWithString:@"file://localhost/Volumes/Users/cbackas/Test.pdf"]]
autorelease];
NSPrintOperation *op = [pdfDocument
getPrintOperationForPrintInfo:printInfo autoRotate:YES];
// Run the print operation without showing any dialogs.
[op setShowsPrintPanel:NO];
[op setShowsProgressPanel:NO];
[op runOperation];
}
CONFIDENTIALITY NOTICE: This email (and any related attachments) contains information from InfoPlus (a service of Bristol Capital, Inc.). It is intended only for the addressee and may contain information that is confidential and/or otherwise exempt from disclosure under applicable law. If you are not the intended recipient or are acting as agent for the intended recipient, any use or disclosure of this communication is prohibited. If you have received this communication in error, please notify me immediately to arrange for the appropriate method of returning or disposing of the communication. If our respective Companies have confidentiality provisions in effect, this email and the materials contained herein are deemed CONFIDENTIAL and should be treated accordingly unless expressly provided otherwise.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden