cancel
Showing results for 
Search instead for 
Did you mean: 

Diagram utf-8 encode problem

gqsforme
Champ in-the-making
Champ in-the-making
Hello everybody !

I am use the  ProcessDiagramGenerator.generateDiagram API to generate deagram,but connot display Chinese

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) 
             ((RepositoryServiceImpl) activiti.getRepositoryService()).getDeployedProcessDefinition(instance
                  .getProcessDefinitionId());
       if (processDefinition != null && processDefinition.isGraphicalNotationDefined()) {
            InputStream in = ProcessDiagramGenerator.generateDiagram(activiti.getRepositoryService().getBpmnModel(instance.getProcessDefinitionId()), "png",
                  activiti.getRuntimeService().getActiveActivityIds(instance.getId()));
            try {
            OutputStream out = new FileOutputStream(new File("d:\\Diagram.png"));
            IOUtils.copy(in, out);
            in.close();
            out.flush();
            out.close();
         } catch (FileNotFoundException e) {
            e.printStackTrace();
         } catch (IOException e) {
            e.printStackTrace();
         }
       }

or using the following way and the Disagram.png are not open

   InputStreamReader reader = new InputStreamReader(in);
            OutputStream out = new FileOutputStream(new File("d:\\Diagram.png"));
            IOUtils.copy(reader, out,"utf-8");

Thanks!

1 REPLY 1

kevinguo1989
Champ in-the-making
Champ in-the-making
try to add font property in your activiti cfg file. The default is Arial which not support Chinese.

eg:

  <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="activityFontName" value="微软雅黑" />
<property name="labelFontName" value="微软雅黑" />
  </bean>