Kaynağa Gözat

Updated .readme, package.json and core files.

tags/v1.0.0
Kalimuthu Selvaraj 5 yıl önce
ebeveyn
işleme
119b6e293a

+ 3
- 3
README.md Dosyayı Görüntüle

@@ -1,6 +1,6 @@
# convert-pdf-img

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

## Dependencies

@@ -15,8 +15,8 @@ const document = require("./convert");

const options = {
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",
sourceFile: "C:\\convert-pdf-img\\sample.pptx", // .ppt, .pptx, .odp, .key and .pdf
outputDir: "C:\\convert-pdf-img\\output",
img: false,
imgExt: "jpg", // Default value png
reSize: 800, // Default Resize is 1200

+ 11
- 1
convert.js Dosyayı Görüntüle

@@ -33,7 +33,9 @@ function libreOffice(libreofficeBin, callback) {
break;
default:
return callback(
new Error(`Operating system not yet supported: ${process.platform}`)
new Error(
`Operating system not yet supported to convert process: ${process.platform}`
)
);
}

@@ -97,6 +99,14 @@ function run(librePath, cmd, convert) {
});
}

function pathExist(outputPath, callback) {
fs.access(outputPath, fs.constants.F_OK, (err) => {
if (err) {
return callback(new Error("Source file does not exist."));
}
});
}

exports.convert = (
{ libreofficeBin, sourceFile, outputDir, img, imgExt, reSize, density },
callback

+ 15
- 8
package.json Dosyayı Görüntüle

@@ -1,10 +1,10 @@
{
"name": "slide-pdf-image",
"name": "document-convert",
"version": "1.0.0",
"description": "The package export ppt, pptx, odp and key to pdf and/or img[png, jpg, jpeg].",
"description": "The package export ppt, pptx, odp and key files to pdf and/or img(png, jpg, jpeg and etc...).",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha --reporter spec"
},
"keywords": [
"ppt to pdf and/or image",
@@ -12,18 +12,25 @@
"keynote to pdf and/or image",
"odp to pdf and/or image",
"ppt convert to pdf",
"pdf to image",
"imagemagick",
"ghostscript"
"ghostscript",
"libreoffice"
],
"author": "Kalimuthu Selvaraj",
"author": {
"name": "Kalimuthu Selvaraj",
"email": "kaalee6@gmail.com",
"url": "https://github.com/kalimuthu-selvaraj"
},
"license": "ISC",
"dependencies": {
"async": "^3.2.0",
"office-to-pdf": "^4.0.0",
"pptx2pdf": "^1.0.10"
"async": "^3.2.0"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^7.2.0"
},
"engines": {
"node": ">=6"
}
}

+ 2
- 2
sample.js Dosyayı Görüntüle

@@ -2,8 +2,8 @@ const document = require("./convert");

const options = {
libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe",
sourceFile: "C:\\convert-pdf-img\\metro_powerpoint.pptx",
outputDir: "abc",
sourceFile: "/home/convert/source/metro_powerpoint.pptx",
outputDir: "C:\\convert-pdf-img\\files\\",
img: true,
imgExt: "jpg",
reSize: 800,

file_example_ODP_1MB.odp → source/file_example_ODP_1MB.odp Dosyayı Görüntüle


metro_powerpoint.pptx → source/metro_powerpoint.pptx Dosyayı Görüntüle


random_color.key → source/random_color.key Dosyayı Görüntüle


sample.txt → source/sample.txt Dosyayı Görüntüle


+ 3
- 3
test/test.js Dosyayı Görüntüle

@@ -13,21 +13,21 @@ describe("Convert files to pdf or/and image", function () {
density: 120,
};
it("should return source file not exist", function () {
options.sourceFile = "C:\\convert-pdf-img\\metro_powerpoint.pptex";
options.sourceFile = "C:\\convert-pdf-img\\source\\metro_powerpoint.pptex";
var result = doc.convert(options, function (err) {
expect(err.message).to.equal("Source file does not exist.");
});
});

it("should return invalid extesion", function () {
options.sourceFile = "C:\\convert-pdf-img\\sample.txt";
options.sourceFile = "C:\\convert-pdf-img\\source\\sample.txt";
var result = doc.convert(options, function (err) {
expect(err.message).to.equal("Invalid extension.");
});
});

it("should return error on image conversion process", function () {
options.sourceFile = "C:\\convert-pdf-img\\metro_powerpoint.pptx";
options.sourceFile = "C:\\convert-pdf-img\\source\\metro_powerpoint.pptx";
options.outputDir = "abc";
var result = doc.convert(options, function (err) {
expect(err.message).to.equal("Error on image conversion process.");

Loading…
İptal
Kaydet