You must Sign In to post a response.
  • Category: ASP.NET

    How to open the pdf file in asp.net

    how to open the pdf file in asp.net but user can just view that file not save and download.
  • #764210
    Hi Vinod.

    Try below piece of code.

    FileAttributes obj = File.GetAttributes(path);
    File.SetAttributes(path, obj | FileAttributes.ReadOnly);

    Refer below msdn article for more information regarding file attributes.

    https://msdn.microsoft.com/en-us/library/system.io.file.setattributes.aspx

    Sridhar Thota.
    Editor: DNS Forum.

  • #764231
    There is no inbuilt viewer for PDF file exist in ASP.NET, you can open it with its native application.
    I mean if user has PDF Acrobat exist and if it open PDF file then bydefault it will open in Acrobat and can be editable, but if user has only Acrobat Reader installed then it can open in view mode.
    You just need to use Hyperlink or Linkbutton control to set 'NavigateURL' to PDF file and it will get open

    Hope it helps

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #764386
    It will be impossible. Cause to view pdf you need pdf viewer embedded in browser. Then when it loads the pdf it also can write or save the file to disk.
    If you are unable to do something properly for the first time, call it Version 1.0!

    Thanks & Regards,
    MONOJ BHUINA

  • #764606
    To view pdf file in ASP.NET, you can add a pdfviewer control.
    refer to this article:
    http://www.c-sharpcorner.com/UploadFile/1583f2/view-pdf-files-from-web-browser-in-C-Sharp/

  • #764672
    You'll need a PDF viewer control if you wish to view PDF files in your website. I found these topics which may be helpful:
    http://www.codeproject.com/Articles/41933/ASP-NET-PDF-Viewer-User-Control-Without-Acrobat-Re

    http://www.codeproject.com/Articles/297669/How-to-Read-Write-and-Edit-PDF-Files-and-Metadata


Sign In to post your comments