Solved

Print PDF to file - Shell syntax for Adobe Acrobat Reader?

Posted on 2007-03-30
26
4,901 Views
Last Modified: 2008-01-09
I need to print a PDF file to file, via a Postscript printer driver, from VB6 code.  It's my intention to use the VB Shell command, but I need to know the correct syntax for the Acrobat Reader.

In the registry (W2K) the shell\print\command syntax is given as:

"C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe" /p /h "%1"

but I can't find an explanation of the arguments anywhere.

I know I need to provide the name of the file to print, the printer name and the destination folder.

Can anyone please explain this syntax (I've spent a fruitless morning googling for this information!)?

Thanks

Ed
0
Comment
Question by:Ed2003
  • 9
  • 6
  • 5
  • +4
26 Comments
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18828932
0
 

Author Comment

by:Ed2003
ID: 18831893
Thanks for this Jeff

I'm already printing successfully from the Reader to a network printer, using the Shell command in my VB application.  What I need to know is how to print to file via a Postscript driver.  At the moment, if I use the Postscript printer driver name as the argument in the command line, instead of the network printer name, nothing happens at all.  I would have expected a dialog to appear for browsing a destination folder, as the driver is connected to the File port.  If I could get to that point, I could try to intercept and complete the dialog.  Ideally, I'd hope to be able to offer the destination folder as a further argument in the command line.

Any more thoughts would be appreciated.

Ed
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18832157
Possible silly question...
Have you explore Lebans method for outputting as PDF? I know he makes use of the PDF driver.
0
 

Author Comment

by:Ed2003
ID: 18833203
Sorry - perhaps I'm not explaining the problem properly.  I have a saved PDF already.  I can print this file to a network printer using the VB Shell command, and get hard copy from the printer.  What I want to do is to print it to a postscript file on hard disk, via a postscript printer driver.  The reason I want to do this is to enable me to generate postscript files automatically in an overnight batch process for sending to a central printing facility where postscript files are fed to Xerox printers whose output is automatically collated and enveloped.  All I need to find is the Shell syntax for printing to file from the Acrobat Reader.

Thanks

Ed
0
 
LVL 75
ID: 18833783
Hi Jeff ... just confirming I got the Notify ... don't think I would be much help here.

mx
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 18834728
Ghostscript (free to use) may help you, might even be faster than Distiller:

http://web.mit.edu/ghostscript/www/Use.htm#File_output

/gustav
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 18834868
0
 
LVL 58

Expert Comment

by:harfang
ID: 18834871
Hello Ed,

This is a real problem using Windows.

MS believes that printing means using a driver to send information to a port (a port being for some reason very different from a file). So, in order to print, you need to "install" a printer, and you can specify the port during the installation.

If you wish to print to a file, you specify that (instead of a port), but you will get prompted for a file name each time you print, so this won't work for an automated solution.

If you use Novell Netware, you can capture a port to file (as you can in any real OS, btw). This would be the simple solution: capture, print, relase capture, manage file, restart...

In any case, under Windows, you cannot do anything with a printer driver as such. You will need to install your Xerox driver (as close as possible to the target printer, of course) as virtual printer and find a way to use that...

Cheers!
(°v°)
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 18834905
Ed

my post are for printing to printer, sorry I didn't your other posts.

but look at the last link, there are a few freeware files there that might help.

jaffer
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 125 total points
ID: 18834920
As for the printer driver printing to a file, you may be able to output to a fixed file to avoid the prompt. Then, locate the name of the file in the Registry and modify the file name before your app prints the pdf file.

/gustav
0
 

Author Comment

by:Ed2003
ID: 18835218
Many thanks to all who have contributed so far.  In the light of the above and of my own continued research, I've pretty well concluded that I need to create a new port with a fixed file name, and then rename the file after each file is printed.

Although this is not the solution I was looking for, I note that this was essentially your answer, cactus_data.  Can I have some advice please as to whether I should accept this solution?
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 18835246
Good question. We haven't used this, I just know that some of my fellow developers have used that method with success.

/gustav
0
 
LVL 57
ID: 18835772
<<Many thanks to all who have contributed so far.  In the light of the above and of my own continued research, I've pretty well concluded that I need to create a new port with a fixed file name, and then rename the file after each file is printed.>>

  That is basically correct.  Depending on the type of printer driver you have, what you do is either print to disk using a printer driver, then convert to PDF format (ie. Ghost Script) or you "print" directly to a PDF file through the driver (ie. Acrobat).  It may be that you can take printer output and convert to PDF as well with Acrobat (I use Ghostscript myself).

  Unless someone chimes in with some actual experience using it, the best source of info would be Adobe's web site.  I'm sure they would have some programming examples.

JimD.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 49

Expert Comment

by:Gustav Brock
ID: 18835912
This should be the command line for Ghostscript:

http://orion.math.iastate.edu/burkardt/g_src/pdf2ps/pdf2ps

Adobe(!) seems to be a no-go:

http://support.adobe.com/devsup/devsup.nsf/docs/51625.htm

/gustav
0
 
LVL 57
ID: 18836100
gustav,

<<Adobe(!) seems to be a no-go:>>

  That's going the wrong way; PDF to a postscript print file.

JimD
0
 
LVL 57
ID: 18836121

 FYI, I found this on the Adobe site in a Word OLE to PDF example:

"Dim pdfDist As PdfDistiller
Set pdfDist = New PdfDistiller
pdfDist.FileToPDF "c:\filename.ps", "c:\filename.pdf", ""

The Visual Basic and Visual C++ implementations of converting from PostScript to PDF is provided in the Acrobat SDK sample, DistillerCtrl."

Note the last line.

JimD
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 18836136
But that's not it:

> What I want to do is to print it [PDF file] to a postscript file ..

/gustav
0
 
LVL 57
ID: 18836212

  Well I guess I'm the one that's confused then;  why are we trying to go from PDF to Postscript?  If he already has the PDF file, then it's just a matter of sending it to a printer...

  Reading back through the thread, I'm not sure exactly what the problem is...

JimD
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 18836249
This is how Ed explained the task:

The reason I want to do this is to enable me to generate postscript files automatically in an overnight batch process for sending to a central printing facility where postscript files are fed to Xerox printers whose output is automatically collated and enveloped.  All I need to find is the Shell syntax for printing to file from the Acrobat Reader.

/gustav
0
 

Author Comment

by:Ed2003
ID: 18837749
Thanks Gustav.  There does seem to have been a good deal of confusion, although I thought I'd explained exactly what I was trying to do and why, in the original question and the follow-up.  Just to recap, I have a PDF already, and want to generate a postscript file!  If anyone can suggest a way to print to a dynamic file name (ie provided at run-time) silently from VB code, I'd be glad to hear it.  Otherwise, I think I'll go with the fixed file name method, renaming each file as it's produced.

I'd still like some advice on whether I should accept cactus_data's solution though, as mentioned above.  If I don't hear anything to the contrary, I'll do so.

Many thanks

Ed
0
 
LVL 57
ID: 18837868
Ed,

<<Just to recap, I have a PDF already, and want to generate a postscript file!>>

 Generate a postscript file or just send the PDF file to a printer to be printed, which uses a postscript driver.

JimD
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 18844301
Did you find a solution?

/gustav
0
 

Author Comment

by:Ed2003
ID: 18844603
JDettman

That's what I'm trying to do - to generate a postscript file at run-time from VB code!  

<<If anyone can suggest a way to print to a dynamic file name (ie provided at run-time) silently from VB code, I'd be glad to hear it.>>

Can you tell me how to do this?

Thanks

Ed
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 18845059
It could be done, but I think I would go with Ghostscript:

http://www.cs.wisc.edu/~ghost/doc/AFPL/8.00/Use.htm#PDF
<quote>
Using Ghostscript with PDF files
Ghostscript is normally built to interpret both PostScript and PDF files, examining each file to determine automatically whether its contents are PDF or PostScript. All the normal switches and procedures for interpreting PostScript files also apply to PDF files, with a few exceptions. In addition, the pdf2ps utility uses Ghostscript to convert PDF to (Level 2) PostScript.
</quote>

http://www.cs.wisc.edu/~ghost/doc/AFPL/8.00/Use.htm#File_output
<quote>
Output to files
Ghostscript also allows you to control where it sends its output. With a display device this isn't necessary as the device handles presenting the output on screen internally. Some specialized printer drivers operate this way as well, but most devices are general and need to be directed to a particular file or printer.

To send the output to a file, use the -sOutputFile= switch. For instance, to direct all output into the file ABC.xyz, use

gs -sOutputFile=ABC.xyz
</quote>

So, no "printing", no special printer setup, just a command line.

/gustav
0
 

Author Comment

by:Ed2003
ID: 18852011
Thanks for this cactus_data

I'll put the Ghostscript option on the backburner as I'd need to get approval to install it on our servers, and go with the fixed file solution for now.  I'll accept your earlier solution as it's this I'm going to use.

Many thanks to all contributors.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 18852040
You are welcome!

/gustav
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Update 21-May-2015: I temporarily removed the source code and the code snippets to make major changes to the program. Regards, Joe A recent question here at Experts Exchange piqued my interest, so I decided to provide a thorough solution and publ…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
We often encounter PDF files that are pure images, that is, they do not have text characters, but instead contain only raster graphics. The most common causes of this are document scanning software and faxing software/services that create image-only…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now