Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can I convert PDF to PS with VBA

151 views
Skip to first unread message

Robert Buster

unread,
Nov 5, 2002, 2:30:22 AM11/5/02
to
I'm looking for a way to convert PDF-files to PostScript automatically ( through VBA ). I've tries the Acrobat 5.0 type library but I can't find the exportPS function. Can someone help me?

Aandi Inston

unread,
Nov 5, 2002, 4:11:55 AM11/5/02
to
Did you just pick the name ExportPS, or is there a documentation
reference to it? You should always use the SDK Reference materials
for Acrobat, but in fact I don't think there is any method for doing
this with VBA, except to have Acrobat print to a PostScript printer
ALREADY connected to a specific file port.

Aandi Inston

Sampada

unread,
Nov 5, 2002, 3:36:01 PM11/5/02
to
You can convert a pdf file to postscript file in VB. Add acrtobat.tlb in project reference.. here is a code

Set lobjAdobeApp = CreateObject("AcroExch.App")
Set lobjAdobeDoc = CreateObject("AcroExch.AVDoc")

szDirPath = "c:\test\" '"C:\testpdf\"
szFileName = "OutFile.ps"
szPDFName = "env.PDF" '"TestFile.pdf"

szTemp = szDirPath & Trim(szPDFName) ' full path to pdf file
lobjAdobeDoc.Open szTemp, szFileName 'open the file, with the final filename as the title of the window
If (lobjAdobeDoc.IsValid = True) Then ' we opened the document ok
Set lobjAdobePDDoc = lobjAdobeDoc.GetPDDoc()
nLastPage = lobjAdobePDDoc.GetNumPages() - 1 'Adobe is picky about having the correct page count.
lobjAdobeDoc.PrintPages 0, nLastPage, 1, 0, 0 'print the document to the default print driver
lobjAdobePDDoc.Close 'shut everything down nicely
lobjAdobeDoc.Close 0
'FileCopy "c:\RightFax.prn", szDirPath & Trim(szFileName) 'copy the new file to something your app understands
'Kill "c:\RightFax.prn" 'clean it out.. not necessary as the next print will overwrite, but I'm paranoid
MsgBox "Postscript file created successfully"
Else
'MsgBox "Could not open " & szPDFName & " in Acrobat" 'something VERY BAD has happened.
SendKeys "{ENTER}", True
End If

Sampada

unread,
Nov 12, 2002, 9:30:21 AM11/12/02
to
We been using this code for 2 years now.. not a single time we had any problem!!!
We had to do so because we deal with big pdf files having maps on few pages and text on few.. this was the only reliable option to convert pdf files to ps. The process has to be fully automated to send jobs to printers and fax servers based on business rules. After converting pdf files to ps files, we also edit ps files before sending to printers.. we have 3 different kinds of printers.. everything works just fine.

pleader

unread,
Nov 12, 2002, 8:54:55 AM11/12/02
to
Out of Curiosity, why would you want to do this? Autoconversion of PS files could be very dangerous if you're not dealing with a very controlled workflow, viz. page counts, page dimensions, orientation, printer setup.

And PS files don't travel well (e.g. to other platforms) unless you really know what goes into them.

Regards,
Victor Lee.

pleader

unread,
Nov 12, 2002, 5:44:53 PM11/12/02
to
Well, in that case you probably have a "very controlled workflow". ;^)

Regards,
Victor Lee.

0 new messages