From 6cf02e2b42e93f3140c52f1cf8dc56c45ee439b7 Mon Sep 17 00:00:00 2001 From: ericwa Date: Sun, 13 Mar 2011 23:38:47 +0000 Subject: [PATCH] Allow saving a print job as a PDF git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32559 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Printing/GSCUPS/GSCUPSPrintOperation.m | 14 +++++++++++--- Printing/GSLPR/GSLPRPrintOperation.m | 14 +++++++++++--- Source/NSPrintPanel.m | 2 +- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e75183653..e980a459b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-03-13 Eric Wasylishen + + * Source/NSPrintPanel.m: + * Printing/GSCUPS/GSCUPSPrintOperation.m: + * Printing/GSLPR/GSLPRPrintOperation.m: Allow saving a print + job as a PDF. + 2011-03-13 Wolfgang Lux * Source/NSSpellChecker.m (-_findNext:, -_learn:, -_forget:, diff --git a/Printing/GSCUPS/GSCUPSPrintOperation.m b/Printing/GSCUPS/GSCUPSPrintOperation.m index 16f5ed719..a4c6972d0 100644 --- a/Printing/GSCUPS/GSCUPSPrintOperation.m +++ b/Printing/GSCUPS/GSCUPSPrintOperation.m @@ -117,9 +117,17 @@ [info setObject: _path forKey: @"NSOutputFile"]; - - [info setObject: NSGraphicsContextPSFormat - forKey: NSGraphicsContextRepresentationFormatAttributeName]; + + if ([[[_path pathExtension] lowercaseString] isEqualToString: @"pdf"]) + { + [info setObject: NSGraphicsContextPDFFormat + forKey: NSGraphicsContextRepresentationFormatAttributeName]; + } + else + { + [info setObject: NSGraphicsContextPSFormat + forKey: NSGraphicsContextRepresentationFormatAttributeName]; + } _context = RETAIN([NSGraphicsContext graphicsContextWithAttributes: info]); diff --git a/Printing/GSLPR/GSLPRPrintOperation.m b/Printing/GSLPR/GSLPRPrintOperation.m index cd6325c5f..f5b8315cc 100644 --- a/Printing/GSLPR/GSLPRPrintOperation.m +++ b/Printing/GSLPR/GSLPRPrintOperation.m @@ -139,10 +139,18 @@ [info setObject: _path forKey: @"NSOutputFile"]; + + if ([[[_path pathExtension] lowercaseString] isEqualToString: @"pdf"]) + { + [info setObject: NSGraphicsContextPDFFormat + forKey: NSGraphicsContextRepresentationFormatAttributeName]; + } + else + { + [info setObject: NSGraphicsContextPSFormat + forKey: NSGraphicsContextRepresentationFormatAttributeName]; + } - [info setObject: NSGraphicsContextPSFormat - forKey: NSGraphicsContextRepresentationFormatAttributeName]; - _context = RETAIN([NSGraphicsContext graphicsContextWithAttributes: info]); return _context; diff --git a/Source/NSPrintPanel.m b/Source/NSPrintPanel.m index ade2f5c16..ab2a2a919 100644 --- a/Source/NSPrintPanel.m +++ b/Source/NSPrintPanel.m @@ -254,7 +254,7 @@ static NSPrintPanel *shared_instance; NSSavePanel *sp; sp = [NSSavePanel savePanel]; - [sp setRequiredFileType: @"ps"]; + [sp setAllowedFileTypes: [NSArray arrayWithObjects: @"pdf", @"ps", nil]]; result = [sp runModal]; if (result == NSOKButton) {