That’s not what CALayer does. It would help to think of how to display a PNG or JPEG image first - noting that a PDF file is more complicated than that.
You’d use a UIImage. Think of it like this. A UIImage is the internal structure of an image or and image document. Think of it as a Photoshop file. That will have a visual display through a UIImageView which is a REPRESENTATION of the image ready to display on the screen, independent of the type of image it is (PNG/JPG, etc) Think of a CALayer as a “Core Animation” Layer or as an organizational layer within a photoshop file. That is how you think about displaying an image in the supported formats. OK? That’s the easy part. To display a PDF, it’s different. PDF files can have more than one page. Do you only wish to display the first page oooooh what? Here is one way of doing it. 1. Define the PDF file location as a URL 2. Load the file into memory . 3. Create a renderer (UIGraphicsImageRenderer) of the proper dimensions for the PDF. 4. Looping through each page of the PDF as the image context (CGContext) you 1. Tlop a background color in it. 2. Use translateBy to set the proper X and Y coordinate system 3. Set the scale of the context using scaleBy. 4. Render the PDF with drawPDFPage and the page number. 5. Return the image. 6. Display the image in a UIImageView This should help. https://www.hackingwithswift.com/example-code/core-graphics/how-to-render-a-pdf-to-an-image And sorry if there are any inaccuracies in my overview. No coffee today. Cheers! Hope this helps. Alex Zavatone > On Jan 4, 2025, at 6:30 AM, Gabriel Zachmann via Cocoa-dev > <cocoa-dev@lists.apple.com> wrote: > > I am using CALayer's to display images with some animations. > > Now, I would like to display PDFs (just the first page). > > Could some kind soul please explain to me how to load PDFs? > > And would I then just add such a PDF object as layer.contents ? > > All hints will be highly appreciated. > > Best regards, Gabriel > > > _______________________________________________ > > 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/zav%40mac.com > > This email sent to z...@mac.com _______________________________________________ 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com