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

A

Alex Smith

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
 
O

Oenone

Alex said:
I have trying to open a PDF file in richtextbox, a .txt file open
successfully but a .pdf file open with unreadable form.

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.
 
A

Alex Smith

Thanks for replay Oneone,
Then if I want to open a pdf file than what is way for that?
anything elase?
Alex.
 
O

Oenone

Alex said:
Thanks for replay Oneone,
Then if I want to open a pdf file than what is way for that?
anything elase?

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,
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top