0

I'm using Flying Saucer for converting XHTML to PDF Files. My Problem is that i have some missing Turkish characters in PDF. But what i don't understand, i don't have any Problems in junit tests. I can convert XHTML files to PDF with all Turkish characters without any Problem. But if i do the same on Applicaton deployed on Tomcat, all Turkish characters missing.

I did some debug and found out that '/fonts/arialuni.ttf' is found in both cases. i found some related threads and itext doc and tried all of them.

http://developers.itextpdf.com/question/how-can-i-load-font-web-infresourcesfontsfoobarttf

Flying Saucer font for unicode characters

code for convert and adding font

            String path2 = "/fonts/arialuni.ttf";

           //FontFactory.register(path2);
            ITextRenderer renderer = new ITextRenderer();
          // renderer.getFontResolver().addFontDirectory(path2,true);

            renderer.getFontResolver().addFont(path2, BaseFont.IDENTITY_H,BaseFont.EMBEDDED);


            renderer.setDocumentFromString(docElem.html());
            renderer.layout();
            renderer.createPDF(os);
            renderer.finishPDF();
            baoOut.flush();

and also applied following for CSS. But still same result.

@font-face {
    src: url('arialuni.ttf'); <!--src: url('/fonts/arialuni.ttf'); -->
    -fs-pdf-font-embed: embed;
    -fs-pdf-font-encoding: Identity-H;
}

body {
    font-family: Arial Unicode MS, Lucida Sans Unicode, Arial, verdana, arial, helvetica, sans-serif;
    font-size: 8.8pt;
}

Does anybody know, why arialuni.tff is found but not used on Tomcat ?

Community
  • 1
  • 1
Runomu
  • 411
  • 1
  • 8
  • 18
  • Please add your solution (everything behind EDIT) as a separate answer and accept it - otherwise people think it is unanswered... – Lonzak Aug 29 '16 at 07:41

1 Answers1

0

finally solved. in some places i was using

InputStream htmlIS = IOUtils.toInputStream(invoiceHtml);

instead

InputStream htmlIS = IOUtils.toInputStream(invoiceHtml, "UTF-8");

that caused problem.

Runomu
  • 411
  • 1
  • 8
  • 18