//获取xml
InputStream stream = repositoryService.getProcessModel(processDefinitionId);
String result = IOUtils.toString(stream, StandardCharsets.UTF_8);// 创建 XMLInputFactory
XMLInputFactory factory = XMLInputFactory.newInstance();// 从字符串创建 XMLStreamReader
XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(result));BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(reader);
final ProcessDiagramGenerator diagramGenerator =
processEngineConfiguration.getProcessDiagramGenerator();// 使用Flowable的内置方法生成SVG图像
InputStream svgImage = diagramGenerator.generateJpgDiagram(bpmnModel);ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = svgImage.read(buffer, 0, 1024)) != -1) {
out.write(buffer, 0, len);
}byte[] pngBytes = out.toByteArray();
String base64= Base64.getEncoder().encodeToString(pngBytes);
flowable 根据xml 字符串生成流程图
于 2024-09-02 11:34:48 首次发布