本文主要是介绍flowable 根据xml 字符串生成流程图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
//获取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 字符串生成流程图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!