PdfPig
PdfPig copied to clipboard
'The font does not contain a character: ’.'
PdfPig 0.1.6 Nuget Package.
I am following the guide within the github repo but i keep getting an error about the font not containing a character. I have attached a few lines of code. This particular string is throwing the error even though it does not contain the full stop character.
PdfDocumentBuilder.AddedFont font = document.AddStandard14Font(Standard14Font.Helvetica);
var test = "This is a Standard Item Called Understanding of customer’s query";
page.AddText(test, 12, closeToTop, font);
System.InvalidOperationException HResult=0x80131509 Message=The font does not contain a character: ’. Source=UglyToad.PdfPig StackTrace: at UglyToad.PdfPig.Writer.PdfPageBuilder.DrawLetters(NameToken name, String text, IWritingFont font, TransformationMatrix fontMatrix, Decimal fontSize, TransformationMatrix textMatrix) at UglyToad.PdfPig.Writer.PdfPageBuilder.AddText(String text, Decimal fontSize, PdfPoint position, AddedFont font) etc (cant share more as it reveals clients)
i see the character it doesnt like is ( ' ) rather than the full stop but this is still an issue. i just misread the error message.
So it looks like you're passing the Microsoft curly apostrophe ’ instead of the "normal" ASCII apostrophe '. The standard 14 fonts only support a limited character set. You might need to use a TrueType font if you want access to the Word symbols like curly quotes and apostrophes.
https://stackoverflow.com/questions/2826191/converting-ms-word-curly-quotes-and-apostrophes