Last active
September 20, 2024 04:11
-
-
Save jfdeclercq/bafb9ddd617a65d4de8453d69cea53be to your computer and use it in GitHub Desktop.
Export View as image (PNG) with date and diagram name in filename. #jarchi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Export View as image (PNG) with date and diagram name in filename. | |
// Get the first view in the model | |
//var view = $("view").first(); | |
var view = selection.filter("archimate-diagram-model").first(); | |
// Get the Base64 bytes of the view in PNG format. Can use "PNG", "BMP", "JPG" or "GIF" | |
// Options are scale (1 - 4) and margin (pixel value) | |
var bytes = $.model.renderViewAsBase64(view, "JPG", {scale: 1, margin: 20}); | |
var date = new Date(); | |
// Ask for a file name | |
var fileName = window.promptSaveFile( { title: "Save View", filterExtensions: [ "*.jpg" ], fileName: ""+ date.toISOString().replace(":","").replace("T","-").slice(0,15)+ "-" + view.name + ".jpg" } ); | |
if(fileName) { | |
// Write to file | |
$.fs.writeFile(fileName, bytes, "BASE64"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
just for sharing, based on a post on the archimatetool forum, I wrote:
Thanks for your original idea,
Regards,