Skip to content
Advertisement

PDFBox with special characters working fine on Windows but characters getting replaced with other characters in Linux

My requirement is that I have a PDF Acroform Template with few text fields and based on logged in user these text fields are prepopulated with user’s name and city and is presented to the user (Note user is not manually entering data into PDF but my backend code is doing this). so these name and city fields are giving problem for non-english characters. Strange thing is this works perfectly fine on my loca (windows 10). However when the code is deployed in lunix machine those non-english characters are getting replaced with some other characters.

I am using pdfbox-app version 2.0.24

I have this font Arial_Narrow.ttf in my classpath. (to fix another issue – java.lang.IllegalArgumentException: … is not available in this font’s encoding: WinAnsiEncoding)

My assumption is since this Arial_Narrow.ttf font has WinAnsiEncoding, it is working on Windows 10 machinee but giving problems when deployed on Lunix machine.

Please help!

JavaScript
JavaScript
JavaScript

Advertisement

Answer

Change this

JavaScript

to this

JavaScript

to avoid subsetting. IIRC it’s because the font file in the subset font doesn’t really exist at the time you’re using it because the object you’re using is a different PDFont object.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement