我在PoDoFo库中编码波兰语字符时遇到问题。
此代码生成单词“Łódź”的无效编码
#include <podofo/podofo.h>
using namespace PoDoFo;
int main(int argc, char *argv[], char *env[]) {
PdfStreamedDocument document("polish.pdf");
PdfPainter painter;
PdfPage* pPage;
pPage = document.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
painter.SetPage( pPage );
PdfFont* pFont = document.CreateFont("Helvetica");
// PdfFont* pFont = document.CreateFont("Helvetica", new PdfIdentityEncoding(0, 0xffff, true) );
PdfString pString("Polish word: Łódź");
// PdfString pString(reinterpret_cast<const pdf_utf8*>("Polish word: Łódź"));
painter.SetFont( pFont );
painter.DrawText( 100.0, pPage->GetPageSize().GetHeight()-100.0, pString );
painter.FinishPage();
document.Close();
return 0;
}
在输出pdf中有
波兰语:ņÃ3dÅo
我试图更改源字符串的编码(使用示例代码中的注释行),但都失败了。
有人可以解释一下如何使用 PoDoFo 库创建包含非 ascii 字符的 PDF 文档吗?