On Feb 27, 2008, at 10:32 AM, Florian Soenens wrote:

i don't understand why this simple code is not working:

PDFDocument *pdfDocument = [[PDFDocument alloc] initWithURL:inputurl];
PDFPage *currentPage = [pdfDocument pageAtIndex:i];
NSImage *image = [[NSImage alloc] initWithData:[currentPage dataRepresentation]];
NSData *tiffRep = [image TIFFRepresentation];
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithData:tiffRep]; NSData *bitmapData = [rep representationUsingType:NSJPEGFileType properties:NULL];
[bitmapData writeToURL:outurl atomically:YES];

You do not explain which part is not working. The code that should produce the bitmapData looks allright, so my guess is that either the document is not loaded in the first line because of a problem with the input URL, or i is an invalid index in line 2, or the output URL in the last line is invalid.

Failing all that there are some other more esoteric reasons why e.g your output may simply be empty. That can happen when PDFKit has trouble with the source document. Are you running this on Tiger or on Leopard? Does the source PDF display correctly in Preview?

-António

----------------------------------------------------
Energy is like a muscle,
it grows stronger through being used.
----------------------------------------------------


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to