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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:54:53+00:00 2026-06-13T23:54:53+00:00

I have a URL where I can download a PDF, but I cannot use

  • 0

I have a URL where I can download a PDF, but I cannot use something like:

[myWebView loadRequest:urlRequest];

since this link will send out some challenges…

However, I managed to get the PDF raw data NSURLConnection(to be exact, I can get the data in the delegate method:

(void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)data).

And then I want to know, how I can show this PDF? Does anyone has any idea? Thanks a lot!

  • 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-13T23:54:54+00:00Added an answer on June 13, 2026 at 11:54 pm

    I have made my own, pdf download class, but this is the bits you’ll need. In the .h of the class. Declare:

    NSMutableData *_data;
    NSString *pdfPath;
    

    Also subclass the delegates for the connection

    <NSURLConnectionDataDelegate, NSURLConnectionDelegate>
    

    Then in the implementation file, in - viewDidLoad:

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    pdfPath = [documentsDirectory stringByAppendingPathComponent:@"pdfName.pdf"];
    

    The connection:didReceiveData: method:

    - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
        if(!_data) _data = [[NSMutableData data]init];
        [_data appendData:data];
        progressView.progress =  ((float) [_data length] / (float) downloadSize);
    }
    

    The connectionDidFinishLoading: method:

    - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    
            unsigned char byteBuffer[[_data length]];
            [_data getBytes:byteBuffer];
            [_data writeToFile:pdfPath atomically:YES];
    
    }
    

    So when it receives data, it builds up the _data, then when it finishes it writes it to the path. Make sure the connection delegate is set to self.

    After that, you can open the path to the PDF as you did before.

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

Sidebar

Related Questions

I have a url of a website. It looks something like this: http://www.example.com/downloads/file/4789/download ?
In my app, i have to connect with a url and download a pdf
I have been looking at this since last night and just can't figure out
I've got a controller action that returns a FileResult like this return this.File(file.pdf, application/pdf);
I have a script that download's files from a server, all works nice. But
I have a file, call it secret.pdf, that I offer for download. However, I
I'm trying to do something that seems like it should be easy but I'm
I have a pdf and want to offer the user a simple Download link.
I have a code which force download a pdf file. Code below $file_name =
how can I upload file from url directly without download it and upload 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.