Skip to content

Commit

Permalink
Merge pull request #3 from NBAMj/master
Browse files Browse the repository at this point in the history
Get ImgUrl base64 encoded from canvas in PDFRenderer
  • Loading branch information
fabre-thibaud authored Jul 19, 2018
2 parents e07e1ce + 8cc9284 commit 68514d3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Within a controller's scope, you can bind the thumbnail settings to your scope v
- `source`: URI (can be a data encoded URI) to the media to render.
- `max-height`: Maximum height of the thumbnail in pixels.
- `max-width`: Maximum width of the thumbnail in pixels.
- `img-url`: Image URL base64 encoded. Use this to save the image in your backend as base64.

There currently is no way to set the actual height/width of the thumbnail. The values will calculated based on the
dimensions of the rendered element, respecting the height/width ratio of the element.
5 changes: 4 additions & 1 deletion dist/angular-thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
page.render({
canvasContext: canvas.getContext("2d"),
viewport: page.getViewport(canvas.height / viewport.height, targetViewport.getRotation())
}).then(function() {
scope.imgUrl = canvas.toDataURL();
});
});
};
Expand Down Expand Up @@ -108,7 +110,8 @@
scale: "=",
fileType: "@",
maxHeight: "@",
maxWidth: "@"
maxWidth: "@",
imgUrl: "="
},
link: function(scope, element, attrs) {
var canvas = document.createElement("canvas"), renderer = null, renderFunc = function() {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-thumbnails.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/angular-thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
canvas.height / viewport.height,
targetViewport.getRotation()
)
}).then(function(){
scope.imgUrl = canvas.toDataURL();
});
});
};
Expand Down Expand Up @@ -171,7 +173,8 @@
'scale': '=',
'fileType': '@',
'maxHeight': '@',
'maxWidth': '@'
'maxWidth': '@',
'imgUrl': "="
},
link: function (scope, element, attrs) {
var canvas = document.createElement('canvas'),
Expand Down

0 comments on commit 68514d3

Please sign in to comment.