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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:37:26+00:00 2026-05-14T07:37:26+00:00

Is it possible to open a PDF from a website in Safari in order

  • 0

Is it possible to open a PDF from a website in Safari in order to save it to local disk?

  • 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-14T07:37:27+00:00Added an answer on May 14, 2026 at 7:37 am

    You can use the NSURL class to download the pdf file to your documents directory, bypassing the need to open it in Safari (and subsequently terminating your own app).

    UIWebView makes it nice and easy to display external PDFs as well as local files (just point the correct filepath at it), so you could even download the PDF to your documents folder and then display it from the local cache at a later date.

    Added some sample code below

    For a simpler example, you might find this is acceptable for your app; This will download the file to your documents folder but uses a blocking function (initWithContentsOfURL), so you may run into problems with large files/slow connections:

    (This code should be all you need, but you will probably want to create a function to handle this step/handle memory/check for errors etc)

    //Grab the file from the URL
    
    NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.website.com/doc1.pdf"]];
    
    // Put the data into a file in your Documents folder
    
    NSString *docFolder = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
    
    NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"doc1.pdf"];
    
    [pdfData writeToFile:filePath atomically:YES];
    

    To give you a basic sample to build from, the following code is enough to display a PDF file inside from your Documents folder in a webview:

    -(void)viewDidLoad
    {
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
      NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@"doc.pdf"];
    
    // ...
    
      webView.scalesPageToFit = YES;
      webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    
      [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:pdfPath isDirectory:NO]]];
    
    }
    

    Should you want to display the PDF directly from the website (rather than a local file) then you can have pdfPath contain the full URL to the file instead.

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

Sidebar

Related Questions

I know its possible to open an app from mobile safari using custom URL
Is it possible to open a pdf file from an app itself into iBooks.
Possible Duplicate: Generation PDF from HTML (component for .NET) Has anyone used any open
Is it possible that when you have a webpage, when you open the PDF,
Possible Duplicate: Open child browser window from child window I have a list of
Possible Duplicate: Open/handle Word documents like SharePoint I´ve developed one website where it is
I'm trying to simply open a PDF from my application when a certain button
Hi is it possible to open a file in an external program from within
Is it possible to open a particular PDF file in a 3rd party PDF
Is it possible to open or create a PDF file in a Java desktop

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.