Activiti 5.16 流程图片生成的中文乱码问题

工作流引擎activiti5.16,绘制的流程图中文乱码问题。

解决方法一:

1.在activiti.cfg.xml增加配置

?
1
2
3
< property  name = "activityFontName"  value = "宋体" />
< property  name = "labelFontName"  value = "宋体" />

2.中文乱码,研究了一下源码,发现居然不设置参数,直接调用png方法,字体就是默认的Arial字体,郁闷了半天,不想改原始程序,又找到个稍微麻烦点的方法

?
1
2
3
4
5
processEngine.getProcessEngineConfiguration().getProcessDiagramGenerator()
     .generateDiagram(bpmnModel,  "png"
                      processEngine.getProcessEngineConfiguration().getActivityFontName(),
                      processEngine.getProcessEngineConfiguration().getLabelFontName(), 
                      processEngine.getProcessEngineConfiguration().getClassLoader(), 1.0 );


解决方法二:

1.复制源码org.activiti.image.impl.DefaultProcessDiagramCanvas,在工程下新增此类,并把修改变量。

  protected String activityFontName = "宋体";
  protected String labelFontName = "宋体";

解决方法三:

1.在获取活动节点的流程图时用方法:

    	ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
    	ExecutionEntity executionEntity = executionEntityManager.findExecutionById(processInstanceId);
    	List activiityIds = executionEntity.findActiveActivityIds();
    	String processDefinitionId = executionEntity.getProcessDefinitionId();

    	GetBpmnModelCmd getBpmnModelCmd = new GetBpmnModelCmd(processDefinitionId);
    	BpmnModel bpmnModel = getBpmnModelCmd.execute(commandContext);

    	ProcessDiagramGenerator procDiaGenerator = new DefaultProcessDiagramGenerator();
    	InputStream is = procDiaGenerator.generateDiagram(
    			bpmnModel, 
    			"png", 
    			activiityIds, 
    			new ArrayList(), 
    			"宋体", 
    			"宋体", 
    			null, 
    			1.0);


你可能感兴趣的:(activiti工作流)