locked
pdf file not opening on android phone RRS feed

  • Question

  • User351619809 posted

    I am trying to show a pdf file embedded on my web page as soon as the web page loads. This is what I am doing to show the pdf file on my aspx page:

    <asp:Literal  ID="ltEmbed" runat="server"></asp:Literal>
    

    and in my .cs page

    string embed = "<object class=\"ss-pdfjs-viewer\" data=\"{0}\" type=\"application/pdf\"    allowfullscreen webkitallowfullscreen>";
                embed += "</object>";
                string fileName = HttpContext.Current.Session["RequestType"] + "_" + HttpContext.Current.Session["MailID"].ToString() + ".pdf";
                ltEmbed.Text = string.Format(embed, ResolveUrl("~/Documents/" + fileName));
    

    everything works fine. I can open this pdf file in my web application, iphone, but not in android phone.

    I am not sure why it is not working in android and all other places. any help with this will be appreciated.

    Thursday, March 4, 2021 5:33 PM

All replies

  • User1535942433 posted

    Hi anjaliagarwal5@yahoo.com,

    According to your description,as far as I think,there are threes reasons for not opening the pdf file:

    1.The PDF document is corrupted 

    2.The PDF document is encrypted - Encryption or password is required before you can open it.

    3.The Android phone does not support file formats.Chrome is the most popular browser in Android tablets & smartphones.

    You could check if you have these problems. Or you could try in other Android phones.

    Best regards,

    Yijing Sun

    Friday, March 5, 2021 7:27 AM
  • User351619809 posted

    I can open the same pdf document on iphones so doesnt seem like pdf document is corrupted. Pdf is not encrypted either. I am trying to pen the pdf document in chrome browser.

    Saturday, March 6, 2021 2:51 AM
  • User1535942433 posted

    Hi anjaliagarwal5@yahoo.com,

    As far as I think,pdf file could be opened in Chrome browser on android phone. Do you have used webview?

    There are two ways:

    1.Attach a download listener to the web view and change the url.

    2.Explore is using Mozilla's pdf.js, which is a pdf reader built entirely in javascript that works just about everywhere.It fits small files.

    More details,you could refer to below articles:

    https://stackoverflow.com/questions/4947591/open-a-pdf-file-inside-a-webview/4947993#4947993

    https://stackoverflow.com/questions/13140197/viewing-pdf-in-android-chrome

    Best regards,

    Yijing Sun

    Monday, March 8, 2021 9:12 AM