|
/*
|
|
* Copyright (C) 2020 Maarch
|
|
*
|
|
* This file is part of Maarch RM.
|
|
*
|
|
* Maarch RM is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Bundle organization is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Maarch RM. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
var fileSystemObject = new ActiveXObject("Scripting.FileSystemObject");
|
|
var stdout = fileSystemObject.GetStandardStream(1);
|
|
var stderr = fileSystemObject.GetStandardStream(2);
|
|
|
|
var docFileName = WScript.Arguments(0);
|
|
docFileName = fileSystemObject.GetAbsolutePathName(docFileName);
|
|
|
|
var objWord = null;
|
|
|
|
try {
|
|
objWord = new ActiveXObject("Word.Application");
|
|
objWord.Visible = false;
|
|
|
|
var OutputFileName = docFileName.replace(/\.doc[^.]*$/, ".pdf");
|
|
var ExportFormat = 17; // WdExportFormat.wdExportFormatPDF;
|
|
var OpenAfterExport = false;
|
|
var OptimizeFor = 0; // WdExportOptimizeFor.WdExportOptimizeForPrint; // 0
|
|
var Range = 0; // WdExportRange.wdExportAllDocument; // 0
|
|
var from = 0;
|
|
var to = 0;
|
|
var Item = 0; //WdExportItem.wdExportDocumentContent; // 0
|
|
var IncludeDocProps = true;
|
|
var KeepIRM = false;
|
|
var CreateBookmarks = 0; // WdExportCreateBookmarks.wdExportCreateHeadingBookmarks; // 0
|
|
var DocStructureTags = true;
|
|
var BitmapMissingFonts = true;
|
|
var UseISO19005_1 = true;
|
|
var FixedFormatExtClassPtr = null;
|
|
|
|
var objDoc = objWord.Documents.Open(docFileName);
|
|
|
|
objDoc.ExportAsFixedFormat(OutputFileName, ExportFormat, OpenAfterExport, OptimizeFor, Range, from, to, Item, IncludeDocProps, KeepIRM, CreateBookmarks, DocStructureTags, BitmapMissingFonts, UseISO19005_1);
|
|
|
|
objDoc.Close();
|
|
|
|
WScript.StdOut.Write('coucou');
|
|
|
|
} finally {
|
|
if (objWord != null) {
|
|
objWord.Quit();
|
|
|
|
//stderr.WriteLine("An error occured during the conversion.");
|
|
}
|
|
}
|