I need to dynamically modify Word files with values โโfrom a database or enter by user. Values โโand files are in Arabic.
The problem is that it does not work all the time. Each time I come across a new and different problem with Arabic characters.
The code I'm using is:
FileInputStream in = new FileInputStream(path+"\\fiches\\"+fileName.trim()+".doc");
POIFSFileSystem fs = new POIFSFileSystem(in);
HWPFDocument doc = new HWPFDocument(fs);
Range r = doc.getRange();
r.replaceText("<matricule>"," "+agent.getMatriculeAgent());
r.replaceText("<cin>"," "+agent.getCin());
r.replaceText("<ุงูุฅุณู
ุงูุดุฎุตู>", " "+agent.getPrenomAgentArabe());
OutputStream out = response.getOutputStream();
response.setContentType("application/rtf");
response.setHeader("Content-Disposition","attachment; filename="+fileName);
doc.write(out);
out.flush();
source
share