How to display a pdf file using code?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jenny

    #1

    How to display a pdf file using code?

    Hi,

    I want to use a button to display a pdf file. I have Windows 2000
    server, IE 6 and Acrobat 7 with plug-in. I can use <a> link to display
    it.

    I search this group for js code but they don't work. I tried this
    code:

    <form><input type="button" value="View PDF" onclick="window .location =
    'c:\Barcode1234 .pdf';">
    <input type="button" value="View"
    onclick="window .open('c:\Barco de1234.pdf')">
    </form>

    The first button displays "The page cannot be displayed...".
    The 2nd button displays new window displaying the drives on the PC,
    such as A:, C: and D:.

    Why does <a> works but not the code? Could you try the code and fix
    it? May be I need to provide the file type but do not know the syntax.
    Thanks a lot

    Jenny

  • Martin Honnen

    #2
    Re: How to display a pdf file using code?



    Jenny wrote:

    [color=blue]
    > I want to use a button to display a pdf file.[/color]

    Why can't you use a normal HTML link (and style that with CSS as a
    button if needed)?
    [color=blue]
    > I search this group for js code but they don't work. I tried this
    > code:
    >
    > <input type="button" value="View PDF" onclick="window .location =
    > 'c:\Barcode1234 .pdf';">[/color]

    Use a proper file URL e.g.
    <input type="button"
    onclick="window .location = 'file:///C:/Barcode1234.pdf ';"
    ...>
    [color=blue]
    > <input type="button" value="View"
    > onclick="window .open('c:\Barco de1234.pdf')">[/color]

    Same here
    onclick="window .open('file:///C:/Barcode1234.pdf ');"

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • Richard

      #3
      Re: How to display a pdf file using code?

      On 7 Jan 2005 11:33:51 -0800 Jenny wrote:
      [color=blue]
      > Hi,[/color]
      [color=blue]
      > I want to use a button to display a pdf file. I have Windows 2000
      > server, IE 6 and Acrobat 7 with plug-in. I can use <a> link to display
      > it.[/color]
      [color=blue]
      > I search this group for js code but they don't work. I tried this
      > code:[/color]

      I'm no expert with the coding, but I do not believe what you want to do is
      possible.
      As the "Adobe reader" has to be installed on the client's machine to work.
      It may be possible though, to have it open up from the server, in which case
      you'd need the reader installed on the server.
      For that, I would suggest you contact your host for assistance.


      Comment

      • Stephen Chalmers

        #4
        Re: How to display a pdf file using code?


        Jenny <jenny_jones_79 @hotmail.com> wrote in message
        news:1105126431 .529378.138000@ f14g2000cwb.goo glegroups.com.. .[color=blue]
        > Hi,
        >
        > I want to use a button to display a pdf file. I have Windows 2000
        > server, IE 6 and Acrobat 7 with plug-in. I can use <a> link to display
        > it.
        >
        > I search this group for js code but they don't work. I tried this
        > code:
        >
        > <form><input type="button" value="View PDF" onclick="window .location =
        > 'c:\Barcode1234 .pdf';">
        > <input type="button" value="View"
        > onclick="window .open('c:\Barco de1234.pdf')">
        > </form>
        >[/color]

        A single backslash is interpreted as the start of an escape sequence.
        Use a forward slash: 'c:/Barcode1234.pdf '
        or escape the backslash: 'c:\\Barcode123 4.pdf'
        --
        S.C.


        Comment

        Working...