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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:51:51+00:00 2026-06-18T03:51:51+00:00

I am using the code below to download a pdf file from a website

  • 0

I am using the code below to download a pdf file from a website and subsequently to display it in a uiwebview

NSString *url = [NSString stringWithString:[[[popOverContent currentValues]     objectAtIndex:0]objectForKey:@"Web"]];

    // Determile cache file path
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,      NSUserDomainMask, YES);
    NSString *filePath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0],@"index.pdf"];

    // Download and write to file
    NSURL *url2 = [NSURL URLWithString:url];
    NSData *urlData = [NSData dataWithContentsOfURL:url2];
    [urlData writeToFile:filePath atomically:YES];

    fileToAtatch = urlData;

    // Load file in UIWebView
    [self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];

all works as expected at this point but later when i use the following code to atatch the pdf file to an email using mfmailcomposer i get problems.

-(IBAction)EmailPressed:(id)sender
{
if ([MFMailComposeViewController canSendMail]) {

    MFMailComposeViewController *viewController = [[MFMailComposeViewController alloc] init];
    viewController.mailComposeDelegate = self;
    NSString *query = @"please find atatched the requested data sheet";
    [viewController setSubject:[popOverContent selectedSize]];
    [viewController setMessageBody:query isHTML:NO];
    [viewController addAttachmentData:fileToAtatch mimeType:@"application/pdf" fileName:[popOverContent selectedSize]];
    [self presentModalViewController:viewController animated:YES];

}

}

this code works exactly as expected and the multi page pdf attaches as expected.

if i test the app on iPad with ios 5.0.1 sending the email to myself, when i click on the icon for the pdf in the email, the pdf doesn’t open, and the preview just sits there with a uiprogress indicator spinning.
however if i test the app in the same way on an ipad2 with ios 6.0.1 the pdf file opens with no problems.
it also works on iphone 5 and also on mac with mountain lion.

so whats happening?
can anyone tell me whats wrong with my code and implementation to give me this strange behaviour on ipad 1 but not on ipad 2 etc.

please advise

thanks

  • 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-18T03:51:52+00:00Added an answer on June 18, 2026 at 3:51 am

    I finally figure this out and solved the problem by changing my code as follows

             fileName = [selectedSizeToUse stringByAppendingString:@".pdf"];
             [mailController setSubject:selectedSizeToUse];
             [mailController addAttachmentData:fileToAtatch mimeType:@"application/pdf" fileName:fileName];
    

    seems that for ios5 implementations pdf files need the .pdf extension to be recognised in the preview application, while in iOS 6 implementations the preview app was clever enough to display the pdf without the .pdf extension.

    hope this helps somebody else that got stuck

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

Sidebar

Related Questions

In Node.js, I'm using the code below to download the file from the server.
I am using the code below to download an Excel file. Once the Response.End()
I am using the code below to download multiple attachments from a TFS server:
I am using jsch to download files from server, my code below. public static
I'm using the code below to download this XML file : private async static
Using the code below (from a console app I've cobbled together), I add seven
I have tried using the code below but it only display results in Chrome
Can I use the PHP code below if the PDF file is not on
Using the code below each image download) file_get_contents() ) takes on average 8-15 seconds.....
What I am trying to do I am using the code below to download

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.