Automate PDF printing - is there a .net Acrobat object?

G

Guest

Hello all,

I wish to automate printing of PDF documents in a C# application.

Is there an Adobe .net object? I tried to create a reference to the COM
Object Adobe Type Library, but I get error "Exception from HRESULT 0x80131019"

Thanks
Chris
 
R

Robby

They do sell the Adobe PDF Library that you can use to do this. I am not
sure if it supports .Net. You should contact them and ask.

--Robby
 
N

Norman Yuan

There are so many existing .NET libraries/components for PDF generating.
Simply google the net for "PDF & .NET", you get hundreds of links. Many are
commercial products, but a few of them are freeware.
 
D

Dennis Myrén

However, generating PDF and printing PDF is not the same thing.
Yes, there are lots of PDF generation libraries out there, but native print
support
you will hardly find.
Your options is to use the DDE interface towards Acrobat, if Acrobat is
available,
or to use GhostScript.
 
G

Guest

Thanks Dennis - quite correct, I am not looking to generate a PDF

I have Acrobat 5.0 installed, and I can see the 'Acrobat 5.0 Type Library'
availabale as a 'COM' object under project references.

However, when I select this, (or any of the COM components) in the
references, it comes up with this error:

"A reference to 'COM obect name here' could not be created. Converting the
type library to a .NET assembly failed. Exception from HRESULT: 0x80131019"

Adding the reference works on another development machine...

Any ideas?

Thanks
Chris
 
D

Dennis Myrén

Sorry for the late reply.

Unfortunately, I have never succeeded using DDE to control Acrobat from C#.
I tried a bit now, getting no errors whatsoever, everything runs, but
nothing happens.
It is really hard, to be honest.

Basically, you will need to use Windows API functions defined in user32.dll,
essentially DdeInitialize, DdeConnect, DdeCreateDataHandle,
DdeClientTransaction, and DdeUninitialize.

This example is C ++, but should give you a start:
http://www.codeproject.com/cpp/ReaderWrapper.asp
If you google a bit, you will find some VB examples of using DDE.
They might be a help as well.

The Acrobat DDE reference you can read about here(section "DDE Messages"):
http://partners.adobe.com/public/developer/en/acrobat/sdk/IACReference.pdf

DDE can be used to control both Acrobat and Acrobat Reader.
However, if you have the full Acrobat Version, then you can and should use
the COM API
instead, which is not available if only the Reader is installed on the
machine.

Finally, if you are out of success, you might consider bying something like
this:
http://www.pdfstore.com/details.asp?ProdID=703&fp
It is relatively cheap.


Hope this helps just a bit.

PS
And please, contact me if you do succeed!
 
G

Guest

Hi Dennis,

Thanks for the reply! Sorry I'm a bit late too - I have discovered the
easiest way will be to do a command line call to acrord32.exe (acrobat
reader) with switches /h and /p to print, so I'm using:

acrord32.exe /p /h filename.pdf

thanks for the links + advice though!

Chris
 
G

Guest

Guys,

For future readers, I found a way to embed this Acrobat object to .Net
windows form. From the Toolbox, add item, selecte COM component, navigate to
pdf.ocx (normally it is under
program files\Adobe\Acrobat 6.0\Reader\ActiveX\)
That is it!
You can print, save, and other things.

(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top