Trying to print batch of PDF files programmatically

D

David Cho

I am still struggling with this. Used the PrintDocument class, but it
was printing gobblygook. Does not recognize the PDF files as Acrobat
files and just prints text.

Can't get the shell command to work.

Tryed

print C:\test.pdf

Is there a better way?

Anyhow, I finally tried to use the Acrobat provided dll called
AxPdfLib.AxPdf and tried the following.

axpdf.LoadFile("C:\test.pdf");
axpdf.Print();

Nothing happens. Please help.
 
R

Rik Hemsley

David said:
I am still struggling with this. Used the PrintDocument class, but it
was printing gobblygook. Does not recognize the PDF files as Acrobat
files and just prints text.

It wouldn't. It doesn't speak PDF.
Can't get the shell command to work.

It doesn't, since Acrobat 6. It works for 4 and 5.
Tryed

print C:\test.pdf

Nope ;)
Is there a better way?

Anyhow, I finally tried to use the Acrobat provided dll called
AxPdfLib.AxPdf and tried the following.

axpdf.LoadFile("C:\test.pdf");
axpdf.Print();

Nothing happens. Please help.

Try printWithDialog().

Adobe Reader 6 gives a warning which you can't get rid of. Adobe Reader
7 doesn't.

The problem remaining is the dialog.

I expected printAll() would be what I wanted, but it simply doesn't do
anything.

I could hack something to accept the dialog, but my app is running as a
Windows Service, so that's likely to be a bad idea.

Does anyone know of a way to print PDF files programmatically, without
user interaction?

I have ruled out GhostScript because we can't get support (AFPL are the
ones who would provide support, but they refuse to sell us a license
because we wouldn't be paying them enough due to the number of licenses
we sell). David, I'd look into GhostScript.

Is there something that comes with the Acrobat SDK which allows printing
without user interaction? I asked Adobe and they told me to buy it. I
don't want to buy something when I don't know whether it does what I need!

Rik
 
M

Michael Voss

Hi !

Rik Hemsley wrote:
[...snip...]
Does anyone know of a way to print PDF files programmatically, without
user interaction?

I have ruled out GhostScript because we can't get support (AFPL are the
ones who would provide support, but they refuse to sell us a license
because we wouldn't be paying them enough due to the number of licenses
we sell). David, I'd look into GhostScript.

We decided to use GSPrint (comes with GhostView) to do this from a
C#-Program.
The other way we are currently thinking of is using the (commercial)
TallComponents PdfRasterizer library to read the pdf file and render it onto
our drawable. Currently, we do still use GhostScript because we encounter
some minor issues using the PdfRasterizer, but they do not seem to be
related to this code library...
Is there something that comes with the Acrobat SDK which allows printing
without user interaction? I asked Adobe and they told me to buy it. I
don't want to buy something when I don't know whether it does what I need!

We are looking for something to display pdf that we can include in out own
application window using OLE, so the user will not be able to do anything
but look at the pdf output, since Adobe Reader 7 does not seem to include
the OLE control PDF.PDFCtrl any longer... No success either.
 
D

David Cho

Got this thing working!

using the System.Diagnostics namespace,

I loop through the following code.

Process command = new Process();
command.StartInfo.FileName = Configuration.PathToAcrobatReader +
"/acrord32.exe";
command.StartInfo.Arguments = "/p /h " + "mydoc.PDF";
command.StartInfo.RedirectStandardOutput = true;
command.StartInfo.UseShellExecute = false;
command.Start();
command.StandardOutput.ReadToEnd();

I was worried that each time the code loops through, a new instance of
AcrobatReader would launch. That is not the case and the code works.
 

dlz

Joined
Nov 24, 2008
Messages
2
Reaction score
0
Configuration.PathToAcrobatReader - where is it?

I copied the code into a C# project, but the build failed, because the name Configuration does not exist in the current context. Any assistance would be greatly appreciated.
 

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