title: itextpdf font does not embed in Linux
body: <p>I have a simple Java program that uses iTextPDF to create a simple "Hello World" file, using a font that's not native to iTextPDF (COOPBL.TTF, straight from Windows).</p>
  
  <p>Running on Windows 7-64 it runs fine and creates a pdf file with a subset of the Cooper Black font embedded in the file, reflected in the file appearance.</p>
  
  <p>Running the exact same class file on Linux (no recompile), it does not embed anything and uses Helvetica.</p>
  
  <p>Here's the program:</p>
  
  <pre><code>import java.io.ByteArrayInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  
  import com.itextpdf.text.FontFactory;
  import com.itextpdf.text.Document;
  import com.itextpdf.text.PageSize;
  import com.itextpdf.text.DocumentException;
  import com.itextpdf.text.pdf.PdfWriter;
  
  import com.itextpdf.tool.xml.XMLWorkerHelper;
  
  
  public class iTextTest {
    private void doit(String sOut) {
      Document doc = new Document(PageSize.LETTER);
  
      try {
        FileOutputStream fOut = new FileOutputStream(sOut);
  
        // Register a non-native font.
        String sFontDir = ".";
        int iResult = FontFactory.registerDirectory(sFontDir);
        if(iResult == 0) {
          System.out.println("TestPDF(): Could not register font directory " + sFontDir);
        } else {
          System.out.println("TestPDF(): Registered font directory " + sFontDir);
        }
        System.out.println("  Fonts registered:");
        for(String sFont:FontFactory.getRegisteredFonts()) {
          System.out.println("    " + sFont);
        }
  
        PdfWriter pdfWriter = PdfWriter.getInstance(doc, fOut);
  
        doc.open();
  
        XMLWorkerHelper helper = XMLWorkerHelper.getInstance();
  
        String htmlContent;
        htmlContent  = "&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;";
        htmlContent += "&lt;P style=\"font-family: cooperblack;\"&gt;";
        htmlContent += "Hello World!";
        htmlContent += "&lt;/P&gt;";
        htmlContent += "&lt;/BODY&gt;&lt;/HTML&gt;";
        helper.parseXHtml(pdfWriter, doc, new ByteArrayInputStream(htmlContent.getBytes()));
  
      } catch(IOException e) {
        e.printStackTrace();
      } catch(DocumentException e) {
        e.printStackTrace();
      }
  
      if(doc != null) {
        doc.close();
      }
    }
  
  
    public static void main(String[] args) {
      if(args.length != 1) {
        System.out.println("Usage: iTextTest outfile");
        return;
      }
  
      iTextTest test = new iTextTest();
      test.doit(args[0]);
    }
  }
  </code></pre>
  
  <p>I'm using:
    itextpdf-5.5.0
    xmlworker-5.5.0
    Windows Java 1.6.0_21
    Linux Java 1.6.0_23</p>
  
  <p>I would include copies of the font and the resulting pdf's, but don't see an apparent way of doing that.  For my tests, I simply copied \Windows\fonts\COOPBL.TTF into the test directories, both for the Windows test and the Linux test.</p>
  
  <p>For what it's worth:
  - Tweaking the protection/properties flags in the font file makes no difference.
  - I'm aware this isn't a public domain font.  I'm only using it for testing.</p>
  
  <p>I'm all ears for any comments!</p>
  
  <p>Thanks,
  Chuck</p>