Generate a png from an office document or from a pdf file.
Generate a png from an office document or from a pdf file. Also, it detect if it doesn't belong to this kind of file.
var DocumentPreview = require('machinepack-document-preview');
// Generate a png from an office document or from a pdf file.
DocumentPreview.generate({
from: '/pdf/document.pdf',
to: '/previews/preview.png',
mime: '/previews/',
}).exec({
// An unexpected error occurred.
error: function (err) {
},
noConvertion: function () {
},
// OK.
success: function () {
},
});
The file you want to convert.
'/pdf/document.pdf'
The directory where you want to put your preview.
'/previews/preview.png'
The content type of your initial file.
'/previews/'
An unexpected error occurred.
OK.