standard deviation symbol σ is not being added to PDF using iText

281 views Asked by At

I am using iText to generate PDFs and I have a symbol σ which does not get added to the PDF.

Is this because of font selection (using HELVETICA_BOLD)?

Can anyone help?

1

There are 1 answers

2
Bruno Lowagie On BEST ANSWER

The σ-symbol doesn't exist in Helvetica, so you need to use the Symbol font. This is demonstrated in the StandardDeviation. See standard_deviation.pdf:

enter image description here

This is how it's done:

public void createPdf(String dest) throws IOException, DocumentException {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream(dest));
    document.open();
    document.add(new Paragraph("The standard deviation symbol doesn't exist in Helvetica."));
    Font symbol = new Font(FontFamily.SYMBOL);
    Paragraph p = new Paragraph("So we use the Symbol font: ");
    p.add(new Chunk("s", symbol));
    document.add(p);
    document.close();
}