• 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: Mon, 14 Jan 2008 18:59:19 -0500


On Jan 14, 2008, at 6:20 PM, John Calhoun wrote:


On Jan 9, 2008, at 10:21 AM, Jerry LeVan wrote:
The only Tiger system that I have available is on a PPC G4, the suggested fix did not work
there... ( but did no harm on my Leopard box, except for an undefined value at compile time)

I'm afraid I lost the original problem. Can you describe the bug?

John Calhoun

Hi John,

The following works on my wife's PPC running 10.4.<latestVersion>
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];
}


Here tmpPage is an array that holds each page of the created PDF Document....
If I replace tmpPage by
PDFDocument *tmpPage;
so the the same tmpPage is used to add the next object to the myBook PDFDocument then
as soon as the second page is added myBook becomes corrupted (tmpPage is released each pass
through the loop).


You suggested:


A workaround for Tiger might be to call the private -[setDocument:] call yourself after adding the page to a document. Something like:


	[someDocument insertPage: originalPage atIndex: i];
	[[someDocument pageAtIndex: i] setDocument: someDocument];

This caused a crash on the PPC...

_______________________________________________

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


References: 
 >Re: NSImage to PDFPage in Tiger? (From: John Calhoun <email@hidden>)
 >Re: NSImage to PDFPage in Tiger? (From: Jerry LeVan <email@hidden>)
 >Re: NSImage to PDFPage in Tiger? (From: John Calhoun <email@hidden>)
 >Re: NSImage to PDFPage in Tiger? (From: Uli Kusterer <email@hidden>)
 >Re: NSImage to PDFPage in Tiger? (From: Jerry LeVan <email@hidden>)
 >Re: NSImage to PDFPage in Tiger? (From: John Calhoun <email@hidden>)

  • Prev by Date: Re: Advice re: "Rough-Cuts" version of "Cocoa Design Patterns"
  • Next by Date: Re: Move window by dragging button
  • Previous by thread: Re: NSImage to PDFPage in Tiger?
  • Next by thread: To read and write in a binary file
  • Index(es):
    • Date
    • Thread