I am creating a PDF using the Grails graphics adapter (mainly Flying Saucer). My GSP page is a UTF-8 page (or at least the properties show that it is UTF-8, there is also a directive <?xml version="1.0" encoding="UTF-8"?> at the top of the GSP page) . At first, the generated PDF correctly contained the äöüõ umlaut characters, but the Cyrillic characters were absent from the PDF (not displayed at all). Then I modified my css file as described in the documentation, adding the following:
@font-face { src: url(ARIALUNI.TTF); -fs-pdf-font-embed: embed; -fs-pdf-font-encoding: UTF-8; } body { font-family: "Arial Unicode MS", Arial, sans-serif; }
ArialUni.ttf is also deployed to the server. But now I get both umlaut characters and Cyrillic characters presented in the form of boxes. If I change the value of the -fs-pdf-encoding property to Identity-H, the umlaut characters are displayed correctly, but the Cyrillic characters are displayed as question marks.
Any ideas on which font can be used to correctly display both umlaut and cyrillic characters? Or maybe my CSS is somehow wrong? Any clues would be greatly appreciated.
Update 1: I also tried using css (which was created by http://fontface.codeandmore.com/ ):
@font-face { font-family: 'ArialUnicodeMS'; src: url('arialuni.ttf'); src: url('arialuni.eot?#iefix') format('embedded-opentype'), url('arialuni.woff') format('woff'), url('arialuni.ttf') format('truetype'), url('arialuni.svg#arialuni') format('svg'); font-weight: normal; font-style: normal; -fs-pdf-font-embed: embed; -fs-pdf-font-encoding: UTF-8; } body { font-family:'ArialUnicodeMS'; }
I added <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> I also tried to run grails with -Dfile.encoding = UTF-8, as mentioned here: http: //grails.1312388.n4.nabble.com/PDF-plugin-Having-problems-with-instalation-td2297840.html , but nothing helps. Cyrillic characters are not shown at all. Any other ideas what could be the problem?
* BTW: * I pack my PDF in zip and send it back to the browser in response like:
response.setHeader "Content-disposition", "attachment; filename=test.zip" response.setHeader "Content-Encoding", "UTF-8" response.contentType = 'application/zip' response.outputStream << zip response.outputStream.flush() response.outputStream.close()
Do I need to somehow consider the encoding during zipping ????, which I like:
public static byte[] zipBytes(Map<String, ByteArrayOutputStream> fileNameToByteContentMap) throws IOException { ByteArrayOutputStream zipBaos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(zipBaos); fileNameToByteContentMap.eachWithIndex {String fileName, ByteArrayOutputStream baos, i -> byte[] content = baos.buf ZipEntry entry = new ZipEntry(fileName) entry.setSize(content.length) zos.putNextEntry(entry) zos.write(content) zos.closeEntry() } zos.close() return zipBaos.toByteArray(); }