{oapdf_gg}
II: a virtual printer configuration into the Windows control panel, enter the printer, click on the "Add Printer" icon. in the installation dialog box on the "step", there choose the printer, in a column manufacturer Select "Generic", a column in the printer, select the "MS Publisher Color Printer", and then by the next step along the way that the end of the installation. three: the first began to write a program (script) Whyprocess using a script to convert it, in fact, the actual testing process, the use of PDF Distiller of the object reference to C # after a successful conversion, the PDF Distiller of the object can not be released, and the second conversion times and then when the error occurred, so here the realization of the conversion process using a script. so that we as long as the procedures in C # script in the call can be achieved WORD to PDF conversion. script host file name: ConvertDoc2PDF.js the contents of script file: var files = WScript.Arguments; var fso = new ActiveXObject ( "Scripting.FileSystemObject"); var word = new ActiveXObject ( "Word.Application"); var PDF = new ActiveXObject ( "PDFDistiller.PDFDistiller.1"); word.ActivePrinter = "MS Publisher Color Printer"; //files (0) as a WORD document file name //files (1) for the conversion after the need to preserve the path //call fso.GetBaseName (files (0)), to no path, no extension, the file name //files.length to document the number of parameters, the use of the cycle can support more than conversion WORD document var docfile = files (0); var psfile = files (1) + fso.GetBaseName (files (0)) + ". ps"; var pdffile = files (1) + fso.GetBaseName (files (0)) + ". pdf"; var logfile = files (1) + fso.GetBaseName (files (0)) + ". log"; try ( var doc = word.Documents.Open (docfile); //WORD documents into PS documents; word.PrintOut (false, false, 0, psfile); doc.Close (0); //PS files into PDF documents; PDF.FileToPDF (psfile, pdffile ,""); fso.GetFile (psfile). Delete ();// delete the PS script file fso.GetFile (logfile). Delete ();// convert to delete the log file word.Quit (); WScript.Echo ( "isuccess ");// success WScript.Quit (0); ) catch (x) ( word.Quit (); WScript.Echo ( "isfail ");// failure WScript.Quit (0); ) procedures and then test the script start MS-DOS, type the following command: c: \> cscript //nologo c:\ConvertDoc2PDF.js c:\test.doc c:\ Description: will see the successful operation of the test.pdf document c:\test.doc parameter is the corresponding script in the files (0) c:\parameters corresponding process is script files (1) you be able to read according to the script to support multiple parameters, use the FOR cycle, more than a conversion WORD document here do not use more than one file conversion is taken into account , the paragraph on the C # script in the implementation of the thread, so it can be converted more than WORD document. |