Re: Using CALayer to display a PDF ?
Re: Using CALayer to display a PDF ?
- Subject: Re: Using CALayer to display a PDF ?
- From: James Walker via Cocoa-dev <email@hidden>
- Date: Sun, 05 Jan 2025 18:37:57 +0000 (UTC)
- Arc-authentication-results: i=1; rspamd-7c48484bf8-dpv22; auth=pass smtp.auth=hostingeremail smtp.mailfrom=email@hidden
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1736102280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zJ1rB8a5gszLeDZ4nutcrHXj1joKxtG1e+Dt6QazX4M=; b=GWryoKoIj1saezWgKU6TXnkp4Z+azSHvZRCLVhkj3D0gTN+U/TwJFkRY3zzwT9Q/MSi31W Z0GO7rPKTPHAgzvYsv+oWHGs2Jxuz7mD071bpyCxud8pkqVOnja3J5bt+4iYygjDD2KtM/ a2ItP5aTus/e6PyonsL6UyXrO/NK/g8aIy2p+1ebCsuPvtunyFK0xGYM8xUMafP/VuxYcB mNuDxn2wZeJV8qe0NfKZKBgwE9VY/UzRjDHpieN1mShQHaaa7OjEZdHZ1rdCnH71nrXeBE e1WBM9xDwtoLrvhBqdTQZcXaWfJ5L2ApnozDsz4aV7VXWhD6DltwNr5VEWKyeg==
- Arc-seal: i=1; s=arc-2022; d=mailchannels.net; t=1736102280; a=rsa-sha256; cv=none; b=F0NXoXygNl++SnC7i7NMpi5nLKnTUjtBJqTSLO1KBIpV3kGa1dHkSIU0wZGHXYur2OTvwz ziH4MvdTlOyXFmMPqMuiDNdGQdGCaqmEHwDMNv9l+Ov29Y1COXp2Xv1D/Wsn2A6Cw51mXg g2IK6XX7jFOyKHJXa+dhREXitPZTwSOxHH4j5+5sMw9I9iHp9xtO8/y+Oa24AbasL7tcwK gjWPmmu673kzPhro4vok1vWZQBWMjZrrkXwmK/+0Kn5SshwBOgV8bkrsPL/NRlBCxcCB4V XvbyUGrifxFUBLIqrygTmG6xvYXv8L8XLpVpjZUmChBkY3WZPTYMWaWJ8Gnm6A==
On 1/5/25 9:47 AM, Gabriel Zachmann via Cocoa-dev wrote:
Thanks a lot to both of you!
I'm sure there's more than one way to do it, but one way is to create an
NSPDFImageRep. You can then get a CGImageRef from that, or on macOS,
create an NSImage and set that as the layer contents.
I forget to mention that I am developing an app for macOS. Sorry!
So, being totally new to handling PDFs in my code, I would use something like
PDFDocument *pdfDoc = [[PDFDocument alloc] initWithURL:url];
then something like
imagePDFrep = [NSPDFImageRep imageRepWithData: pdfDoc];
then something like
imageOfFirstPage = [ [NSImage init] addRepresentation: imagePDFrep];
?
Is that the general gist of it?
No, imageRepWithData: takes an NSData* parameter. It's just the
contents of a PDF file.
_______________________________________________
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