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 6231093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:52:15+00:00 2026-05-24T09:52:15+00:00

I am developing an application which render a PDF file using CoreGraphics. I am

  • 0

I am developing an application which render a PDF file using CoreGraphics. I am displaying one page of the PDF at a time. In viewDidLoad I have the following code:

NSString *pdfFullPath = [[NSBundle mainBundle] pathForResource:@"catalogue" ofType:@"pdf"];
pdf = CGPDFDocumentCreateWithURL((__bridge CFURLRef)[NSURL fileURLWithPath:pdfFullPath]);

currentPage = [[_dataObject description] intValue];

[pdfView setImage:[self imageFromPDF:pdf withPageNumber:currentPage withScale:1.5]];

[_dataObject description] contains the current page number as a string.

Then I have this method which renders the PDF:

- (UIImage *)imageFromPDF:(CGPDFDocumentRef)_pdf withPageNumber:(NSUInteger)pageNumber withScale:(CGFloat)scale
{
    if(pageNumber > 0 && pageNumber <= CGPDFDocumentGetNumberOfPages(_pdf))
    {
        CGPDFPageRef pdfPage = CGPDFDocumentGetPage(_pdf, pageNumber);
        CGRect tmpRect = CGPDFPageGetBoxRect(pdfPage,kCGPDFMediaBox);
        CGRect rect = CGRectMake(tmpRect.origin.x, tmpRect.origin.y, tmpRect.size.width * scale, tmpRect.size.height * scale);
        UIGraphicsBeginImageContext(rect.size);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextTranslateCTM(context, 0, rect.size.height);
        CGContextScaleCTM(context, scale, -scale);
        CGContextDrawPDFPage(context, pdfPage);
        UIImage *pdfImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();

        return pdfImage;
    }

    return nil;
}

This seems to be a very slow process which locks the application entirely when imageFromPDF is being called and therefore I am looking for any way to optimize the process so it would be faster. Any ideas?

  • 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-24T09:52:15+00:00Added an answer on May 24, 2026 at 9:52 am

    What I ended up doing is to save each page of the PDF as an image on the iPad. The name of the images is the page number. When I flip to a new page I check if the file exists on the iPad. E.g. for page 4 I would check if “4.jpg” exists, if it does, I will show “4.jpg” else I will render the page and save it.

    This approach might use a lot of space on the iPad but for my use that’s not really an issue as the application will not end up on App Store but will be used for salesmen in a company.

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

Sidebar

Related Questions

I'm developing an application which currently have hundreds of objects created. Is it possible
I am developing a web application which has Chart Controls. I have developed a
I am developing an application using WPF to dynamically render content, including text and
I have heard that when developing application which uses a database you should do
I'm developing an application which requires two interfaces - one for mobile phones browsers
I am new to iPhone apps, I am developing one application which requires playing
i developing an application in which i found memory leak in following method how
i am developing application which point towards the particular location, i have calculate angle
Im developing one application which used SeekBar to control volume in MediaPlayer. The problem
i am developing an application which have eight advertisement boxes, the advertisement data with

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.