image export of running diagram

cancel
Showing results for 
Search instead for 
Did you mean: 
ajeje93
Active Member II

image export of running diagram

Jump to solution

I would like to export the image of a BPMN diagram, getting the process definition from the process instance. I know that is possible to to the export of the XML in this way and using the repository service and I am wondering if it is also possible to export an image (png, jpg,...).

Thank in advance.

1 Solution

Accepted Solutions
daisuke-yoshimo
Senior Member

Re: image export of running diagram

Jump to solution

Thank you for your reply and your test code.
I see that you want to create a dynamic process and generate it's diagram image.

But, it is difficult to generate dynamic process's diagram because it have no graphic information like the following.
You should make the graphic information of dynamic process.

<bpmndi:BPMNDiagram id="BPMNDiagram_test">
<bpmndi:BPMNPlane bpmnElement="test" id="BPMNPlane_test">
<bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
<omgdc:Bounds height="35.0" width="35.0" x="70.0" y="170.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="task1" id="BPMNShape_task1">
<omgdc:Bounds height="55.0" width="105.0" x="180.0" y="160.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
<omgdc:Bounds height="35.0" width="35.0" x="370.0" y="170.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="105.0" y="187.0"></omgdi:waypoint>
<omgdi:waypoint x="180.0" y="187.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="285.0" y="187.0"></omgdi:waypoint>
<omgdi:waypoint x="370.0" y="187.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>

I have no idea to make the properly placed process diagram.
I maked the sample code that generate a process diagram aligned in line and made pull request to your repo.
https://github.com/ajeje93/activiti-processdiagramgenerator-test/pull/1
https://github.com/daisuke-yoshimoto/activiti-processdiagramgenerator-test/blob/master/ProcessDiagra...

View solution in original post

15 Replies
gdharley
Intermediate

Re: image export of running diagram

Jump to solution

If you know the Process Instance ID you can use the Diagram Viewer URL: Activiti User Guide - Process Instance Diagram 

If you are looking for the process definition diagram (no specific process instance), then you can follow the directions in the following stack overflow post: integrate the diagram viewer of activiti in webApp - Stack Overflow 

Cheers,

Greg

ajeje93
Active Member II

Re: image export of running diagram

Jump to solution

What if I am using normal Java and not Java EE? I mean, I have no TomCat or other web servers running at the moment and I would like my application not to rely on external stuff.

Thank you again.

gdharley
Intermediate

Re: image export of running diagram

Jump to solution

Not sure what you mean.

If you are not running a servlet container (i.e. no REST API) you can still use the deployer Java API to generate a diagram image with the image generator module.

Check out the source here: Activiti/ProcessDiagramGenerator.java at 15ab72410f151970ef264b0275232b19d6739a2e · Activiti/Activit... 

Greg

ajeje93
Active Member II

Re: image export of running diagram

Jump to solution

Thank you very much, I was looking for something like this

ajeje93
Active Member II

Re: image export of running diagram

Jump to solution

I'm sorry to bother you again, but i get the following error when trying to generate a diagram:

Exception in thread "main" java.lang.NullPointerException
 at org.activiti.image.impl.DefaultProcessDiagramGenerator.initProcessDiagramCanvas(DefaultProcessDiagramGenerator.java:817)
 at org.activiti.image.impl.DefaultProcessDiagramGenerator.generateProcessDiagram(DefaultProcessDiagramGenerator.java:477)
 at org.activiti.image.impl.DefaultProcessDiagramGenerator.generateDiagram(DefaultProcessDiagramGenerator.java:403)
 at org.activiti.image.impl.DefaultProcessDiagramGenerator.generateDiagram(DefaultProcessDiagramGenerator.java:408)
 at org.activiti.image.impl.DefaultProcessDiagramGenerator.generateJpgDiagram(DefaultProcessDiagramGenerator.java:451)
 at org.activiti.image.impl.DefaultProcessDiagramGenerator.generateJpgDiagram(DefaultProcessDiagramGenerator.java:447)

Do you know why this is happening?

daisuke-yoshimo
Senior Member

Re: image export of running diagram

Jump to solution

> Do you know why this is happening?

I cannot not identify the cause by your stack trace.
Perhaps,your bpmn xml don't have graphic info.<bpmndi:BPMNDiagram

If it is a code problem, you can get the running diagram by writing as follows.

BpmnModel bpmnModel = repositoryService.getBpmnModel(pde.getId());
ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
InputStream resource = diagramGenerator.generateDiagram(bpmnModel, "png", runtimeService.getActiveActivityIds(processInstance.getId()),
Collections.<String>emptyList(), processEngineConfiguration.getActivityFontName(), processEngineConfiguration.getLabelFontName(),
processEngineConfiguration.getAnnotationFontName(), processEngineConfiguration.getClassLoader(), 1.0);

https://github.com/Activiti/Activiti/blob/master/modules/activiti-rest/src/main/java/org/activiti/re...

I made the sample activiti project.

https://github.com/daisuke-yoshimoto/generateDiagram
https://github.com/daisuke-yoshimoto/generateDiagram/blob/master/src/main/java/generateDiagram/Gener...

ajeje93
Active Member II

Re: image export of running diagram

Jump to solution

Thank you, I think that is about graphic info because I generated the diagram using variables and not using an XML file.

Do you have any ideas on how to add automatically graphic info when one is not using the modeler plugin?

daisuke-yoshimo
Senior Member

Re: image export of running diagram

Jump to solution

I'm sorry that I have no idea.

Why do not you use xml?

Do not you want to create diagrams of process instances?

ajeje93
Active Member II

Re: image export of running diagram

Jump to solution

Yes, it's a little bit complicated. Long story short, my application has to dinamically create a diagram so I cannot use an XML file