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

  • SEARCH
  • Home
  • 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 3981066
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:21:57+00:00 2026-05-20T05:21:57+00:00

I have to develop an application which takes PDF as input, that PDF document

  • 0

I have to develop an application which takes PDF as input, that PDF document has 200 pages. I am using UIScrollView to swipe left and right. On each swipe I am drawing a PDF document. The code is as under :

- (id)initWithFrame:(CGRect)frame content:(NSString *)aPDFPage type:(NSString *)contentType
{
    if ((self = [super initWithFrame:frame])) 
    {
        // Initialization code
        self.backgroundColor = [UIColor whiteColor];
        pageRef = [[NSString alloc]initWithString:aPDFPage];
        pageTypeRef = [[NSString alloc]initWithString:contentType];
    }
    return self;
}


- (void)drawRect:(CGRect)rect 
{
    ctx = UIGraphicsGetCurrentContext();
    [self drawPDF];
}

-(void)drawPDF
{
    NSString *pathToPdfDoc = [[NSBundle mainBundle] pathForResource:self.pageRef ofType:self.pageTypeRef];
    NSURL *pdfUrl = [NSURL fileURLWithPath:pathToPdfDoc];

    document = CGPDFDocumentCreateWithURL((CFURLRef)pdfUrl);

    page = CGPDFDocumentGetPage(document, 1);
    CGContextTranslateCTM(ctx, 0.0, [self bounds].size.height);
    CGContextScaleCTM(ctx, 1.0, -1.0);

    CGAffineTransform transform = aspectFit(CGPDFPageGetBoxRect(page, kCGPDFTrimBox),CGContextGetClipBoundingBox(ctx));

    CGContextConcatCTM(ctx, transform);

    CGContextSetInterpolationQuality(ctx, kCGInterpolationLow); 
    CGContextSetRenderingIntent(ctx, kCGRenderingIntentDefault);

    CGContextDrawPDFPage(ctx, page);
    CGPDFDocumentRelease(document);
}


-(void)dealloc 
{
    [pageRef release];
    [pageTypeRef release];
    [super dealloc];
}

This works fine. But if I swipe very fast, more often subsequent pages does not load instantly. Screen becomes white.

How to solve this, please guide.

Regards,
Ranjan

  • 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-05-20T05:21:57+00:00Added an answer on May 20, 2026 at 5:21 am

    one of the obvious issues is that drawRect may be called regularly, and may only request that you draw some of the view’s rect.

    in your implementation, you:

    • read the pdf from disk. this takes a lot of time, especially since drawRect may be called at a high frequency.

    • read the pdf. this takes some time — it can be avoided from occurring during drawRect.

    • draw one page. draw only what you need to draw, where possible.

    • dispose of the pdf. you should hold on to the pdf document while the pdf view is visible, rather than reading it from disk every time you need to draw.

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

Sidebar

Related Questions

I have to develop an application using C#.net that has to be run once
I am using asp.net MVC to develop an application that will have ajax interactions.
I have to develop an application which parses a log file and sends specific
I am using VS2008 to develop a WinForms 2.0 application. I have read about
I have to develop a application that will communicate with some external device.I would
When i am using net beans to develop one standalone swing application which is
Say suppose 10 developers have taken 6 months to develop some application. As a
I have a quick little application and wanted to give a try to develop
I develop a variety of applications and have 3-4 miscellaneous libraries that I reuse
I have to develop the application based on a spinner. I have taken the

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.