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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:34:40+00:00 2026-06-12T01:34:40+00:00

I have a muti page pdf document stored on local storage. I want to

  • 0

I have a muti page pdf document stored on local storage. I want to extract any page out of that pdf doc and convert it into NSData to attach it with ‘MFMailComposeViewController’. With the following lines of code, I can easily retrive the required page…

CGPDFDocumentRef pdfDoc=CGPDFDocumentCreateWithURL(pdfURL);
CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfDoc, pageNumber);

But I am unable to find a way to convert pdfPage into NSData so that I can attach it with mail.

NOTE: The requirement is to attach page in PDF format, so please DON’T suggest converting PDF into PNG or JPEG.

  • 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-12T01:34:41+00:00Added an answer on June 12, 2026 at 1:34 am

    CGPDF is primarily for drawing from and to PDF, not for converting PDF data. Therefore, if you want to extract a page, you’ll have to draw it. Use for example:

    // input
    CGDataProviderRef provider = CGDataProviderCreateWithCFData((__bridge CFDataRef)inputData);
    CGPDFDocumentRef document = CGPDFDocumentCreateWithProvider(provider);
    CGPDFPageRef page = CGPDFDocumentGetPage(document, pageIndex);
    CGRect mediaBox = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
    // output
    CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData((__bridge CFMutableDataRef)outputData);
    CGContextRef context = CGPDFContextCreate(consumer, &mediaBox, NULL);
    // draw
    CGContextBeginPage(context, &mediaBox);
    CGContextDrawPDFPage(context, page);
    CGContextEndPage(context);
    // cleanup
    CGDataProviderRelease(provider);
    CGPDFDocumentRelease(document);
    CGDataConsumerRelease(consumer);
    CGContextRelease(context);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have you any idea how to find out if spell check suggestions dialog is
I have a muti-module maven project, and I created a new module that depends
Have a simple form that has a PictureBox in one location. I want to
Have done quite a bit of searching for a guide (of any substance) for
have 2 questions : A computer with 32-bit address uses 2-level page table (9
Assume I have a muti-level hash: $class->{'key1'}->{'key2'}->{$key3}->{'string'}->{$key5}, where $class->{'key1'}->{'key2'}->{$key3}->{'string'}->{$key5} equals to some integer number.
Have a bunch of WCF REST services hosted on Azure that access a SQL
Have finally got a responsive site working (of a fashion). What I want to
have Googled the cr*p out of this one so apologies if the answer is
Have a look at one of my websites: moskah.com The problem is that it

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.