Solved

Programmatically convert .doc to .pdf

Posted on 2008-10-27
9
1,083 Views
Last Modified: 2012-06-27
Hi Experts.

I am using Visual Basic 6.0 and need to convert a Word document to a PDF file programmatically.

I have Adobe Acrobat  6.0 Professional installed in my development machine.  I figured I should have the components (OCX, DLL) I would need to make this happen.

Can someone please help me?  Please?

Thanks very much for your anticipated assitance.
0
Comment
Question by:winpiglet
  • 5
  • 2
  • 2
9 Comments
 
LVL 2

Expert Comment

by:jbuzzard
ID: 22812048
Why do you need to do it in VB? I would suggest making the 'program' make an external call to 'cutePDF' printer or the like.
0
 

Author Comment

by:winpiglet
ID: 22812136
I need it to be in VB because the file will be emailed to clients (as their invoices)..  What does cutePDF do?
0
 
LVL 2

Expert Comment

by:jbuzzard
ID: 22812226
cutePDF is a free pdf printer; you could get your program to autoinstall that at the start, and then use it to write to pdf before emailing. It's easier than writing it yourself...
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 250 total points
ID: 22812268
Why is it that somebody always has to bring up tools like cutePDF or PDF995 - even though the asker clearly states that they have the full version of Acrobat?

winpiglet: You can do this with what you have (Word, Acrobat and VB). However: Keep in mind that the Acrobat EULA does not allow you to run Acrobat on a server (or in a server like environment).

And, another caveat: This task will be much easier with a newer version of Acrobat. Starting with Acrobat 7, Adobe provided a documented way to name PDF files. Acrobat 6 does not have that, so it gets a bit more complicated. If  you have a chance to upgrade, please do, it will make your life a lot easier.

The general method is this:

You need to create a PostScript printer that allows you to write to file (that is the setup part and needs to be done outside of your software).

In your VB program, you automate Word to open one file at a time, and print it to the just created PostScript printer - ending up with a PostScript file.
Then you VB program takes that file and hands it over to Distiller. You can download the Distiller API documentation from Adobe's web site (http://www.adobe.com/devnet/acrobat).
There are two ways you can do this: You can either use the command line interface, or you can use the automation interface. Both are described in the Distiller API documentation.

In Acrobat 7 and later, you set a registry key with the PDF file name before you start your print process in Word, then you just select the "Adobe PDF" printer and print to that printer. Distiller will automatically create the PDF file for you.

Regardless of what you do, you cannot mimic the behavior of the PDFMaker (which will convert Word links and bookmarks as well). The interface to PDFMaker is not published, and people who tried to reverse  engineer it have been bitten by software updates that render their solutions useless.
0
 
LVL 2

Expert Comment

by:jbuzzard
ID: 22812319
The reason for bringing up tools like CutePDF is because it is free, and doesn't require a full (and paid for) version of Acrobat on every computer. It can then act in the exact manner you are referring to above. I thought it was relevant...
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22812345
Yes, but the asker has a full (and paid for - I hope) license for Acrobat...
0
 
LVL 2

Expert Comment

by:jbuzzard
ID: 22812467
Sorry, explain a bit more - I kinda thought he/she may be writing a program for distribution over more than just one computer.
If he/she's just using one computer, then acrobat is fantastic. However, more than one means more than one license; not good for end price.
0
 

Author Comment

by:winpiglet
ID: 22812563
ok guys.... thank you very much for your comments and suggestion.  I appreciate them.

Yes, I have full and paid for version of Acrobat 6.0 Prof
Yes, the program should be running on at least 20 computers in our local area network.  So a solution that is portable is the best solution.

I will look into the cutePDF then khkremer's solution.  And see what best fit my needs.  I'll get back on this issue as soon as I've tried both.

Thanks very much to you both.
0
 
LVL 2

Expert Comment

by:jbuzzard
ID: 22812679
No worries - hope you get it working.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update 21-May-2015: I temporarily removed the source code and the code snippets to make major changes to the program. Regards, Joe A recent question here at Experts Exchange piqued my interest, so I decided to provide a thorough solution and publ…
PDF files have been in the limelight due to its unmatched features.  Personal documents, emails, business reports and eBooks are all converted into PDF files owing to peerless features provided by it. Adding watermark to a PDF file is a method to se…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
We often encounter PDF files that are pure images, that is, they do not have text characters, but instead contain only raster graphics. The most common causes of this are document scanning software and faxing software/services that create image-only…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question