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=simple/simple; d=uni-bremen.de; s=2019; t=1736099291; i=@uni-bremen.de; bh=v6PAUFxF2MD1OlG4SB0ep5pfo9PaOPlMfMEoAhkjHYk=; h=From:Subject:Date:References:To:In-Reply-To; b=IlmGKfILkayDQnSC+H8wdfq9jmYcPZsD2EX+THAShsck6OOm85ZOH+PHHjDRAI5+5 mW7Ltp+STPdL4AWE39+6NQuRtPH9XUUj8HduV7lJJKp2RhW+PUJv41KzlOkSeReR1Q 7fguQP9cx+6N19/JM8F8UdkDOSq4fVsh1S+2ja4wZPplZptmv3Vol5qgAzxA9O554H 3KJmORDM8QsJX0T7lJPJc2gTjxj3qbNUMSsGo4wkMXWlZS8v3TQ89YaS1JEhN0+qaQ 5/uVbQVE8WB4Ut7GzBy0iqph0hlceWpEraUTnkaEXKt3zt8MdEeyc145XEsCIML/aW u+tPLnE4EkATw== 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? Best, G. _______________________________________________ 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 smime.p7s
participants (1)
-
Gabriel Zachmann via Cocoa-dev