Introduce new option in SVGExport to not embed images.

Closes #696
This commit is contained in:
Jürg Lehni 2015-08-20 19:34:38 +02:00
parent 650bf5d616
commit 3dd0f1fc1b
3 changed files with 11 additions and 3 deletions

View file

@ -2087,6 +2087,9 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
* @option [options.matchShapes=false] {Boolean} whether path items should
* tried to be converted to SVG shape items (rect, circle, ellipse, line,
* polyline, polygon), if their geometries match
* @option [options.embedImages=true] {Boolean} whether raster images
* should be embedded as base64 data inlined in the xlink:href attribute,
* or kept as a link to their external URL.
*
* @param {Object} [options] the export options
* @return {SVGElement} the item converted to an SVG node

View file

@ -643,6 +643,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
* @option [options.matchShapes=false] {Boolean} whether path items should
* tried to be converted to SVG shape items (rect, circle, ellipse, line,
* polyline, polygon), if their geometries match
* @option [options.embedImages=true] {Boolean} whether raster images
* should be embedded as base64 data inlined in the xlink:href attribute,
* or kept as a link to their external URL.
*
* @param {Object} [options] the export options
* @return {SVGElement} the project converted to an SVG node

View file

@ -101,15 +101,17 @@ new function() {
return node;
}
function exportRaster(item) {
function exportRaster(item, options) {
var attrs = getTransform(item._matrix, true),
size = item.getSize();
size = item.getSize(),
image = item.getImage();
// Take into account that rasters are centered:
attrs.x -= size.width / 2;
attrs.y -= size.height / 2;
attrs.width = size.width;
attrs.height = size.height;
attrs.href = item.toDataURL();
attrs.href = options.embedImages === false && image && image.src
|| item.toDataURL();
return createElement('image', attrs);
}