/// <reference path="MarginMeasure.js"/>

global.PhantomPdfRenderer = function PhantomPdfRenderer(pageSize, orientation, margin, dpi, filepath) {
    this._pageSize = pageSize;
    this._orientation = orientation;
    this._margin = new MarginMeasure(margin);
    this._dpi = dpi;
    this._filepath = filepath;
};

PhantomPdfRenderer.prototype = {
    render: function (page) {
        var filename = this._filepath + '.pdf';
        page.paperSize = {
            format: this._pageSize,
            orientation: this._orientation,
            border: Measure.zero().toInches(),
            margin: this._margin.toInches(),
            dpi: this._dpi
        };
        page.viewportSize = {
            width: 10000,
            height: 10000
        };
        page.render(filename);
        return filename;
    }
};