473,466 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 23549
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.