• 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
NSPrintOperation Fails to Auto-Paginate?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPrintOperation Fails to Auto-Paginate?


  • Subject: NSPrintOperation Fails to Auto-Paginate?
  • From: DairyKnight <email@hidden>
  • Date: Mon, 3 May 2010 10:57:01 +0800

Hi all,

I've been working on a tool to print an NSView to a PDF file. I followed
Apple's documentation but couldn't get the auto-pagination work.
The resulting PDF file is always long and one-page.  Hope someone with
relevant experience could help me. My code is as follows:

MyCustomView *curView = [curDocument textView];

NSPrintInfo *sharedInfo = [NSPrintInfo sharedPrintInfo];
NSMutableDictionary *sharedDict = [sharedInfo dictionary];
NSMutableDictionary *prtInfoDict = [[NSMutableDictionary
alloc]initWithDictionary:sharedDict];
[prtInfoDict setObject:NSPrintSaveJob forKey:NSPrintJobDisposition];

// Set up NSPrintInfo
NSPrintInfo *prtInfo = [[NSPrintInfo alloc] initWithDictionary:prtInfoDict];
[prtInfo setTopMargin:1];
[prtInfo setBottomMargin:1];
[prtInfo setLeftMargin:1];
[prtInfo setRightMargin:1];
[prtInfo setPaperSize:NSMakeSize(1144 / 150 * 72, 786 / 150 * 72)];
[prtInfo setVerticalPagination:NSAutoPagination];
[prtInfo setHorizontalPagination:NSAutoPagination];
[prtInfo setVerticallyCentered:NO];

// Initiate the Print Job
NSPrintOperation *printOp = [NSPrintOperation PDFOperationWithView:curView
insideRect:[curView bounds] toPath:@"/Users/peidaqi/Desktop/test.pdf"
printInfo:prtInfo];
[printOp setShowPanels:NO];
[printOp runOperation];

Thanks.

Cheers,
DairyKnight
_______________________________________________

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

  • Follow-Ups:
    • Re: NSPrintOperation Fails to Auto-Paginate?
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: #macdev/#iphonedev ban, in need of sympathy
  • Next by Date: Re: #macdev/#iphonedev ban, in need of sympathy
  • Previous by thread: [modeator] Re: #macdev/#iphonedev ban, in need of sympathy
  • Next by thread: Re: NSPrintOperation Fails to Auto-Paginate?
  • Index(es):
    • Date
    • Thread