15

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?

Juan Marcos
  • 153
  • 1
  • 5
  • I tried your `fo:block` code in both FOP 1.0 and FOP .95. It worked fine in both versions. Do you have access to stderr? You should be getting a warning if there is a font or glyph issue. – Daniel Haley Nov 04 '11 at 22:41
  • @DevNull actually, I haven't tested in FOP 1.0 yet, just FOP .95, I'm starting learning this, could you tell me how can I access to stderr to see if it is a font or glyph issue? – Juan Marcos Nov 08 '11 at 13:20
  • Probably you're doing your development in an IDE like Eclipse. Whenever you run your code the output gets sent to the console; by default it (in Eclipse at least) will show stderr as red lines in that console. – Wivani Dec 09 '11 at 13:17
  • 1
    Probably your FOP configuration does not include a font suitable to act as a replacement for the Symbol font or your PDF reader have some problem with the Symbol font. – gioele Dec 17 '11 at 18:29
  • @gioele I agree with your first statement, maybe the FOP configuration does not include a font suitable, I just ended using svg to draw it, I did all this research to avoid using svg, but at the end I couldn't solve it, by the way I'm not working with xsl:fo anymore. – Juan Marcos Dec 18 '11 at 20:18
  • What operating system you running Java on? If it's Linux/Unix type - you may need to check the locale of the logged-in user and/or make sure you have the -Dfile.encoding flag set to (probably) 'utf-8'..... If you are windows the -Dfile.encoding might still matter but not the locale (I don't think). If you have access to both Windows / *nix - try it on both - do you get the same result? – monojohnny Feb 17 '14 at 21:20
  • I could imagine that OP's code would not work if the fo xml is declaring a different encoding than UTF-8. – Stefan Hegny Jul 14 '16 at 12:21

1 Answers1

4

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

luchoct
  • 419
  • 3
  • 6