소스 검색

Updated .readme, package.json and core files.

tags/v1.0.0
Kalimuthu Selvaraj 5 년 전
부모
커밋
119b6e293a
9개의 변경된 파일34개의 추가작업 그리고 17개의 파일을 삭제
  1. 3
    3
      README.md
  2. 11
    1
      convert.js
  3. 15
    8
      package.json
  4. 2
    2
      sample.js
  5. 0
    0
      source/file_example_ODP_1MB.odp
  6. 0
    0
      source/metro_powerpoint.pptx
  7. 0
    0
      source/random_color.key
  8. 0
    0
      source/sample.txt
  9. 3
    3
      test/test.js

+ 3
- 3
README.md 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기


metro_powerpoint.pptx → source/metro_powerpoint.pptx 파일 보기


random_color.key → source/random_color.key 파일 보기


sample.txt → source/sample.txt 파일 보기


+ 3
- 3
test/test.js 파일 보기

@@ -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…
취소
저장