# PDF-writer and MS word document

**URL:** <https://www.ruby-forum.com/t/pdf-writer-and-ms-word-document/74094>\
**Category:** Ruby\
**Created:** [October 30, 2006, 5:49am UTC](https://www.ruby-forum.com/t/pdf-writer-and-ms-word-document/74094 "2006-10-30T05:49:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [October 30, 2006, 5:49am UTC](https://www.ruby-forum.com/t/pdf-writer-and-ms-word-document/74094/1 "2006-10-30T05:49:55Z")

</div>

Hi guys,

I just wonder if anyone out there ever uses PDF::Writer to create a PDF  
file from a MS word document file. I can only create a PDF file if the  
file is in plain text format.

Thanks,

Li

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [October 30, 2006, 7:21am UTC](https://www.ruby-forum.com/t/pdf-writer-and-ms-word-document/74094/2 "2006-10-30T07:21:37Z")

</div>

Li Chen wrote:

> Hi guys,
> 
> I just wonder if anyone out there ever uses PDF::Writer to create a PDF  
> file from a MS word document file. I can only create a PDF file if the  
> file is in plain text format.
> 
> Thanks,
> 
> Li

You might want have to write some sort of a macro or script file which  
opens up word, dumps the document to text so you can do your conversion.

An easier approach would be to use a PDF print driver

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [October 30, 2006, 3:09pm UTC](https://www.ruby-forum.com/t/pdf-writer-and-ms-word-document/74094/3 "2006-10-30T15:09:58Z")

</div>

CatLady [] wrote:

> You might want have to write some sort of a macro or script file which  
> opens up word, dumps the document to text so you can do your conversion.
> 
> An easier approach would be to use a PDF print driver.

Do you know which is most popular and compatible with in Ruby?

Thanks,

Li

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [November 7, 2006, 10:44am UTC](https://www.ruby-forum.com/t/pdf-writer-and-ms-word-document/74094/4 "2006-11-07T10:44:39Z")

</div>

CatLady [] wrote:

> You might want have to write some sort of a macro or script file which  
> opens up word, dumps the document to text so you can do your conversion.
> 
> An easier approach would be to use a PDF print driver

There are some filters available on most open-source platforms that will  
do a _fair_ job of this. [OpenOffice.org](http://OpenOffice.org) will also do a _fair_ to  
_acceptable_ job of this. For the most part, though, making high-quality  
PDFs of a Word document requires either buying software for a Windows  
platform or using the Adobe service that converts documents on the web.

Creating high-quality PDFs from _original_ documents is much easier in  
the open source world. TeX and all its trappings, DVI, PostScript,  
Scribus, Inkscape, etc. offer excellent PDF output. The tricky part is  
getting the information from the Word document.

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [November 7, 2006, 10:45am UTC](https://www.ruby-forum.com/t/pdf-writer-and-ms-word-document/74094/5 "2006-11-07T10:45:11Z")

</div>

If you are on Mac, simply print to the Adobe PDF printer.  
If you are on Windows, download something like PDF995 which creates a  
PDF printer for you.  
If you are on Linux, I don’t think you have the printer option.  
OpenOffice should be able to export a PDF, and you could figure a way  
to finagle an API there somewhere most likely.

PDF::Writer is difficult because (to my knowledge) there is no way to  
extract data from a Word file programmatically, with the exception of  
perhaps using the application “antiword” to extract the text and then  
using PDF::Writer to write that back. Not your best option (because  
formatting and such is lost), but it is an option.

–Jeremy

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [November 7, 2006, 10:45am UTC](https://www.ruby-forum.com/t/pdf-writer-and-ms-word-document/74094/6 "2006-11-07T10:45:54Z")

</div>

On 10/30/06, Li Chen [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> CatLady [] wrote:
> 
> > You might want have to write some sort of a macro or script file which  
> > opens up word, dumps the document to text so you can do your conversion.
> > 
> > An easier approach would be to use a PDF print driver.  
> > Do you know which is most popular and compatible with in Ruby?

You’re not looking for something to run from Ruby. You’re looking for  
a program that understands the (proprietary) Microsoft Word format and  
can write the (semi-open) PDF format. The absolute best way to do this  
is to open the document in Word and print it through Acrobat. Lesser  
ways include opening the document in OpenOffice and exporting it as a  
PDF.

Alternatively, you can try something like PDFCamp (works on Windows):  
[Word To Acrobat - a best Word To Acrobat utility](http://www.verypdf.com/pdfcamp/pdf-writer/word-to-acrobat.html)

You might be able to use [http://www.pdfonline.com/](http://www.pdfonline.com/) to convert, but I’m  
not sure they’d want you doing a third-party conversion in your own  
application. Or maybe [http://www.primopdf.com/](http://www.primopdf.com/) if you want to consider  
that. Or [Word doc to pdf converter can convert batch of pdf files easily](http://www.convertzone.com/doc2pdf/help.htm). Or try FastPDF:  
[http://www.fastpdf.com/](http://www.fastpdf.com/).

PDF::Writer will never have this capability directly, and even if  
someone were to create a Word document parser, it is unlikely that  
formatting would be preserved exactly. It might be more likely to see  
a PostScript parser, but even that is unlikely.

-austin
