473,322 Members | 1,232 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to print a PDF file in C# ?

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
Oct 4 '05 #1
3 23538
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
Oct 5 '05 #2
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

Oct 5 '05 #3
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

Oct 5 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Manfred Schwab | last post by:
Recording messages and print statements in a textfile during program execution. Is there a similar command to redirect errormessages or print statements into a standart asciifile during...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
7
by: Ron | last post by:
Hi All, Is it possible to have Access print a report, identical to one that would print to a printer, only print to a "standard" text file? I can't find it in help and when I try to just print...
3
by: Max58kl | last post by:
Trying to access data and print it to the screen using Perl Builders I/O Window -------------------------------------------------------------------------------- Hi I am using a program called...
3
by: itdaddy | last post by:
hey perl gurus! i am new to this forum cause i need help. I have done many scripts. but i want to use perl to do this: What I want to do is this. I have a QRP file that I can convert to a txt...
2
by: alivip | last post by:
when I wont to inser (anyting I print) to the textbox it will not inser it just print then hanging # a look at the Tkinter Text widget # use ctrl+c to copy, ctrl+x to cut selected text, #...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
5
by: prakashturkar | last post by:
Hi, I am Prakash.... I have tried to print an MS Word file using the basic print utilities provided in JAVA.But while asking for printing through my own code i am getting proble for example..."The...
2
by: dmorand | last post by:
When I try to print a 'print version' of my page it looks fine in IE 7, but when I print in IE 6 the margins are all screwed up. The page itself looks the same in both browsers, it's just when I...
11
by: JWest46088 | last post by:
I'm having difficulty trying to figure out how to print a text file from a hash table one line at a time. I have the text file read into the hash table and can print the text file all at once, but I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.