function fixPageMargins(margin) {
	    if (!margin) return null;

	    if (typeof margin === 'number' || margin instanceof Number) {
	        margin = { left: margin, right: margin, top: margin, bottom: margin };
	    } else if (margin instanceof Array) {
	        if (margin.length === 2) {
	            margin = { left: margin[0], top: margin[1], right: margin[0], bottom: margin[1] };
	        } else if (margin.length === 4) {
	            margin = { left: margin[0], top: margin[1], right: margin[2], bottom: margin[3] };
	        } else throw 'Invalid pageMargins definition';
	    }

	    return margin;
	}
Executes layout engine for the specified document and renders it into a pdfkit document
ready to be saved.

@param {Object} docDefinition document definition
@param {Object} docDefinition.content an array describing the pdf structure (for more information take a look at the examples in the /examples folder)
@param {Object} [docDefinition.defaultStyle] default (implicit) style definition
@param {Object} [docDefinition.styles] dictionary defining all styles which can be used in the document
@param {Object} [docDefinition.pageSize] page size (pdfkit units, A4 dimensions by default)
@param {Number} docDefinition.pageSize.width width
@param {Number} docDefinition.pageSize.height height
@param {Object} [docDefinition.pageMargins] page margins (pdfkit units)

@example

var docDefinition = {
	content: [
		'First paragraph',
		'Second paragraph, this time a little bit longer',
		{ text: 'Third paragraph, slightly bigger font size', fontSize: 20 },
		{ text: 'Another paragraph using a named style', style: 'header' },
		{ text: ['playing with ', 'inlines' ] },
		{ text: ['and ', { text: 'restyling ', bold: true }, 'them'] },
	],
	styles: {
		header: { fontSize: 30, bold: true }
	}
}

var pdfDoc = printer.createPdfKitDocument(docDefinition);

pdfDoc.pipe(fs.createWriteStream('sample.pdf'));
pdfDoc.end();

@return {Object} a pdfKit document object which can be saved or encode to data-url