I have a spring boot application which renders a XML document into PDF. The document contains French characters like é à
. While running the application through STS I have no issues the PDF is generated as expected. But while running the application through command line using java -jar target\\application.jar
the generated PDF has French characters as é Ã
. I am converting the XML into byte[] and creating the PDF. I couldn't figure out a way out. Any help is much appreciated.
Two options:
Force the encoding with the file.encoding
argument, such as -Dfile.encoding=utf-8
.
java -Dfile.encoding=utf-8 -jar target\\application.jar
(better) When you convert the xml file into a byte array, specify the encoding:
Reader reader = new InputStreamReader(new FileInputStream("/path/to/xml/file"), StandardCharsets.UTF_8); // do your file reading ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.