java - Got DocumentException Arial with Cp1252 is not recognized -


the last months generates thousends of pdfs (on windows 7 while developing, opensuse while test & production) font courier.

now got goal use arial. switched font name in our property files , got exception:

stacktrace snippet: com.itextpdf.text.documentexception: font 'arial' 'cp1252' not recognized. @ com.itextpdf.text.pdf.basefont.createfont(basefont.java:708) @ com.itextpdf.text.pdf.basefont.createfont(basefont.java:615) @ com.itextpdf.text.pdf.basefont.createfont(basefont.java:450)

after googleing while found solution. have use "arial.ttf" (like filename) in settings. after that, got exception:

java.io.ioexception: arial.ttf not found file or resource.   @ com.itextpdf.text.io.randomaccesssourcefactory.createbyreadingtomemory(randomaccesssourcefactory.java:224)   @ com.itextpdf.text.io.randomaccesssourcefactory.createbestsource(randomaccesssourcefactory.java:173)   @ com.itextpdf.text.pdf.randomaccessfileorarray.<init>(randomaccessfileorarray.java:147)   @ com.itextpdf.text.pdf.truetypefont.process(truetypefont.java:625)   @ com.itextpdf.text.pdf.truetypefont.<init>(truetypefont.java:369)   @ com.itextpdf.text.pdf.basefont.createfont(basefont.java:699)   @ com.itextpdf.text.pdf.basefont.createfont(basefont.java:615)   @ com.itextpdf.text.pdf.basefont.createfont(basefont.java:450) 

so hint there is, itextpdf looking file right now. typed filename c:\\windows\\fonts\\arial.ttf our config. works!

but goal use "arial" fontname. possible?

thanx lot!

it's not possible use name arial, because arial isn't listed 1 of 14 standard type 1 fonts (whereas courier 1 of 14).

if want use arial, you'll need refer arial.ttf file, , yes, can mean need provide c:/windows/fonts/arial.ttf path.

if want make application platform-independent, can ship font code resource, , use path resource.

another solution, use fontfactory , register fonts. note initial call register fonts can take time, fontfactory search hard disk many fonts can find looking @ directories may contains font files (depending on os). take @ fontfactoryexample , experiment register(), registerdirectory() , registerdirectories() methods.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -