Command-Line Printing

K

Kelly M

We accept Publisher files uploaded via the web for printing, and we convert
..pub files to PDF on the fly. We're adjusting our workflow to print to a PDF
print driver, in order to keep CMYK colors, but we're having problems running
the files programmatically.

We've tried running a command line, and if you execute it as a user, it
works fine:
"C:\Program Files\Microsoft Office\OFFICE11\mspub.exe" /p "C:\Documents and
Settings\kelly\Desktop\hr2006.pub"

However, running it through a web server (PHP/Apache) launches Publisher,
but it hangs and eventually errors out without printing.

First, is there a better method of programmatically printing a .pub document
to PDF? Second, if not, anybody have any clues why it would hang? Third, I
recall seeing a Publisher list of command-line switches, but I can't find
that any more, does anyone have a link?

Thanks for any clues in pointing me in the right direction.

- Kelly
 
E

Ed Bennett

Kelly said:
First, is there a better method of programmatically printing a .pub document
to PDF?

Does PHP support COM? If it does, you can use Publisher (2002 or later)
as a COM server, and programmatically open the files (you can even use a
single instance if you prefer rather than opening and closing a load).

You'll probably need to reference the Microsoft Office object library
and the Microsoft Publisher object library. Then create an instance of a
Publisher object.
Second, if not, anybody have any clues why it would hang?

No idea, sorry. I wasn't even aware of the command-line switch until you
posted!
Third, I
recall seeing a Publisher list of command-line switches, but I can't find
that any more, does anyone have a link?

Nope. If you find one, can you post it here - I'll add it to my list o'
links at the website below.
 
K

Kelly M

I think I've found the answer, or set of answers. As I'd thought, it had to
do with permissions. Not only do all Office files need to have their
permissions set so the IUSR_<accountname> guest account for IIS can access
them, Publisher needs to have a specific "Launch Permissions" flag set. I
found the specifics in this MS KB article:
http://support.microsoft.com/kb/288366/

Also, I needed to log in as the IUSR_<accountname> account to set up a user
profile for Publisher in that account. That was also tricky, but the above
article had info on how to do that.

Once all that was done, PHP was able to successfully launch Publisher and
print a file to a PDF print driver.

- Kelly

Ed Bennett said:
Does PHP support COM? If it does, you can use Publisher (2002 or later)
as a COM server, and programmatically open the files (you can even use a
single instance if you prefer rather than opening and closing a load).
You'll probably need to reference the Microsoft Office object library
and the Microsoft Publisher object library. Then create an instance of a
Publisher object.

Yes, I've tried to instantiate a COM object through PHP, but it had the same
issue.
 

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