Tuesday 15 September 2015

How to use Verdana Font in Stamper (iText PDF) -



How to use Verdana Font in Stamper (iText PDF) -

i want utilize verdana font while stamping pdf file itext pdf. original file uses verdana, isn't alternative in class basefont.

here function create font right now:

def standardstampfont() { homecoming basefont.createfont(basefont.helvetica, basefont.winansi, false) }

i'd alter verdana font, exchanging part basefont.helvetica "verdana" doesn't work.

any idea? in advance!

as documented, itext supports standard type 1 fonts, because itext ships afm file (adobe font metrics files). itext has no thought font metrics of other fonts (verdana isn't standard type 1 font). need provide path verdana font file.

basefont.createfont("c:/windows/fonts/verdana.ttf", basefont.winansi, basefont.embedded)

note alter false basefont.embedded because same problem have on side, occur on side of person looks @ file: pdf viewer can render standard type 1 fonts, may not able render other fonts such verdana.

caveat: hard coded path "c:/windows/fonts/verdana.ttf" works me on local machine because font file can found using path on local machine. code won't work on server host itext site, though (which linux server doesn't have c:/windows/fonts directory). using hard coded path way of example. should create sure font nowadays , available when deploy application.

pdf itext

No comments:

Post a Comment