Bladeren bron

Updated .readme, package.json and core files.

tags/v1.0.0
Kalimuthu Selvaraj 5 jaren geleden
bovenliggende
commit
119b6e293a
9 gewijzigde bestanden met toevoegingen van 34 en 17 verwijderingen
  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 Bestand weergeven

# convert-pdf-img # 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 ## Dependencies




const options = { const options = {
libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe", // Optional 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, img: false,
imgExt: "jpg", // Default value png imgExt: "jpg", // Default value png
reSize: 800, // Default Resize is 1200 reSize: 800, // Default Resize is 1200

+ 11
- 1
convert.js Bestand weergeven

break; break;
default: default:
return callback( return callback(
new Error(`Operating system not yet supported: ${process.platform}`)
new Error(
`Operating system not yet supported to convert process: ${process.platform}`
)
); );
} }


}); });
} }


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 = ( exports.convert = (
{ libreofficeBin, sourceFile, outputDir, img, imgExt, reSize, density }, { libreofficeBin, sourceFile, outputDir, img, imgExt, reSize, density },
callback callback

+ 15
- 8
package.json Bestand weergeven

{ {
"name": "slide-pdf-image",
"name": "document-convert",
"version": "1.0.0", "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", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha --reporter spec"
}, },
"keywords": [ "keywords": [
"ppt to pdf and/or image", "ppt to pdf and/or image",
"keynote to pdf and/or image", "keynote to pdf and/or image",
"odp to pdf and/or image", "odp to pdf and/or image",
"ppt convert to pdf", "ppt convert to pdf",
"pdf to image",
"imagemagick", "imagemagick",
"ghostscript"
"ghostscript",
"libreoffice"
], ],
"author": "Kalimuthu Selvaraj",
"author": {
"name": "Kalimuthu Selvaraj",
"email": "kaalee6@gmail.com",
"url": "https://github.com/kalimuthu-selvaraj"
},
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"async": "^3.2.0",
"office-to-pdf": "^4.0.0",
"pptx2pdf": "^1.0.10"
"async": "^3.2.0"
}, },
"devDependencies": { "devDependencies": {
"chai": "^4.2.0", "chai": "^4.2.0",
"mocha": "^7.2.0" "mocha": "^7.2.0"
},
"engines": {
"node": ">=6"
} }
} }

+ 2
- 2
sample.js Bestand weergeven



const options = { const options = {
libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe", 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, img: true,
imgExt: "jpg", imgExt: "jpg",
reSize: 800, reSize: 800,

file_example_ODP_1MB.odp → source/file_example_ODP_1MB.odp Bestand weergeven


metro_powerpoint.pptx → source/metro_powerpoint.pptx Bestand weergeven


random_color.key → source/random_color.key Bestand weergeven


sample.txt → source/sample.txt Bestand weergeven


+ 3
- 3
test/test.js Bestand weergeven

density: 120, density: 120,
}; };
it("should return source file not exist", function () { 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) { var result = doc.convert(options, function (err) {
expect(err.message).to.equal("Source file does not exist."); expect(err.message).to.equal("Source file does not exist.");
}); });
}); });


it("should return invalid extesion", function () { 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) { var result = doc.convert(options, function (err) {
expect(err.message).to.equal("Invalid extension."); expect(err.message).to.equal("Invalid extension.");
}); });
}); });


it("should return error on image conversion process", function () { 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"; options.outputDir = "abc";
var result = doc.convert(options, function (err) { var result = doc.convert(options, function (err) {
expect(err.message).to.equal("Error on image conversion process."); expect(err.message).to.equal("Error on image conversion process.");

Laden…
Annuleren
Opslaan