PoDoFo 库 c++ 将文本抛光为 pdf
PoDoFo library c++ polish text to pdf
This solution
对我不起作用。
还有其他选择吗?
编辑
我有这个:
string font = "resources//fonts//FreeSans.ttf";
PdfStreamedDocument document(output_pdf_name.c_str());
PdfPainter painter;
PdfPage* page;
page = document.CreatePage(PdfPage::CreateStandardPageSize(ePdfPageSize_A4));
painter.SetPage(page);
const PdfEncoding *pEncoding = PdfEncodingFactory::GlobalIdentityEncodingInstance();
PdfFont *f1 = document.CreateFont(font.c_str(), true, true, pEncoding);
PdfString eNtext("English text");
PdfString pLtext("Łódź stół");
painter.SetFont(f1);
painter.DrawText(100.0, page->GetPageSize().GetHeight() - 100.0, eNtext);
painter.DrawText(100.0, page->GetPageSize().GetHeight() - 150.0, pLtext);
painter.FinishPage();
document.Close();
我在输出 pdf 中看到了这个
如果我设置
string font = "resources//fonts//FreeSans.ttf";
PdfFont *f1 = document.CreateFont(font.c_str());
PdfString pLtext("\u0141\u00F3d\u017A st\u00F3\u0142");
我得到了
希望,这将有助于找到答案。
这段代码对我有用:
PdfStreamedDocument document(output_pdf_name.c_str());
PdfPainter painter;
PdfPage* page;
page = document.CreatePage(PdfPage::CreateStandardPageSize(ePdfPageSize_A4));
painter.SetPage(page);
PdfString eNtext("English text");
PdfString pLtext(L"Łódź stół");
PdfFont* pFont = document.CreateFont("TIMES NEW ROMAN", false, new PdfIdentityEncoding(0, 0xffff, true));
painter.SetFont(pFont);
painter.DrawText(100.0, page->GetPageSize().GetHeight() - 100.0, eNtext);
painter.DrawText(100.0, page->GetPageSize().GetHeight() - 150.0, pLtext);
painter.FinishPage();
document.Close();
这是最重要的部分:
PdfString pLtext(L"Łódź stół");
PdfFont* pFont = document.CreateFont("TIMES NEW ROMAN", false, new PdfIdentityEncoding(0, 0xffff, true));
此致!
This solution 对我不起作用。 还有其他选择吗?
编辑
我有这个:
string font = "resources//fonts//FreeSans.ttf";
PdfStreamedDocument document(output_pdf_name.c_str());
PdfPainter painter;
PdfPage* page;
page = document.CreatePage(PdfPage::CreateStandardPageSize(ePdfPageSize_A4));
painter.SetPage(page);
const PdfEncoding *pEncoding = PdfEncodingFactory::GlobalIdentityEncodingInstance();
PdfFont *f1 = document.CreateFont(font.c_str(), true, true, pEncoding);
PdfString eNtext("English text");
PdfString pLtext("Łódź stół");
painter.SetFont(f1);
painter.DrawText(100.0, page->GetPageSize().GetHeight() - 100.0, eNtext);
painter.DrawText(100.0, page->GetPageSize().GetHeight() - 150.0, pLtext);
painter.FinishPage();
document.Close();
我在输出 pdf 中看到了这个
如果我设置
string font = "resources//fonts//FreeSans.ttf";
PdfFont *f1 = document.CreateFont(font.c_str());
PdfString pLtext("\u0141\u00F3d\u017A st\u00F3\u0142");
我得到了
希望,这将有助于找到答案。
这段代码对我有用:
PdfStreamedDocument document(output_pdf_name.c_str());
PdfPainter painter;
PdfPage* page;
page = document.CreatePage(PdfPage::CreateStandardPageSize(ePdfPageSize_A4));
painter.SetPage(page);
PdfString eNtext("English text");
PdfString pLtext(L"Łódź stół");
PdfFont* pFont = document.CreateFont("TIMES NEW ROMAN", false, new PdfIdentityEncoding(0, 0xffff, true));
painter.SetFont(pFont);
painter.DrawText(100.0, page->GetPageSize().GetHeight() - 100.0, eNtext);
painter.DrawText(100.0, page->GetPageSize().GetHeight() - 150.0, pLtext);
painter.FinishPage();
document.Close();
这是最重要的部分:
PdfString pLtext(L"Łódź stół");
PdfFont* pFont = document.CreateFont("TIMES NEW ROMAN", false, new PdfIdentityEncoding(0, 0xffff, true));
此致!