Copy an OrgChart as image to Clipboard
Copy OrgChart JS image to clipboard.
Have you ever wanted to quickly copy your organization chart and paste it into another app, like Slack, Word, or an email, as an image?
With OrgChart JS and the modern Clipboard API, you can do exactly that.
In this tutorial, you will export your chart as SVG, convert it to PNG, and copy it directly to the clipboard without downloading any files.
How it works
The flow is simple:
- Trigger chart export with
chart.exportToSVG(). - Intercept the export in
onExportStart. - Get SVG content from
args.pages[0]. - Convert SVG to PNG using a temporary canvas.
- Write the PNG blob with
navigator.clipboard.write.
Important notes
- Clipboard image write requires a secure context (
https://orlocalhost). - Browsers usually require this action to be triggered by a user gesture (button click).
- This approach copies a PNG image, so you can paste directly into chat tools and documents.
Summary
By combining OrgChart JS export events with the Clipboard API, you can add a smooth "Copy chart image" feature to your app in just a few lines of code.