View PDF in RichTextBox in WindowsForm

I'm very new to Visual C#, but i've done alot of VBA in Excel.

Page 1 of 1

5 Replies - 47140 Views - Last Post: 02 September 2009 - 08:40 AM Rate Topic: -----

#1 Engineer Joe   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-October 08

View PDF in RichTextBox in WindowsForm

Post icon  Posted 13 October 2008 - 04:18 PM

I really have two problems.

1) I'm pretty sure I have to add something like PdfLib as a reference. I just installed Adobe Reader 9, which I understand comes with the ActiveX controls I need. However, I do not know which control to add as a reference (PdfLib is not available to be selected from the COM tab.) The other problem I forsee is showing it in the richtext box. I never use richtextboxes, only picture boxes. If anyone could help me out, I'd greatly appreciate it. Like I said, I'm very new to C# and haven't developed my independent reportoire yet.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
// using PdfLib;	 <-----I need to use the Acrobat Control for ActiveX or at least the Adobe Reader 9 equivalent.

namespace WindowsFormsApplication1
{
	public partial class ViewerForm : Form
	{
		public ViewerForm()
		{
		 InitializeComponent();
		 PdfLib.AxAcroPDF axAcroPDF1;
		 axAcroPDF1.LoadFile(@"C:\Documents and Settings\jcrowe\Desktop\Medical Gas\_0708170240_001.pdf");
		 axAcroPDF1.Show();  
		}

		private void richTextBox1_TextChanged(object sender, EventArgs e)
		{
   
		}
	}
}



Is This A Good Question/Topic? 0
  • +

Replies To: View PDF in RichTextBox in WindowsForm

#2 anipirakis   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-October 08

Re: View PDF in RichTextBox in WindowsForm

Posted 21 October 2008 - 12:26 PM

View PostEngineer Joe, on 13 Oct, 2008 - 04:18 PM, said:

I really have two problems.

1) I'm pretty sure I have to add something like PdfLib as a reference. I just installed Adobe Reader 9, which I understand comes with the ActiveX controls I need. However, I do not know which control to add as a reference (PdfLib is not available to be selected from the COM tab.) The other problem I forsee is showing it in the richtext box. I never use richtextboxes, only picture boxes. If anyone could help me out, I'd greatly appreciate it. Like I said, I'm very new to C# and haven't developed my independent reportoire yet.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
// using PdfLib;	 <-----I need to use the Acrobat Control for ActiveX or at least the Adobe Reader 9 equivalent.

namespace WindowsFormsApplication1
{
	public partial class ViewerForm : Form
	{
		public ViewerForm()
		{
		 InitializeComponent();
		 PdfLib.AxAcroPDF axAcroPDF1;
		 axAcroPDF1.LoadFile(@"C:\Documents and Settings\jcrowe\Desktop\Medical Gas\_0708170240_001.pdf");
		 axAcroPDF1.Show();  
		}

		private void richTextBox1_TextChanged(object sender, EventArgs e)
		{
   
		}
	}
}



You need to get your hands on the Acrobat SDK. You can get this at http://www.adobe.com...navID=downloads . This download will actually get you a couple of examples on how to implement this kind of control.

InterAppCommunicationSupport\C#Samples\BasicIacOCXCS

Let me know if this helps.

Aleksei
Was This Post Helpful? 0
  • +
  • -

#3 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: View PDF in RichTextBox in WindowsForm

Posted 21 October 2008 - 12:40 PM

if you like, you can show PDFs without the need of installing adobe(or using the adobe SDK). I had to do this for a client that needed to show PDF "help" documents but didn't want to install adobe on all of the workstations.

Let me find the name of the control and I will post it....unless you are dead set on using a RichTextBox.

This post has been edited by eclipsed4utoo: 21 October 2008 - 12:41 PM

Was This Post Helpful? 0
  • +
  • -

#12 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: View PDF in RichTextBox in WindowsForm

Posted 21 October 2008 - 01:01 PM

here it is...

http://pdfsharp.com/...t...4&Itemid=64

and here is the simple code to view a PDF in .Net.

the "pdfAcroViewer" is a control that I dragged/dropped onto a form.
string helpFile = "C:\HelpFile.pdf";
pdfAcroViewer.LoadFile(helpFile);
pdfAcroViewer.ShowToolbar = false;
pdfAcroViewer.SetPageMode(PdfSharp.Pdf.PdfPageMode.FullScreen);


Was This Post Helpful? 2

#13 Mrlister   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-September 09

Re: View PDF in RichTextBox in WindowsForm

Posted 02 September 2009 - 08:22 AM

Hey... great help !!

What references do you need to add to your project?

would you attach a sample solution space to this post ?
Was This Post Helpful? 0
  • +
  • -

#14 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: View PDF in RichTextBox in WindowsForm

Posted 02 September 2009 - 08:40 AM

It turns out that you do still need Adobe installed on the client PC.

when you download the libraries, you should see a "PdfSharp.dll". Just reference that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1