draw-image-export2 icon indicating copy to clipboard operation
draw-image-export2 copied to clipboard

Support export to svg

Open laingsimon opened this issue 6 years ago • 6 comments

Would be useful support converting a diagram to SVG format.

It is possible to export to a raster (PNG or jpg) or a vector (pdf), but not a vector format that can be natively displayed within a webpage (like a PNG can).

This is possible if the diagram can be exported in svg+xml format.

Should be possible to achieve this in the section of export.js where the PNG/jpg image is extracted (albeit via a screenshot).

The diagram can be exported to svg in draw.io so should be possible to include this logic here, if not possible to retrieve the SVG data as it stands.

laingsimon avatar May 12 '19 20:05 laingsimon

Could the desktop version command line not be used, instead?

davidjgraph avatar Aug 02 '19 08:08 davidjgraph

@davidjgraph

Could the desktop version command line not be used, instead?

I'm trying to display a SVG image within a webpage, so wouldn't be possible without another service running somewhere.

sl-slaing avatar Dec 26 '19 09:12 sl-slaing

Could the desktop version command line not be used, instead?

Is this possible ? Is the CLI described somewhere ? I'm looking to programmatically convert .drawio files to .svg (or even .png) ones. However I have found little to no document about how to do this.

Adirelle avatar Apr 30 '20 12:04 Adirelle

draw.io --help Usage: draw [options] [input file/folder]

Options: -V, --version output the version number -c, --create creates a new empty file if no file is passed -k, --check does not overwrite existing files -x, --export export the input file/folder based on the given options -r, --recursive for a folder input, recursively convert all files in sub-folders also -o, --output <output file/folder> specify the output file/folder. If omitted, the input file name is used for output with the specified format as extension -f, --format if output file name extension is specified, this option is ignored (file type is determined from output extension, possible export formats are pdf, png, jpg, svg, vsdx) (default: "pdf") -q, --quality output image quality for JPEG (default: 90) -t, --transparent set transparent background for PNG -e, --embed-diagram includes a copy of the diagram (for PNG format only) -b, --border sets the border width around the diagram (default: 0) -s, --scale scales the diagram size --width fits the generated image/pdf into the specified width, preserves aspect ratio. --height fits the generated image/pdf into the specified height, preserves aspect ratio. --crop crops PDF to diagram size -a, --all-pages export all pages (for PDF format only) -p, --page-index <pageIndex> selects a specific page, if not specified and the format is an image, the first page is selected -g, --page-range .. selects a page range (for PDF format only) -h, --help display help for command

alderg avatar Apr 30 '20 13:04 alderg

Thank you. Is there a way do it using node only instead of the full electron build ?

Adirelle avatar May 01 '20 22:05 Adirelle

FYI - I have built a docker container that exposes drawio Desktop (including the SVG export capability) as a RESTful API:

https://hub.docker.com/r/tomkludy/drawio-renderer

Hopefully this can be of help to others; it is already functioning in my own build pipeline.

tomkludy avatar Sep 13 '20 21:09 tomkludy

Thanks for the suggestion. Unfortunately, we're not going to implement this. The problem we've been seeing with feature that we implement but don't actively use is the code just rots and breaks. @tomkludy 's solution looks like a good workaround.

davidjgraph avatar Sep 22 '23 10:09 davidjgraph