对不起,我的英语,我有一个问题的西里尔符号在PDF中。我在Windows和Linux中使用带有字体配置的PoDoFo库版本0.9.7。
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();我看到了page for Polish,但它对我没有帮助!
在截图上给出我的例子:

发布于 2021-11-21 10:24:51
我将path设置为font,它就可以工作了!
document.CreateFontSubset("LiberationSans-Regular", false
, false, false, pEncoding, "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf");如果你想要自动搜索,你可以试试这个:
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;
};https://stackoverflow.com/questions/70048016
复制相似问题