Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Batch convert Word files to PDFs Apps
I had a lot of Word documents to convert to PDF files, and I found it annoying that I had to use File » PRint and then pick the Save as PDF option from the pop-up menu for each of the 200 files. So I found a solution: Install the CUPS-PDF module for OS X. This is a virtual PDF printer that looks like a "real" printer to the system, but creates a PDF file when you send a document to it. Make sure to install it correctly in Printer Setup, and (important!) make it your default printer.

Now go into Microsoft Word, and create a new Macro (name: testprintpdfs). Paste in the following code:
Sub testprintpdfs()
'
' testprintpdfs macro
' batch pdf print test
'

For i = 1 To 110
    ActiveDocument.PrintOut
    'Dialogs(wdDialogFilePrint).Show
    ActiveWindow.Close
Next i
End Sub
Now open all your files in Word, and execute the macro. It will send a direct print command (without the dialog) and close the current document. It will continue to do this until there are no open documents left -- it will finally give an error, but I didn't care about that. Your PDF files should now be located on your desktop in the cups-pdf folder. They will have some junk (__MICROSFT_WORD_) in front, which you can remove with a simple shell script, Automator, or your other favored file renaming tool.

I hope this hint can save some of you some time, and I am looking forward to reading comments or suggestions for improvements.

[robg adds: Looking at the code, you should probably adjust the For i = 1 to 110 line to reflect the number of documents you plan on converting. This will stop the error from occurring, but this fix isn't critical. We have an older hint here that talked about another way of creating a CUPS PDF printer, but the above-linked package seems like a very nice solution, and it's the first I've heard of it.]
    •    
  • Currently 2.71 / 5
  You rated: 5 / 5 (7 votes cast)
 
[59,423 views]  

Batch convert Word files to PDFs | 14 comments | Create New Account
Click here to return to the 'Batch convert Word files to PDFs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Batch convert Word files to PDFs
Authored by: bobsc on Mar 16, '07 08:04:11AM

If you have Acrobat, it installs a PDF Printer.

---
bobsc



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: nukular on Mar 16, '07 09:43:20AM

I would guess this is going to be useless with the new version of Office for Mac as it is no longer going to support creation of VBA macros on OSX.

Or have I missed something?



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: adrianm on Mar 16, '07 09:50:31AM

You'll have to script it with AppleScript instead. In improvement IMO.
Good hint about the cups pdf installer. Very useful that.

---
~/.sig: not found



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: Arlo on Mar 16, '07 10:17:36AM
This Automator action will do it without all that nonsense:
http://automatorworld.com/archives/text-to-pdf/

---
www.automatorworld.com
"Better Living Through Macintosh Scripting"

[ Reply to This | # ]

Batch convert Word files to PDFs
Authored by: ctopfel on Mar 16, '07 10:59:05AM

The program you suggest doesn't seem to work under 10.4.8 (cannot open/select Word documents with it) and is not Universal. The comments say that is is very slow.

and I'm sure it doesn't present word documetns correctly.



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: Arlo on Mar 16, '07 11:36:09AM

I'm on 104.9, and can't speak for Intel, but it works fine for me. Documents convert fast and correctly, at least the ones I have thrown at it. Maybe it chokes on complex .doc files. Does Universal matter anyway? It should work in emulation, no?

---
www.automatorworld.com
"Better Living Through Macintosh Scripting"



[ Reply to This | # ]
The CUPS-PDF module is golden!
Authored by: Peter Kappesser on Mar 16, '07 01:35:04PM

Great hint in itself about the existence of the CUPS-PDF module, for all of us who don't have Acrobat! When I'm away from home with my laptop, I'm always "printing" web receipts, etc. and saving as PDF, to print when I get home if I need paper copies. This is much neater -- no more having to remember to click the "Save as PDF" button or having to cancel and reprint when I forget. (I know the job will spool to disk and print when I get home, but I save to PDF far more often than I print to paper.)



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: TheTominator on Mar 18, '07 10:01:24AM

After you have installed the Virtual Printer using CUPS-PDF, there is a simpler and more powerful way to batch convert any set of documents to PDF files.

Use Printer Setup Utility to create a Desktop Printer icon for the Virtual Printer. After it is created, I put it in my Dock for easy access.

In the Finder, drag your file icons to the Virtual Printer icon. For Microsoft Word documents, Microsoft Word will be opened and instructed to print each document to that printer.

Unlike the Microsoft Word Macro method, you can do this for any other document created by any other program. As necessary, the Finder will open the appropriate application and tell it to print to the Virtual Printer.

There are two mild limitations to this general method.

(1) The files you drag to the printer icon need to be ones that the Mac knows what to do with (i.e. you can double-click to open it in some program on your Mac).

(2) The document's default "Open With" application needs to support the AppleScript command for Print. All well-behaved MacOS X programs do this. NeoOffice for example doesn't, and thus batch converting native NeoOffice documents does not work for this printer icon method.

---
-- The Tominator



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: TheTominator on Mar 18, '07 10:04:41AM

I forgot to mention that you do not need to make the Virtual Printer your default printer when you use the Desktop Printer icon method.

---
-- The Tominator



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: ctopfel on Mar 18, '07 03:12:46PM

Thanks very much for the tip.
This is much cleaner than the macro method.



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: ctopfel on Mar 18, '07 03:19:44PM

A question: is it possible to disable the printer dialog with this mehtod?The macro method has the advantage that it doesn't require clicking okay at each dialog.



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: TheTominator on Mar 18, '07 06:09:43PM

I don't think there is any general way to disable a dialog that may come up. Some programs bring up a dialog and some don't. Microsoft Word is one of those programs that brings up a Print dialog. Apple's TextEdit.app doesn't.

If your Microsoft Word documents are simple enough that TextEdit can open and interpret them OK, then you can change the "Open With" settings for those .doc files so that they are handled by TextEdit instead. Then print them using the Desktop Printer of the Virtual Printer.

---
-- The Tominator



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: tullius on Oct 17, '08 07:10:56PM

Great hint!

Anyone know how to do something similar in OS9? I ask because I have a *lot* of files created in FrameMaker (IMHO the best word processor/document creator ever released), and I need to turn these files into a format that I can use in OSX.

---
---Tom Tullius



[ Reply to This | # ]
Batch convert Word files to PDFs
Authored by: jdo017 on Mar 19, '07 05:11:23PM
Great hint, but I think this code won't return that pesky error:

Sub PrintPDF()

Dim docLoop As Document

For Each docLoop In Documents
  docLoop.PrintOut
  ActiveDocument.Close
Next docLoop

End Sub

---
God invented the integers, all else is the work of man.

[ Reply to This | # ]