Basically, I need to take a question from a text file and format it as a question would be formatted in a maths exam.
Right now, I'm using PDFsharp to do this but it always saves the alphanumerical symbols (for example, ) as boxes.
I tried copying from the sample on PDFsharp and have this
Dim document As New PdfSharp.Pdf.PdfDocument
Dim page As PdfSharp.Pdf.PdfPage = document.AddPage()
Dim gfx As PdfSharp.Drawing.XGraphics = PdfSharp.Drawing.XGraphics.FromPdfPage(page)
Dim tf As New PdfSharp.Drawing.Layout.XTextFormatter(gfx)
Dim options As New PdfSharp.Drawing.XPdfFontOptions(PdfSharp.Pdf.PdfFontEncoding.Unicode)
Dim font As New PdfSharp.Drawing.XFont("LastResort", 10, PdfSharp.Drawing.XFontStyle.Regular, options)
tf.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left
tf.DrawString(questionArray(i)), font, PdfSharp.Drawing.XBrushes.Black, New PdfSharp.Drawing.XRect(0, 0, page.Width.Point, page.Height.Point), PdfSharp.Drawing.XStringFormats.TopLeft)
Dim filename As String = "test" + Str(i).Trim + ".pdf"
document.Save(filename)
Process.Start(filename)
I know I don't need to keep repeating the "PdfSharp.Pdf" stuff, my plan was to clean it all up when I get the characters saving properly. Last Resort is a font that contains unicode symbols and the mathematical alphanumerical block, according to https://www.fileformat.info/info/unicode/block/mathematical_alphanumeric_symbols/fontsupport.htm
My end goal is to take a basic .txt file like "f(x) = 5[^2] + (k+7) + k where k is a real constant." and save it to a PDF to resemble a real math exam question.
So, is there a better way to do this or a way to make PDFsharp do it?