How to Convert MS word (97-2000) document to PDF document by printing on "Source Forge - PDF Creator" through server side asp

I have a requirement where i need to convert a word (97-2000) document to a PDF document through asp. I have sourceforge-PDFCreator installed on the server and try printing the word document to a PDF file. there are 2 issues in the process.
(i)   I am not able to supply file as a parameter.
I tried using the following ObjDocument.PrintOut(,,,"drive\filename")
This saves the file but i am not able to open this file.. it is empty and giving an error on opening.

(ii) If i use
  ObjDocument.PrintOut() - This gives me an openable document, but askes for file name.

Please suggest how do i use and get the desired results.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

drgiridharanConnect With a Mentor Author Commented:
This works in VBA. I did make it work earlier and you would have got that from my original posting.

However, the same function PrintOut(... do not give the desired result. The file is created but when you try to open the file, you get an incompatible format message and contents are not displayed.

Currently i have given our client the following choices.

(i)    Write an VB activeX/application that is callable from asp - vbscript/Jascript.
(ii)   Buy a thirdparty component. (not yet decided).

Thanks for your help. But not able to take it as it does not work..
Try setting the PrintToFile parameter to True.

drgiridharanAuthor Commented:
It gives an error.
If i miss the first parameter as blank like
instead if i use objDocument.PrintOut(0,0,0.......) then it does not give error but still i am not able to open the doucment. When i try to open the document, it gives .. the document is not in the required format.
drgiridharanAuthor Commented:
Can yu give me the full code snippet that will work.
I can't reproduce your environment, but these two subs print to a file in VBA
Sub PrintDoc1(Doc As Document)
    Doc.PrintOut , , , "C:\MyPath\MyFile1.prn", , , , , , , True
End Sub
Sub PrintDoc2(Doc As Document)
    Doc.PrintOut OutputFileName:="C:\MyPath\MyFile2.prn", PrintToFile:=True
End Sub

Open in new window

All Courses

From novice to tech pro — start learning today.