How to print a PDF file in C# ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I'm trying to make an application in C# that can, from a DataSet, create a
PDF file.
I'll made that (and it works) using iTextSharp library.
Now I want to print this PDF file within the code.
I just have the free Acrobat Reader 7.0.
In my Visual project, I included a reference to AcroPDFLib, and tried to
work with it.

This is my simple code :
AcroPDFLib.AcroPDFClass test = new AcroPDFClass();
test.LoadFile("listing.pdf");
test.printAll();

Unfortunatelly, I've got an error with LoadFile() : a NullReferenceException
with VS2003 and "Attemped to read or write protected memory. This is often an
indication that other memory is corrupt." with VS2005 Beta2.

Any help would be welcome :)

PS: I also apologize for my poor english
 
Hi!
I'm trying to make an application in C# that can, from a DataSet, create
a PDF file.
I'll made that (and it works) using iTextSharp library. Now I want to
print this PDF file within the code. I just have the free Acrobat Reader
7.0. In my Visual project, I included a reference to AcroPDFLib, and
tried to work with it.

Try this:
1. in your project add reference to COM 'Acrobat Control for ActiveX' -
now you should have AxPdfLib namespace
2. AxPdfLib.AxPdf axPdf = new AxPdfLib.AxPdf();
3. axPdf.LoadFile("my.pdf");

You can put Acrobat Reader on your form with GUI editor - simply customize
your toolbox by adding COM 'Adobe Acrobat Control for ActiveX'.

Good luck,
Piotrek

P.S. I use Acrobat Reader 6
 
The problem is that with Acrobat 7.0 there is no more COM 'Acrobat Control
for ActiveX', and I need to make it with Acrobat 7.0
 
Correction : In fact I was wrong, the problem is that I was not adding the
reference buy customizing the toolbox.

Now it's working.

Thanks for your help
 
Back
Top