Skip to content
This repository has been archived by the owner on Sep 10, 2019. It is now read-only.

Commit

Permalink
implemented pdfmake-browser
Browse files Browse the repository at this point in the history
  • Loading branch information
ardean committed Feb 26, 2016
1 parent 85fd981 commit 97df2fd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
4 changes: 2 additions & 2 deletions demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ const profile = {
};

const pdf = simpleReminder(invoice, reminder, profile);
pdf.getBase64((data) => {
$("iframe").attr("src", `data:application/pdf;base64,${data}`);
pdf.getDataUrl({}, (data) => {
$("iframe").attr("src", data);
});
24 changes: 11 additions & 13 deletions dist/pdf-reminder-simple.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("roboto-base64"), require("pdfmake/build/pdfmake"));
module.exports = factory(require("pdfmake-browser"), require("roboto-buffer"));
else if(typeof define === 'function' && define.amd)
define(["roboto-base64", "pdfmake/build/pdfmake"], factory);
define(["pdfmake-browser", "roboto-buffer"], factory);
else {
var a = typeof exports === 'object' ? factory(require("roboto-base64"), require("pdfmake/build/pdfmake")) : factory(root["roboto-base64"], root["pdfmake/build/pdfmake"]);
var a = typeof exports === 'object' ? factory(require("pdfmake-browser"), require("roboto-buffer")) : factory(root["pdfmake-browser"], root["roboto-buffer"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__) {
Expand Down Expand Up @@ -60,20 +60,16 @@ return /******/ (function(modules) { // webpackBootstrap
value: true
});

var _robotoBase = __webpack_require__(1);
var _pdfmakeBrowser = __webpack_require__(1);

var _robotoBase2 = _interopRequireDefault(_robotoBase);
var _pdfmakeBrowser2 = _interopRequireDefault(_pdfmakeBrowser);

var _pdfmake = __webpack_require__(2);
var _robotoBuffer = __webpack_require__(2);

var _pdfmake2 = _interopRequireDefault(_pdfmake);
var _robotoBuffer2 = _interopRequireDefault(_robotoBuffer);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

window.pdfMake = {
vfs: _robotoBase2.default
};

var defaultStyle = {
fontSize: 10
};
Expand Down Expand Up @@ -121,10 +117,12 @@ return /******/ (function(modules) { // webpackBootstrap
};

exports.default = function (invoice, reminder, profile) {
return _pdfmake2.default.createPdf(getDoc(invoice, reminder, profile));
return new _pdfmakeBrowser2.default(getTemplate(invoice, reminder, profile), {
Roboto: _robotoBuffer2.default
});
};

function getDoc(invoice, reminder, profile) {
function getTemplate(invoice, reminder, profile) {
var organizationSettings = profile.organizationSettings;
var address = organizationSettings.address;
var billingAddress = invoice.billingAddress;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pdf-reminder-simple",
"description": "A simple pdf reminder template",
"version": "0.1.0",
"version": "0.1.1",
"author": "Orbin",
"keywords": [
"pdf",
Expand All @@ -15,8 +15,8 @@
"main": "dist/pdf-reminder-simple.js",
"license": "MIT",
"dependencies": {
"pdfmake": "orbin-ch/pdfmake#fix-webpack-win",
"roboto-base64": "^0.1.1"
"pdfmake-browser": "^0.2.0",
"roboto-buffer": "^0.1.0"
},
"devDependencies": {
"babel-core": "^6.4.0",
Expand Down
14 changes: 6 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import roboto from "roboto-base64";
import pdfMake from "pdfmake/build/pdfmake";

window.pdfMake = {
vfs: roboto
};
import Pdf from "pdfmake-browser";
import robotoFont from "roboto-buffer";

const defaultStyle = {
fontSize: 10
Expand Down Expand Up @@ -62,10 +58,12 @@ const footerLayout = {
};

export default (invoice, reminder, profile) => {
return pdfMake.createPdf(getDoc(invoice, reminder, profile));
return new Pdf(getTemplate(invoice, reminder, profile), {
Roboto: robotoFont
});
};

function getDoc(invoice, reminder, profile) {
function getTemplate(invoice, reminder, profile) {
const organizationSettings = profile.organizationSettings;
const address = organizationSettings.address;
const billingAddress = invoice.billingAddress;
Expand Down

0 comments on commit 97df2fd

Please sign in to comment.