spring boot 整合activiti5.22 部署到linux 查看流程图是乱码

1、在Spring boot 中配置activiti使用宋体

@Bean
    public ProcessEngineConfiguration processEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager) {
        SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
        processEngineConfiguration.setDataSource(dataSource);
        processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE);
        processEngineConfiguration.setDatabaseType(ProcessEngineConfigurationImpl.DATABASE_TYPE_MYSQL);

        processEngineConfiguration.setTransactionManager(transactionManager);

        //流程图字体
        processEngineConfiguration.setActivityFontName("宋体");
        processEngineConfiguration.setAnnotationFontName("宋体");
        processEngineConfiguration.setLabelFontName("宋体");

        return processEngineConfiguration;
    }

在获取图片的地方设置字体

 BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
       
 // 获取流程图图像字符流
        ProcessDiagramGenerator pec = processEngine.getProcessEngineConfiguration().getProcessDiagramGenerator();
        InputStream imageStream = pec.generateDiagram(
                bpmnModel,
                "png",
                ActivityIds,
                flowIds,
                "宋体",
                "宋体",
                "宋体",
                null,
                1.0);

2、配置服务器上字体信息

把window系统的宋体字体文件复制出来,window 系统路径 C:\Windows\Fonts\simsun.ttc

spring boot 整合activiti5.22 部署到linux 查看流程图是乱码_第1张图片

找到服务器jdk安装目录,忘记的话就执行 Java -verbose 倒数2行包含安装路径

spring boot 整合activiti5.22 部署到linux 查看流程图是乱码_第2张图片

进入jre/lib/fonts/fallback/  (/fonts/fallback/  这二个文件夹没有就新增)

放入前面的字体文件。

3、重启项目,问题解决

 

 

 

 

 

你可能感兴趣的:(activiti)