Getting Text Size With wxPdfDocument
Posted: Wed Aug 15, 2018 8:53 pm
Hello, I am trying to use GetStringWidth() in wxPdfDocument and I was expecting the line drawn to be the same length as the text. Does anyone know what I am doing wrong?
Thanks in advance with any help you can give me!
Code: Select all
string sFilePath = "/home/test/test.pdf"; wxPdfFontManager::GetFontManager()->AddSearchPath(wxT("/usr/share/fonts")); wxPdfDocument pdf; pdf.AddPage(wxPORTRAIT, wxPAPER_A4); pdf.SetFont(wxT("Helvetica"), NULL, 14); string sToDraw = "Test String Size"; double dWidth = pdf.GetStringWidth(sToDraw); pdf.Text(10, 10, sToDraw); pdf.Line(10, 10, dWidth, 10); pdf.SaveAsFile(sFilePath); string sOpenCommand = "xdg-open " + sFilePath; system (sOpenCommand.c_str());