From a13b905dfb2f305d9ce20efec7891c2f9100a9e0 Mon Sep 17 00:00:00 2001 From: Andrey Ustyuzhanin Date: Sun, 18 Sep 2016 21:50:18 +0300 Subject: [PATCH] zero-padding slide numbers --- decktape.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/decktape.js b/decktape.js index 7883916..4e59a6f 100644 --- a/decktape.js +++ b/decktape.js @@ -321,7 +321,12 @@ function exportSlide(plugin) { // e.g. for impress.js (may be needed to be configurable) .then(delay(1000)) .then(function () { - page.render(options.screenshotDirectory + '/' + options.filename.replace('.pdf', '_' + plugin.currentSlide + '_' + resolution.width + 'x' + resolution.height + '.' + options.screenshotFormat), { onlyViewport: true }); + function paddedSlideNum() { + width = Math.ceil(Math.log(plugin.totalSlides + 1)/Math.log(10)) + n = plugin.currentSlide + ''; + return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n; + }; + page.render(options.screenshotDirectory + '/' + options.filename.replace('.pdf', '_' + paddedSlideNum() + '_' + resolution.width + 'x' + resolution.height + '.' + options.screenshotFormat), { onlyViewport: true }); }) }, decktape) .then(function () { page.viewportSize = options.size })