Re: Using CALayer to display a PDF ?
site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=frameforge.com; s=hostingermail-a; t=1736102278; 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; bh=zJ1rB8a5gszLeDZ4nutcrHXj1joKxtG1e+Dt6QazX4M=; b=YE8Ggo5UvcN7gYtYt10DjDsWDxouMfXuz8Mnkbp9bDd5Q45G/KyhtstXBN9dMzrEZ+n0Z/ I0i2ZFZvKDCstr1H5tKXQPbLrMAWOwFb4MwSuiD+h0cbcO+z7SdS6GLXB1OSOcegNs1sH+ ccEHD8pMlC9Hm+MQjQYeajUqdbPaq7Xw80dl19Rj7DGjI0Sg5EegKCZLA3v71xYqOml5Gn WQpmwR+CkcI+gT1dhO8Pa7db8zNo7/7Lx/E/U1nBgd4jJYO6wdc8iupNXP28KuN7MbE14E Wuxc3wwiE25DWVH9W5oRdC74OVv/B+UVWACrYRousU4FKRt+4hbFvIB9GKqzAw== User-agent: Mozilla Thunderbird 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? _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com No, imageRepWithData: takes an NSData* parameter. It's just the contents of a PDF file.
participants (1)
-
James Walker via Cocoa-dev