Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7927793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:29:56+00:00 2026-06-03T19:29:56+00:00

I’m trying to understand how CATiledLayer works when rendering a PDF page using CGContextDrawPDFPage()

  • 0

I’m trying to understand how CATiledLayer works when rendering a PDF page using CGContextDrawPDFPage().

My understanding was that drawLayer:inContext: is called once per tile and level of detail. Is that correct?

In the delegate of my tiled layer I call CGContextDrawPDFPage().
However I noticed (by putting logs into the drawLayer:inContext:) that drawLayer:inContext: gets called more often if I make the tile size of my tiled layer smaller.
This makes me wonder:

  • Is my PDF page drawn/rendered x times?
  • Or does CGContextDrawPDFPage() magically know what part of the page to draw?
  • Isn’t CATiledLayer a waste of resources when rendering a PDF page? What is its advantage?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:30:00+00:00Added an answer on June 3, 2026 at 7:30 pm

    I noticed that drawLayer:inContext: gets called more often if I make the tile size of my tiled layer smaller.

    Yes, of course. Assuming your layer’s size is the same, then if you tell it to use smaller tiles, it will need more tiles to cover the area.

    Is my PDF page drawn/rendered x times?

    Since you call CGContextDrawPDFPage() once per tile, then yes.

    However, that may not be a problem, because:

    Does CGContextDrawPDFPage() magically know what part of the page to draw?

    It might, but it doesn’t require any magic.

    Before CATiledLayer calls -drawLayer:inContext:, it sets the clip of the CGContext to include only the area of that tile. The PDF drawing code can get the clip bounds (via CGContextGetClipBoundingBox) and then choose to render only the content inside that rectangle.

    That said, there are two caveats:

    1. CGContextDrawPDFPage() is a black box, so it might not actually do that optimization. It seems obvious, but you’ll have to check the performance numbers to see if it really is happening or not.
    2. There is still considerable overhead in parsing and laying out the PDF content. You may still incur some of that cost on each call to CGContextDrawPDFPage — it really depends on how smart CG is, and whether it caches things internally or not.

    Isn’t CATiledLayer a waste of resources when rendering a PDF page? What is its advantage?

    The advantage of CATiledLayer is mostly in memory savings: the bitmaps that rendered content are stored in are very large, so it pays to render and keep only the content that is currently visible on screen. It also provides a mechanism for caching the areas that were recently visible or might become visible again soon, depending on how the user zooms and scrolls.

    The tradeoff is: you have to separate your drawing into separate calls for each tile, and you may have to render into tiles more often than you would have otherwise.

    Depending on how large your view is, how far you zoom in/out, how expensive your PDF is to draw, and what else is happening in your application, it might make sense to use CATiledLayer or it might not. It’s up to you to look at the performance numbers and decide.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.