-1

This solution doesn't work for me. Any other options?

EDIT

I have this:

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();

and I see this in output pdf

Image1

If I set

string font = "resources//fonts//FreeSans.ttf";
PdfFont *f1 = document.CreateFont(font.c_str());
PdfString pLtext("\u0141\u00F3d\u017A st\u00F3\u0142");

I got

Image3

Hope, it will help to find the answer.

mkl
  • 90,588
  • 15
  • 125
  • 265
Fryderyk
  • 61
  • 1
  • 7
  • Possible duplicate of [Can't get Czech characters while generating a PDF](http://stackoverflow.com/questions/26631815/cant-get-czech-characters-while-generating-a-pdf) – Tadeusz Kopec for Ukraine Mar 20 '17 at 12:18
  • @TadeuszKopec I doubt that a question for one PDF library used with C# can really be considered a duplicate for a different PDF library used with C++, even if probably the cause underneath is similar. But as the OP hardly provides any information, it's difficult to say anything at all. – mkl Mar 20 '17 at 15:19
  • Fryderyk, if you really want help, please start by providing enough information about your issue. It is not even clear what your actual problem is, "doesn't work for me" might mean anything, probably each time you tried your CPU exploded... – mkl Mar 20 '17 at 15:25
  • Y, sorry. I edited question and added more info. Btw, its really annoying I need 10 rep points to add more then 2 urls... I wanted to show you more, but I cant :/ – Fryderyk Mar 20 '17 at 19:23

1 Answers1

0

This code works for me:

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();

This is the most important part:

PdfString pLtext(L"Łódź stół");
PdfFont* pFont = document.CreateFont("TIMES NEW ROMAN", false, new PdfIdentityEncoding(0, 0xffff, true));

Best regards!

Fryderyk
  • 61
  • 1
  • 7