Results 1 to 14 of 14

Thread: PDF Download link

  1. #1

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    PDF Download link

    Hi,
    I want to create a simple link (pdf image and text) from which the user can simply download a pdf document.
    I store the whole link html string in a resource file, as it depends on what language the user are using.
    Seems that if you say a href ='mydoc.pdf', then the document are opened in the same page, just a bunch of garbage....
    I want the dialog to come up...normal way
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  2. #2
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Re: PDF Download link

    what happens if you use href='file:\\path\mydoc.pdf' ?

    In the unlikely event that I answer your question correctly, please Rate my post

    Using Visual Studio 2005 Professional

  3. #3

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Re: PDF Download link

    Code:
    <a href='file:\\CASM_sample_en.pdf'>test</a>
    say page cannot be found.
    Code:
    <a href='CASM_sample_en.pdf'>test</a>
    open the file in the same window, but not pdf, just garbage (I assume IE read into the file)
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  4. #4
    Hyperactive Member Datacide's Avatar
    Join Date
    Jun 2005
    Posts
    309

    Re: PDF Download link

    I think your browser just isnt set up right, try downloading a pdf from another site.
    PHP in your FACE!

  5. #5

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Re: PDF Download link

    Thanks for the advice.
    However, I have to make sure anyone, using any browser, will be able to download this documents (sample issues, subscribtion forms, etc) from my website.
    I did got across some code the other day, but did not look into it...will look into it later, as I got myself caught up in some stored procedures right now.
    thanks again!
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  6. #6
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: PDF Download link

    If you upload the pdf file to a location on your site you will reference it just like any other page. If they have Acrobat then it will open in the browser. If they dont then it will present the save to dialog so they can download the file.

    For ex: http://www.vbforums/downloads/myfile.pdf

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Re: PDF Download link

    that's what I thought too...believe me, it dont
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  8. #8
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: PDF Download link

    Hmm, I havent linked to a pdf in a while but thats how I have always done it with Acrobat 5 and 6.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: PDF Download link

    BTW, it's file:///, not file:\\.

  10. #10

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Re: PDF Download link

    yeah...me too long ago when i played around with html, before going to good ol vb6.

    apparantly one have to do something like this. I will post the solution once I got to that (got busy with some other stuff...how's that for holiday?)

    Code:
    Private Sub Page_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Response.ContentType = "application\octet-stream"
     Dim filename as string=new string("c:\\downloads\\hi.doc") 
            Dim downloadFile As System.IO.FileStream = New System.IO.FileStream(filename, IO.FileMode.Open)
            Response.Write(downloadFile.Length() & "#")
            downloadFile.Close()
            Response.WriteFile(filename)
            Response.Flush()
            Response.End()
    End Sub
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  11. #11
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: PDF Download link

    Yes that is the right way, except that the content type is usually "application\pdf"
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: PDF Download link

    application/pdf will open it in the browserwindow. application/octet-stream should trigget a download.

  13. #13

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Re: PDF Download link

    uuuurgh..no luck

    Code:
    //Set the appropriate ContentType.
    Response.ContentType = "application/octet-stream ";
    //Get the physical path to the file.
    string FilePath = MapPath("../downloads/CAND_Subscribe_en.pdf");
    //Write the file directly to the HTTP content output stream.
    Response.WriteFile(FilePath);
    Response.End();
    Response.Flush();
    Response.End();
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  14. #14
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: PDF Download link

    Try the following link:

    File Upload/Download

    Hope this helps!

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width