Re: Why doesn't this code produce a PDF?
Re: Why doesn't this code produce a PDF?
- Subject: Re: Why doesn't this code produce a PDF?
- From: Andre John Mas <email@hidden>
- Date: Thu, 12 Jul 2001 18:31:13 -0400
Forgot to mention that 'theText' is an NSTextView.
Andre
On Thursday, July 12, 2001, at 06:28 PM, Andre John Mas wrote:
Hi,
I have written this method and I can't get it to create a PDF file. Is
there a right way to do this? I have seen a number of apps that offer
this facility, but no source code examples.
Andre
- (void)printText:(id)sender
{
NSPrintOperation *printOperation;
NSPrintInfo *sharedPrintInfo;
NSPrintInfo *myPrintInfo;
NSMutableDictionary *myPrintInfoDict;
NSSavePanel *savePanel;
NSMutableDictionary *dict;
savePanel = [NSSavePanel savePanel];
[savePanel setRequiredFileType:@"pdf"];
if ([savePanel runModal])
{
// Although we are storing to file, we want to be able to use the
// same page layout
sharedPrintInfo = (NSPrintInfo*)[NSPrintInfo sharedPrintInfo];
dict = [sharedPrintInfo dictionary];
myPrintInfoDict = [ NSMutableDictionary dictionaryWithDictionary:
dict ];
[myPrintInfoDict setObject:NSPrintSaveJob
forKey:NSPrintJobDisposition ];
// Is this necessary?
[myPrintInfoDict setObject:[savePanel filename]
forKey:NSPrintSavePath ];
myPrintInfo = [NSPrintInfo alloc];
[myPrintInfo initWithDictionary: myPrintInfoDict];
[myPrintInfo setHorizontalPagination: NSFitPagination];
[myPrintInfo setVerticallyCentered:NO];
// printOperation = [NSPrintOperation
[printOperationWithView:textView printInfo: myPrintInfo];
printOperation = [NSPrintOperation PDFOperationWithView:theText
insideRect:[theText bounds]
toPath:[savePanel filename]
printInfo:myPrintInfo
];
[printOperation setShowPanels:NO];
[printOperation runOperation];
}
}
--
mailto:email@hidden