I want to open a pdf file in Rich TextBox ...

Discussion in 'ASP .Net' started by Alex Smith, Jun 7, 2005.

  1. Alex Smith

    Alex Smith Guest

    Hi Friends,
    I have trying to open a PDF file in richtextbox, a .txt file open
    successfully but a .pdf file open with unreadable form.
    I have trying with

    OpenFileDialog fileopen = new OpenFileDialog();

    PdfLib.PdfClass newpdf = new PdfLib.PdfClass();



    void Browse_Click(object sender, EventArgs e)

    {

    fileopen.ShowDialog();

    string fname = fileopen.FileName;

    StreamReader sr = new StreamReader(fname);

    string varread = sr.ReadToEnd();

    richTextBox1.Text = varread;

    sr.Close();

    }



    Alex
     
    Alex Smith, Jun 7, 2005
    #1
    1. Advertisements

  2. Alex Smith

    Oenone Guest

    That's because PDF files are binary files whose content is not directly
    readable (not without understanding the file format and performing a fairly
    considerable amount of processing in order to extract it).

    RichTextBoxes can't display PDF file content, I'm afraid.
     
    Oenone, Jun 7, 2005
    #2
    1. Advertisements

  3. Alex Smith

    Alex Smith Guest

    Thanks for replay Oneone,
    Then if I want to open a pdf file than what is way for that?
    anything elase?
    Alex.
     
    Alex Smith, Jun 7, 2005
    #3
  4. Alex Smith

    Oenone Guest

    If you're developing a web application, all you can do is send the PDF file
    to the browser and allow it to save or open it in whatever way it sees fit.

    If you're developing a Windows forms application, you might be able to find
    a third party control which is able to display PDF files, though I'm not
    aware of one off the top of my head. Otherwise all I can think of is to open
    the PDF file in the user's PDF viewer application (usually Acrobat Viewer).
    You can see an easy way to do this here:

    http://groups-beta.google.com/group..._frm/thread/f86d24faad711820/e138fa4abfa5f46f

    Hope that helps,
     
    Oenone, Jun 7, 2005
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.