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

Click here to return to the 'Bulk convert text files to PDF' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Bulk convert text files to PDF
Authored by: tedw on Jun 06, '11 10:31:18AM
No. Well, possibly if the word documents are in rtf or text format, but not .doc files. there have been several hints about converting word documents to PDF (search the site), but the general problem seems to be that Word format is proprietary so Apple didn't include a conversion algorithm in CUPS (which is free under GNU license). the file types natively supported are listed here.

It doesn't seem impossible that someone could develop such support as a third party - the file at /usr/share/cups/mime/mime.convs seems to imply that local conversion configurations can be created, at any rate - but they'd still have to work out the proprietary software issue.

[ Reply to This | # ]

Bulk convert text files to PDF
Authored by: musselrock on Jun 06, '11 12:50:53PM

I forgot about textutil which is application independent. Search this forum for "textutil" looking under OS X 10.4. Lots of good hints.

[ Reply to This | # ]
Bulk convert text files to PDF
Authored by: tedw on Jun 06, '11 01:56:52PM
well, I'd forgotten about textutil as well. You could convert doc and docx files to pdf indirectly by first converting them to rtf format, with the following modifications:
on open theFiles
	set oldTID to AppleScript's text item delimiters
	repeat with thisFile in theFiles
		-- get file path as posix path
		set inputFilePath to POSIX path of thisFile
		set AppleScript's text item delimiters to "."
		-- check for doc & docx, convert them to rtf, reset inputFilePath to point to converted file
		if last text item of inputFilePath is in {"doc", "docx"} then
			do shell script "textutil -convert rtf " & quoted form of inputFilePath
			set inputFilePath to ((text items 1 thru -2 of inputFilePath) & "rtf") as text
		end if
		-- create output path - same name with .pdf extension
		set outputFilePathBits to text items of inputFilePath
		set last text item of outputFilePathBits to "pdf"
		set outputFilePath to outputFilePathBits as text
		-- create convert command and send to shell
		set AppleScript's text item delimiters to " "
		set cmdList to {"/System/Library/Printers/Libraries/convert", "-f", quoted form of inputFilePath, "-o", quoted form of outputFilePath}
		do shell script (cmdList as text)
	end repeat
	set AppleScript's text item delimiters to oldTID
end open
That might lose or mess up some formatting - not everything in a doc file can be represented properly in rtf - but it might do for quick and dirty conversions. Probably it should clean up the intermediary rtf files, too, but...

[ Reply to This | # ]