Skip to content

Commit 68514d3

Browse files
Merge pull request #3 from NBAMj/master
Get ImgUrl base64 encoded from canvas in PDFRenderer
2 parents e07e1ce + 8cc9284 commit 68514d3

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Within a controller's scope, you can bind the thumbnail settings to your scope v
4848
- `source`: URI (can be a data encoded URI) to the media to render.
4949
- `max-height`: Maximum height of the thumbnail in pixels.
5050
- `max-width`: Maximum width of the thumbnail in pixels.
51+
- `img-url`: Image URL base64 encoded. Use this to save the image in your backend as base64.
5152

5253
There currently is no way to set the actual height/width of the thumbnail. The values will calculated based on the
5354
dimensions of the rendered element, respecting the height/width ratio of the element.

dist/angular-thumbnails.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
page.render({
5454
canvasContext: canvas.getContext("2d"),
5555
viewport: page.getViewport(canvas.height / viewport.height, targetViewport.getRotation())
56+
}).then(function() {
57+
scope.imgUrl = canvas.toDataURL();
5658
});
5759
});
5860
};
@@ -108,7 +110,8 @@
108110
scale: "=",
109111
fileType: "@",
110112
maxHeight: "@",
111-
maxWidth: "@"
113+
maxWidth: "@",
114+
imgUrl: "="
112115
},
113116
link: function(scope, element, attrs) {
114117
var canvas = document.createElement("canvas"), renderer = null, renderFunc = function() {

dist/angular-thumbnails.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/angular-thumbnails.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
canvas.height / viewport.height,
8787
targetViewport.getRotation()
8888
)
89+
}).then(function(){
90+
scope.imgUrl = canvas.toDataURL();
8991
});
9092
});
9193
};
@@ -171,7 +173,8 @@
171173
'scale': '=',
172174
'fileType': '@',
173175
'maxHeight': '@',
174-
'maxWidth': '@'
176+
'maxWidth': '@',
177+
'imgUrl': "="
175178
},
176179
link: function (scope, element, attrs) {
177180
var canvas = document.createElement('canvas'),

0 commit comments

Comments
 (0)