How can I display a Unicode character using Apache fop? Showing "?" instead of character.

Juan Marcos picture Juan Marcos · Nov 2, 2011 · Viewed 7.3k times · Source

I been trying to insert a Unicode character ∇ or ▽, so it shows in the PDF generated by Apache FOP.

This is what I did so far:

  1. First you have to know the correct Unicode codepoint to represent the character according to this basic help Apache XSL-FO Input, that Unicode codepoint can be found in unicode.org inside a list of Mathematical Operators. The code is ∇ ∇ NABLA, I could also use ▽ ▽ a down-pointing triangle.

  2. After finding the correct code I have to select a font containing the necessary glyph and the Adobe PostScript and PDF Specification specify Base-14 Font Character Mapping that must be available to every PostScript interpreter and PDF reader, so I search in the list and the font Symbol contains ∇&#x2207, (no font contains▽▽ discarded)

  3. After that search the result code I think I should use in xsl:fo is:

     <fo:block font-family="Symbol">
     &#x2207;
     </fo:block>
    
  4. The problem is when it generates the PDF, the result is not what I expected "∇", but instead of that it shows a "?", I read that when it can't show the character usually shows "#", but my code is showing "?".

  5. I'm using Apache fop 0.95, I suspect is that version which is causing the problem, and I should update to 1.0, but at the moment that's the version used in production, and the team leader said it's difficult at the moment to upgrade it.

So there that is the problem, could be something else besides the version? Could be something dummie I forgot to do? How can I display a Unicode character using Apache fop?

Answer

luchoct picture luchoct · Jan 23, 2012

Try with the decimal value of the symbol (I think you don't need the Symbol font family for this):

&#8711;

For everyone who need to know the values of special symbols, you can find them here