Преглед на файлове

Updated .readme file and added default ext into image conversion.

tags/v1.0.0
Kalimuthu Selvaraj преди 5 години
родител
ревизия
55cd61b936
променени са 2 файла, в които са добавени 11 реда и са изтрити 23 реда
  1. 8
    20
      README.md
  2. 3
    3
      convert.js

+ 8
- 20
README.md Целия файл

@@ -1,10 +1,11 @@
# convert-pdf-img

Converts `.ppt,` `.pptx`, `.odp` and `.key` to `pdf or/and image(png, jpg, jpeg)`
Converts `.ppt,` `.pptx`, `.odp` and `.key` file to `pdf or/and image(png, jpg, jpeg, etc)`

## Dependencies

Please install libreoffice, imagemagick and might required ghostscript for Mac os
**(Note: Please do restart after installed all required software.)**

## Usage Example

@@ -12,27 +13,14 @@ Please install libreoffice, imagemagick and might required ghostscript for Mac o
// Import convert module
const document = require("./convert");

// `.ppt,` `.pptx`, `.odp` and `.key` to pdf and/or image convert options
const options = {
libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe", // This is optional if it is null it will find default installation path inn your OS
sourceFile: "C:\\convert-pdf-img\\sample.pptx",
outputDir: "C:\\convert-pdf-img\\abc",
libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe", // Optional
sourceFile: "C:\\convert-pdf-img\\sample.pptx", // `.ppt,` `.pptx`, `.odp`, `.key` and `.pdf`
outputDir: "C:\\convert-pdf-img\\sample",
img: true,
imgExt: "jpg",
reSize: 800,
density: 120,
};

// Document (`.ppt,` `.pptx`, `.odp` and `.key`) to pdf and/or image convert options

const options = {
libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe", // This is optional if it is null it will find default installation path inn your OS
sourceFile: "C:\\convert-pdf-img\\sample.pdf",
outputDir: "C:\\convert-pdf-img\\",
img: true,
imgExt: "jpg",
reSize: 800,
density: 120,
imgExt: "jpg", // Optional and Default image conversion format is.png
reSize: 800, // Optional and Default Resize is 1200
density: 120, // Optional and Default density value is 120
};

// Convert document to pdf and/or image

+ 3
- 3
convert.js Целия файл

@@ -108,7 +108,7 @@ exports.convert = (
const baseFileName = path.basename(sourceFile);
const outputFile = baseFileName.replace(/\.[^.]+$/, ".pdf");

const outputImg = outputFile.replace(/\.pdf$/, `-%d.${imgExt}`);
const outputImg = outputFile.replace(/\.pdf$/, `-%d.${imgExt || "png"}`);

const ext = path.extname(sourceFile.toLowerCase());
const extensions = [".pdf", ".pptx", ".ppt", ".odp", ".key"];
@@ -147,7 +147,7 @@ exports.convert = (

fs.access(sourceFile, fs.constants.F_OK, (err) => {
if (err) {
return callback(new Error("Source File does not exist."));
return callback(new Error("Source file does not exist."));
} else {
if (extensions.includes(ext)) {
run(res, pdf, "pdf").then((pdfRes) => {
@@ -170,7 +170,7 @@ exports.convert = (
}
});
} else {
return callback(new Error("Extension does not support."));
return callback(new Error("Invalid extension."));
}
}
});

Loading…
Отказ
Запис