Reputation: 131
Sorry my English, i have a problem with cyrillic symbols in PDF. I use PoDoFo library version 0.9.7 with fontconfig in Windows and Linux.
PdfMemDocument document;
document.Load("anyfile.pdf", true);
/***/
PdfFont *fontPtr = fontPtr = document.CreateFont("Arial", false, false, PdfEncodingFactory::GlobalIdentityEncodingInstance());
PdfPainter painter;
painter.SetPage(document.GetPage(0));
/***/
PdfString str(reinterpret_cast<const pdf_utf8*>("Next text is russian words: 'Пример текста на русском.'"));
// i use plog loging lib and it:
// LOG_INFO << str.GetStringUtf8(); // out correct string
/***/
painter.DrawTextAligned(40, 400, 800, str.GetStringUtf8(), PoDoFo::EPdfAlignment::ePdfAlignment_Left);
painter.FinishPage();
document.Close();
I see it page for Polish but it not help for me!
On screenshot whats give my example:
Upvotes: 2
Views: 605
Reputation: 131
I set path to font and it works!
document.CreateFontSubset("LiberationSans-Regular", false
, false, false, pEncoding, "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf");
And if you want auto search, you can try this:
PdfFontConfigWrapper ftWrapper;
auto createFont = [&ftWrapper](PdfMemDocument& document, const std::string& fontName, bool bold, bool italic, const PdfEncoding* pEncoding) -> PdfFont* {
auto fontPath = PdfFontCache::GetFontConfigFontPath(static_cast<FcConfig*>(ftWrapper.GetFontConfig()), fontName.c_str(), true, false);
PdfFont *fontPtr = document.CreateFontSubset(fontName.c_str(), bold, italic, false, pEncoding, fontPath.c_str());
return fontPtr;
};
Upvotes: 1