Hey, I’m trying to fit several bpmn-viewer's in different div’s that are arranged using Bootstrap.css.
Although the import of the Bpmn files works without problems, the scaling is a challenge.
The approaches I tried so far:
(1) The use of fit-viewport, but it seems like that will only work for fullscreen viewers / divs:
bpmnViewer.get('canvas').zoom('fit-viewport')
(2) Calculate the zoom value by hand. However, the diagram is shifted to the middle and not drawn at (0,0), which results in the problem that the right side of the diagram is not visible:
// "width" holds the width of the canvas element
// "this.width" holds the width the imported bpmn-diagram
const width = document.getElementById(id).offsetWidth
bpmnViewer.get('canvas').zoom(width / this.width)
(3) Trying to move it manually afterwards:
bpmnViewer.get('canvas').scroll({ dx: -(width / 2), dy: -(height / 2) })
(4) The use of viewport, but scale was not set properly in my application:
bpmnViewer.get('canvas').viewbox({ x: 0, y: 0, width, height, scale: (width / this.width) })
Unfortunately, I got none of the above listed approaches working properly to fix my problem.
Did I miss something?
Thank you in advance for any help.




