DocumentPreview.generate()

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.

Usage

Hover over inputs/exits for more info.

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 () {

 

},

});

Inputs

from required

The file you want to convert.

'/pdf/document.pdf'
to required

The directory where you want to put your preview.

'/previews/preview.png'
mime required

The content type of your initial file.

'/previews/'

Exits

error

An unexpected error occurred.

noConvertion
success

OK.