0

i'm working with liferay 7.2 on local and after generating pdf, working so fine for me

after deploying on test site the pdf is generated without recognizing letters with accents like é a collegue told me that the problem is caused due to the site which is using linux as a system

i m using a pdf writer folowing this code

    Document document = new Document(PageSize.A4);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter writer = PdfWriter.getInstance(document, baos);
    Font font_titre = new Font(Font.TIMES_ROMAN, 14, Font.BOLD, coul_bleu);
    ph1 = new Phrase("Activités", font_titre);

I'm getting this :

problem after generating pdf

  • What is the character encoding of the source file ? It should be UTF-8, that will work cross on all OS platforms. – PeterMmm Aug 09 '22 at 10:59
  • 1
    While indeed the fonts included in a PDF viewer are limited in their character selection, Western European characters usually are covered, in particular something like an 'é'. Furthermore, the screen shot looks like UTF-8 encoded text being interpreted as if it was Latin-1 encoded. Thus, for a test please replace 'é' by '\u00E9' and test again. If that eventually draws an 'é', it's a mere encoding issue of your code. – mkl Aug 09 '22 at 12:40
  • 1
    Great! By the way, that most likely means that your code file is saved as UTF-8 but that your Java compiler expects the Java code files to be Latin-1 (or similarly) encoded. As UTF-8 here nowadays is quite standard, you might want to change your compiler call to expect UTF-8 encoded files. – mkl Aug 10 '22 at 09:35

0 Answers0