• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Why doesn't this code produce a PDF?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why doesn't this code produce a PDF?


  • Subject: Why doesn't this code produce a PDF?
  • From: Andre John Mas <email@hidden>
  • Date: Thu, 12 Jul 2001 18:28:57 -0400

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


  • Prev by Date: Re: cocoa-dev digest, Vol 1 #276 - 13 msgs
  • Next by Date: Re: Why doesn't this code produce a PDF?
  • Previous by thread: Re: cocoa-dev digest, Vol 1 #276 - 13 msgs
  • Next by thread: Re: Why doesn't this code produce a PDF?
  • Index(es):
    • Date
    • Thread