1.0.3 • Published 7 months ago

doc-to-pdf-converter v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

doc-to-pdf-converter

Description

doc-to-pdf-converter is a Node.js-based application that recursively converts all .doc and .docx files in a specified folder and its subdirectories to PDF. The application ensures all Microsoft Word instances are terminated before the conversion process starts, and provides detailed logging throughout the process. This package tested only on Windows OS, not yet tested on Linux or MacOS

Features

  1. Recursively converts .doc and .docx files to PDF

  2. Handles subdirectories

  3. Terminates all running Microsoft Word instances before starting the conversion

  4. Provides detailed logging with timestamps and process times

  5. Skips temporary Word files to avoid errors

Requirements

  1. Node.js(v14 or higher)

  2. npm (Node Package Manager)

  3. Microsoft Word (for the VBScript to interact with)

  4. Windows OS (Not tested on Linux or MacOS)

Installation

Globally:

  • Install globally if you plan to use it directly from Command line:
npm install -g doc-to-pdf-converter

Locally:

  • Install locally to a project to use it within your project:
npm i doc-to-pdf-converter

Executable

  • You can create executable file (.exe) to use it from any place on your local directory or other devices, in package.json => pkg => targets keep the target OS for your executable file and remove others, then run the following command:
npm run pack
  • .exe file will be created in the root directory,use the .exe file any place you want from the command line as follow:
doc-to-pdf-converter --input "path/to/input/folder" --output "path/to/output/folder" --log-level debug

Usage

Usage from command-line:

  • From command line run:
node build/index.js --input "path/to/input/folder" --output "path/to/output/folder" --log-level debug

import convert2PDF from 'doc-to-pdf-converter';

async () => {
	const result = await convert2PDF(
		false,
		true,
		'path-to-input-folder',
		'path-to-output-folder',
		'<log-level> (default "info")',
		'path-to-log-file(default"Output folder")'
	);
};

Command-line options:

  • --input, -i: Input directory path (required)

  • --output, -o: Output directory path (default: ./exported)

  • --log-level, -ll: Log level (info, debug, warn; default: info)

  • --log-file, -lf: Log file path (default: ./convert-.log)

Example

node build/index.js --input "C:\path\to\input\folder" --output "C:\path\to\output\folder" --log-level debug --log-file "./logs/convert.log"

Project Structure

doc-to-pdf-converter/ ├── src/ │ ├── index.js │ ├── convertDocToPdf.js | |── ConsoleColorLogger.ts ├── assets/ │ ├── script.vbs |── Types/ | |── types.d.ts | |── global.d.ts ├── package.json ├── README.md ├── tsconfig.json

Logging

The application provides detailed logs with timestamps and process times. Logs can be saved to a file or printed to the console.

Contributing

Contributions are welcome! Please submit a pull request or open an issue for any suggestions or improvements.

License

This project is licensed under the ISC License.

Author

Mustafa Heidar

Repository

You can find the GitHub repository for this project at: doc-to-pdf-converter

Changelog

v1.0.1-v1.0.2

  • Updated dependencies to the latest versions.
  • Fixed issues with logging to console and file.
  • Improved error handling during the conversion process.
  • Fixed output directory structure, now all created filed are grouped into one directory without any subdirectories.
  • Fixed issue with created files extension, now original file extension is removed from the file name.
  • VBS script will be created by the application if not exists, in case the app is running from pkg, the created temp_script.vbs will be removed once finished, however if app is running from node the created script will remain in the assets folder.
  • Managed log levels accordingly.
  • Quiet and no logging mode feature.
  • Fixed types declarations error, currently all types are properly defined
1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago