Skip to content

Commit

Permalink
Merge pull request mooz#16 from dustinc/master
Browse files Browse the repository at this point in the history
Add setPdfFileBaseName
  • Loading branch information
mooz authored Jan 31, 2018
2 parents 122b837 + 1ed9e37 commit 65719c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function PDFImage(pdfFilePath, options) {
if (!options) options = {};

this.pdfFilePath = pdfFilePath;
this.pdfFileBaseName = path.basename(pdfFilePath, ".pdf");

this.setPdfFileBaseName(options.pdfFileBaseName);
this.setConvertOptions(options.convertOptions);
this.setConvertExtension(options.convertExtension);
this.useGM = options.graphicsMagick || false;
Expand Down Expand Up @@ -68,6 +68,9 @@ PDFImage.prototype = {
setConvertOptions: function (convertOptions) {
this.convertOptions = convertOptions || {};
},
setPdfFileBaseName: function(pdfFileBaseName) {
this.pdfFileBaseName = pdfFileBaseName || path.basename(this.pdfFilePath, ".pdf");
},
setConvertExtension: function (convertExtension) {
this.convertExtension = convertExtension || "png";
},
Expand Down
5 changes: 5 additions & 0 deletions tests/test-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ describe("PDFImage", function () {
it("should have correct basename", function () {
expect(pdfImage.pdfFileBaseName).equal("test");
});

it("should set custom basename", function() {
pdfImage.setPdfFileBaseName('custom-basename');
expect(pdfImage.pdfFileBaseName).equal("custom-basename");
});

it("should return correct page path", function () {
expect(pdfImage.getOutputImagePathForPage(1))
Expand Down

0 comments on commit 65719c1

Please sign in to comment.