I'm trying to create a searchable PDF from images that have been OCRed and in PoDoFo 0.9.22 I was able to do it with the code below. I would increase/decrease the font size till I had the correct size that matched my image. But as of 0.10.x (I'm trying to use 0.10.3) there is no GetFontSize anywhere and PdfFont does not have SetFontSize. How can I achieve the same thing in the new version?
Thanks
void PrintTextOnPage(PoDoFo::PdfPainter& mPainter, PoDoFo::PdfFont* pFont, const TRectD& pageBB, const PoDoFo::PdfString aText, const TRectD& txtBB)
{
const PoDoFo::PdfFontMetrics* fontMetrics = pFont->GetFontMetrics();
float fontSize = pFont->GetFontSize();
double tmpW = fontMetrics->StringWidth(aText);
while (tmpW < txtBB.Width)
{
fontSize += 1.0;
pFont->SetFontSize(fontSize);
tmpW = fontMetrics->StringWidth(aText);
}
while (tmpW > txtBB.Width)
{
fontSize -= 0.5;
pFont->SetFontSize(fontSize);
tmpW = fontMetrics->StringWidth(aText);
}
mPainter.DrawText(txtBB.Left, (pageBB.Height) - (txtBB.Top + txtBB.Height), aText);
}
Replace
and
with
and
Finding the text
GetFontSizein the sources was easy.