I am new to PDF creation technique in MAC OSx.
Can you please help me to create PDF programmatically from NSString
.
I have a multiple HTML files and I am going to create the PDF of each one and this html file I am not going to display on Screen.So printing technique also not help to me.
NSPrintInfo *printInfo;
NSPrintInfo *sharedInfo;
NSPrintOperation *printOp;
NSMutableDictionary *printInfoDict;
NSMutableDictionary *sharedDict;
sharedInfo = [NSPrintInfo sharedPrintInfo];
sharedDict = [sharedInfo dictionary];
printInfoDict = [NSMutableDictionary
dictionaryWithDictionary:sharedDict];
[printInfoDict setObject:NSPrintSaveJob forKey:NSPrintJobDisposition];
NSString *tempFileName =
[NSString stringWithFormat:@"%@_file_%lu.pdf",
[[NSProcessInfo processInfo] globallyUniqueString], fileNumber];
NSURL *poTempfileURL =
[_tempDirectoryURL URLByAppendingPathComponent:tempFileName];
[printInfoDict setObject:poTempfileURL forKey:NSPrintJobSavingURL];
printInfo =
[[NSPrintInfo alloc] initWithDictionary:printInfoDict];//1
[printInfo setHorizontalPagination: NSAutoPagination];//2
[printInfo setVerticalPagination: NSAutoPagination];//3
[printInfo setVerticallyCentered:NO];//4
printOp = [NSPrintOperation printOperationWithView:textView printInfo:printInfo];//5
[printOp setShowsPrintPanel:NO];
[printOp setShowsProgressPanel:NO];//6
DLog(@"poTempfileURL=%@",poTempfileURL);
BOOL didRunOK = [printOp runOperation];//7
As you see '[NSPrintOperation printOperationWithView:textView printInfo:printInfo];' this line required view to print and I not going to display my content to any view. So please help me out to find out the best way to same.