Skip to content

Instantly share code, notes, and snippets.

@aregee
Created November 3, 2015 08:15
Show Gist options
  • Save aregee/2fa24a75907de8dbe2e2 to your computer and use it in GitHub Desktop.
Save aregee/2fa24a75907de8dbe2e2 to your computer and use it in GitHub Desktop.
app.get(/(.*\.pdf)\/([0-9]+).png$/i, function (req, res) {
var pdfPath = req.params[0];
var pageNumber = req.params[1];
var PDFImage = require("pdf-image").PDFImage;
var pdfImage = new PDFImage(pdfPath);
pdfImage.convertPage(pageNumber).then(function (imagePath) {
res.sendFile(imagePath);
}, function (err) {
res.send(err, 500);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment