Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Options to control bounding box in SVG Export. #972

Open
lehni opened this issue Feb 14, 2016 · 3 comments
Open

Feature: Options to control bounding box in SVG Export. #972

lehni opened this issue Feb 14, 2016 · 3 comments

Comments

@lehni
Copy link
Member

lehni commented Feb 14, 2016

By default Project#exportSVG() exports the SVG content exactly the way it is seen in the current view, including the view's size, scroll and zoom factor. This is not always the desired behavior.

I'd like to propose to implement these additional features:

  • options.bounds:
    • 'view': the current behavior, and the default.
    • 'content': the strokeBounds of the project content (all layers)
    • Rectangle: a rectangle specifying the bounding box to be used in the SVG output, in project coordinates.
    • null: When explicitly set to null, no bounds are used, the SVG contains now size information.
  • options.matrix:
    • When nothing is specified and options.bounds is 'view', the view's transformation matrix reflecting, zooming and scrolling is used.
    • When it is set to a matrix, this matrix is used to transform the exported content.
    • When nothing is set, and options.bounds is not 'view', no additional transformations are applied.

Does this naming make sense? Is anything missing?

lehni added a commit that referenced this issue Feb 14, 2016
And use it to support SvgExport unit tests. Relates to #972
@lehni
Copy link
Member Author

lehni commented Feb 14, 2016

I have implemented this in 6f4890c
The naming can still change, and documentation is missing.

@lehni lehni added this to the v1.0.0 milestone Feb 14, 2016
@lilltiger
Copy link

How about adding:

options.bounds:
'item' : the stroke bounds of the item that is exported.

@lukefeld
Copy link

lukefeld commented Jun 9, 2022

@lehni I'm currently using the following code:

var boundsArtboard = new Rectangle({x:10,y:10, width:100, height:100});
var svg = paper.project.exportSVG({asString:true,precision: 5, bounds:boundsArtboard});

When I view the exported SVG in a web browser it appears correctly. However, if I open this SVG file in Illustrator, the SVG file contains all objects that exist on that currently layer. See attached SVG image example. How do I just export the objects in the bounds and not everything on the layer? Thanks

image0
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants