0

I am using CGContextDrawPDFPage class to render PDF in my app without any trouble. But, the amount of time taken to load the book is a bit more and the time taken to render the page is proportional to the number of pages in the PDF.

In my case, the PDF can contain anywhere between 500 to 1000 pages. Due to this, the loading time of my PDF is getting increased. It is almost taking 10 seconds to render the first page which is really bad from a user experience aspect. And this time is being taken only during the loading of the book for the first time. In my opinion the delay is due to the fact that i am trying to read the entire PDF at once.

Is there a way in which i can read the PDF part by part so that the initial time to render the PDF is faster.

Thanks.

A for Alpha
  • 2,904
  • 8
  • 42
  • 76
  • Thanks for the vote down but it makes sense when this come with a bit of explanation or comments... This might help me to improve my question – A for Alpha Aug 19 '11 at 10:55
  • No, it doesn't make enough sense. CGPDFDocumentRef is data and does not render. CGContextDrawPDFPage renders. – David Dunham Aug 19 '11 at 17:35

2 Answers2

1

Have you run Instruments to see where the time is spent?

David Dunham
  • 8,139
  • 3
  • 28
  • 41
  • No david...but like i mentioned in my question, i think the size of the PDF is causing some trouble here... The time taken to render the PDF is directly proportional to its size.. – A for Alpha Aug 22 '11 at 10:47
  • It'll take you like 5 minutes to run Instruments. It may well point to something you can't control, but it's often very insightful. – David Dunham Aug 22 '11 at 20:48
1

I suggest you use heavy pre-caching to solve the problem. In my experience, analyzing the PDF (for aspect ratio stuff, annotation, etc) takes some time. Drawing is slow too.

I solved this with pre-generating images on the fly, and showing them whenever possible. Of course this is tricky too, e.g. don't ever try to render on and off screen at the same time, memory usage while drawing a complex pdf is off-scale and performing two operations at the same time may just crash your app.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
steipete
  • 7,581
  • 5
  • 47
  • 81
  • 1
    i have seen your link dude.. itz nothing less than awesome... We are discussing this issue and will let u know abt it soon... :) – A for Alpha Dec 27 '11 at 14:10