• 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
Re: Printing Problem (Was: Re: Generating PDFs....)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Printing Problem (Was: Re: Generating PDFs....)


  • Subject: Re: Printing Problem (Was: Re: Generating PDFs....)
  • From: Scott Thompson <email@hidden>
  • Date: Thu, 30 Jun 2005 00:21:26 -0500


On Jun 29, 2005, at 7:13 PM, Dave DeLong wrote:

Hi everyone,

Thanks for the tips on how to make PDFs. I tried a couple different ways (drawing directly into an NSImage, typing into a hidden NSTextView and then getting PDF data), but I didn't have much success with either.

A friend of mine then pointed out I could try printing to a file, so we worked up some code that takes the NSTextView and saves it to a file (resulting in the wanted PDF). There's one glitch: every other page in the PDF is blank. I end up with a 66 page PDF instead of a 33 page PDF.

Here's my printing code (textView is my NSTextView containing all of the properly formatted text):

NSString * save = [@"~/Desktop/Preview.pdf" stringByExpandingTildeInPath];

    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];
[printInfoDict setObject:save forKey:NSPrintSavePath];
printInfo = [[NSPrintInfo alloc] initWithDictionary: printInfoDict];
[printInfo setHorizontalPagination: NSAutoPagination];
[printInfo setVerticalPagination: NSAutoPagination];
[printInfo setVerticallyCentered:NO];
printOp = [NSPrintOperation printOperationWithView:textView printInfo:printInfo];
[printOp setShowPanels:NO];
[printOp runOperation];


Any ideas as to what I'm missing?

If I had to guess, I would say that your text view is wider than one printed page. The computer prints the first page showing the left side of the text view, and then the next page is some sliver of your text view off to the right side.


As an experiment, try cutting the width of your text view in half and see if you get something close to what you expect. More likely than not, you're going to want to ask the printer for the width of the page and use that to set the width of your text view.

Scott

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Generating PDFs.... (From: Dave DeLong <email@hidden>)
 >Re: Generating PDFs.... (From: Scott Thompson <email@hidden>)
 >Re: Generating PDFs.... (From: Nicko van Someren <email@hidden>)
 >Printing Problem (Was: Re: Generating PDFs....) (From: Dave DeLong <email@hidden>)

  • Prev by Date: Re: WebKit & MiniBrowser: Document Tail Wagging the Dog
  • Next by Date: Re: subclass of NSSlider won't call action method
  • Previous by thread: Printing Problem (Was: Re: Generating PDFs....)
  • Next by thread: Re: Generating PDFs....
  • Index(es):
    • Date
    • Thread