getAttachmentPositionsInExpImage

getAttachmentPositionsInExpImage Method

Description

Returns the positions of attachment symbols in the current diagram within the bounds of an exported image.

.getAttachmentPositionsInExpImage(/* Object */ options)

Parameters

options Object

An object containing the option that were used to create the exported image. For more information, see the exportImage method.

Returns

Array

An array of objects that each contain the location of an attachment symbol within an exported image generated with the specified options.

Each of these objects is a hash of the form:

Note that all coordinates are in pixels relative to the top left corner of the exported image with positive values down and right.

Example — Export a PNG Image and Get Attachment Locations

/*
    This example assumes editor is an initialized
    ESDWeb object and that a diagram is loaded
*/
 
// Export the diagram as a png image.
var exportOptions = {
    format: 'image/png',
    margin: 10,
    width: 800,
    height: 600,
    includeFieldMeasurements: true
};
 
editor.exportImage(exportOptions, onExport, onError);
 
function onExport(image) {
    // The export was successful...
    // The parameter "image" contains a 800 x 600 base 64
    // encoded PNG image of the diagram.
    // Any operations that depend on the exported image must
    // be done within the body of this callback function.
 
    // Get the attachment positions in the exported image. Note that we must use the same
    // options that were used to create the image.
    var attachmentPositions = editor.getAttachmentPositionsInExpImage(exportOptions);
 
    // Both the image and the positions of attachment symbols in the image are now available.
    ...
}
 
function onError(error) {
    alert('Export failed: ' + error.message;
}