• 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: NSImage to PDFPage in Tiger?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage to PDFPage in Tiger?


  • Subject: Re: NSImage to PDFPage in Tiger?
  • From: Jerry LeVan <email@hidden>
  • Date: Wed, 2 Jan 2008 16:40:19 -0500


On Jan 2, 2008, at 4:25 PM, John Calhoun wrote:

On Dec 21, 2007, at 11:56 AM, Jerry LeVan wrote:
The only thing holding back the Universal version of my app from being on a par
with the Leopard version is a replacement for the PDFPage method - initWithImage.

There is sample code about (PDFCalendar I think) that shows you a way to do this using a PDFPage subclass. The PDFPage's draw and bounds methods are overridden, The bounds method will return the image bounds and the draw method displays the image. This "PDFPage" object can be added to a PDFDocument.


john calhoun—

Hi John,

Someone suggested using dataWithPDFInsideRect... that seems to work
//Tiger code
NSImageView * pdfView;
NSData *pdfData;
NSMutableArray * tmpPage = [NSMutableArray array];
int i;
for(i=0;i< cnt;i++) {
theImage =[ [NSImage alloc]
initWithContentsOfFile: [fileNameList objectAtIndex:i]];
pdfView = [[NSImageView alloc]
initWithFrame:NSMakeRect(0,0,
[theImage size].width,
[theImage size].height)];


[pdfView setImage:theImage];
pdfData = [pdfView dataWithPDFInsideRect:[pdfView bounds]];
[tmpPage addObject: [[[PDFDocument alloc] initWithData: pdfData] autorelease]];
[myBook insertPage:[ [tmpPage objectAtIndex:i] pageAtIndex:0] atIndex:i];
[pdfView release];
[theImage release];
[filesLeft setIntValue: --fcnt];
[filesLeft displayIfNeeded];
}


For reasons that are not clear to me I had to keep the "pages" until I was
finished with the PDF document in Tiger. For Leopard this was not necessary...
// Leopard Code
for (i=0; i< cnt ; i++) {
nextImage = [[NSImage alloc] initWithContentsOfFile:(NSString*) [fileNameList objectAtIndex:i]];
nextPDFPage = [[PDFPage alloc] initWithImage:nextImage];
[myBook insertPage: nextPDFPage atIndex: i];
[nextImage release];
[nextPDFPage release];
[filesLeft setIntValue: --fcnt];
[filesLeft displayIfNeeded];
}


Jerry_______________________________________________

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: NSImage to PDFPage in Tiger?
      • From: John Calhoun <email@hidden>
References: 
 >Re: NSImage to PDFPage in Tiger? (From: John Calhoun <email@hidden>)

  • Prev by Date: Re: Status item using custom view not responding to clicks (Follow up)
  • Next by Date: Re: Localization Issue
  • Previous by thread: Re: NSImage to PDFPage in Tiger?
  • Next by thread: Re: NSImage to PDFPage in Tiger?
  • Index(es):
    • Date
    • Thread