Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Open a pdf file in browser

Open a pdf file in browser

Scheduled Pinned Locked Moved ASP.NET
tutorial
6 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NarVish
    wrote on last edited by
    #1

    Hi, I would like to open a pdf file in a web browser. I tried the below, but its not working. Please let me know how to open it.

    <object type="application/pdf" data="C:\Lalitha\Bloomberg\TablesProject\Copy.pdf" width="500" height="650" ></object>

    M 1 Reply Last reply
    0
    • N NarVish

      Hi, I would like to open a pdf file in a web browser. I tried the below, but its not working. Please let me know how to open it.

      <object type="application/pdf" data="C:\Lalitha\Bloomberg\TablesProject\Copy.pdf" width="500" height="650" ></object>

      M Offline
      M Offline
      Morgs Morgan
      wrote on last edited by
      #2

      You clients browser will decide whether or not to open the pdf file or offer a download functionality, but hey! here goes the answer:

      Download file

      Caution here! It's never a good idea (security large hole) to offer a full file path like you have done in the orginal post which is why i changed it in my solution. Happy coding, morgs

      N 1 Reply Last reply
      0
      • M Morgs Morgan

        You clients browser will decide whether or not to open the pdf file or offer a download functionality, but hey! here goes the answer:

        Download file

        Caution here! It's never a good idea (security large hole) to offer a full file path like you have done in the orginal post which is why i changed it in my solution. Happy coding, morgs

        N Offline
        N Offline
        NarVish
        wrote on last edited by
        #3

        Thanks for your reply, Morgs.. anchor tag showing only a link. I need to open the file in the web page itself. It should not open as a separate process..

        M 1 Reply Last reply
        0
        • N NarVish

          Thanks for your reply, Morgs.. anchor tag showing only a link. I need to open the file in the web page itself. It should not open as a separate process..

          M Offline
          M Offline
          Morgs Morgan
          wrote on last edited by
          #4

          Have you tried my solution? when you click the link, the browser will open the pdf file for you in the browser, if the browser does not know how to open your file, it will offer it for download. e.g. http://www.edb.utexas.edu/minliu/multimedia/CSS.pdf[^] I don't think you are going to find any other way around this, oh well you can always try something after one thing fails. Happy coding, Morgs

          N 1 Reply Last reply
          0
          • M Morgs Morgan

            Have you tried my solution? when you click the link, the browser will open the pdf file for you in the browser, if the browser does not know how to open your file, it will offer it for download. e.g. http://www.edb.utexas.edu/minliu/multimedia/CSS.pdf[^] I don't think you are going to find any other way around this, oh well you can always try something after one thing fails. Happy coding, Morgs

            N Offline
            N Offline
            NarVish
            wrote on last edited by
            #5

            Yes, the pdf file opened in a browser.. I agree with you. But I need it in some specific area as shown in the below link. http://www.cs.tut.fi/~jkorpela/html/iframe-pdf.html[^] When I tried the same using iframe tag, its not working. Its showing blank rectangle.

            <iframe src="C:\TablesProject\Copy.pdf" width="60%" style="height:10em" align="right">
            the document
            </iframe>

            B 1 Reply Last reply
            0
            • N NarVish

              Yes, the pdf file opened in a browser.. I agree with you. But I need it in some specific area as shown in the below link. http://www.cs.tut.fi/~jkorpela/html/iframe-pdf.html[^] When I tried the same using iframe tag, its not working. Its showing blank rectangle.

              <iframe src="C:\TablesProject\Copy.pdf" width="60%" style="height:10em" align="right">
              the document
              </iframe>

              B Offline
              B Offline
              Bernhard Hiller
              wrote on last edited by
              #6

              And when Acrobat Reader is configured to open as a stand alone application, you cannot do that.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups