How to print a PDF file in C# ?
How to print a PDF file in C# ?
am 04.10.2005 16:46:13 von unknown
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
Re: How to print a PDF file in C# ?
am 05.10.2005 09:29:45 von Piotr Szukalski
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
Re: How to print a PDF file in C# ?
am 05.10.2005 09:53:02 von unknown
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
"Piotr Szukalski" wrote:
> 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
>
Re: How to print a PDF file in C# ?
am 05.10.2005 16:46:10 von unknown
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
"François Miermont" wrote:
> 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
>
> "Piotr Szukalski" wrote:
>
> > 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
> >