You are not logged in.
Hello,
I tried to write some texts in Hebrew, Arabic and Japanese inside a PDF file. Using the function TextOut() available in the TPdfCanvas, the texts are written correctly. Now I tried to write the same texts using the TextRect() and MultilineTextRect() available in the same canvas. The result shows only ??? symbols for all non Latin texts. I tried some workarounds, as e.g. converting text to UTF8, but no way.
The texts to write are declared as follow:
std::wstring WAppSettings::m_EnglishText = L"Any text... What happen?";
std::wstring WAppSettings::m_JapaneseText = L"任意のテキストには、何が起こりますか?";
std::wstring WAppSettings::m_HebrewText = L"כל טקסט, מה קורה?";
std::wstring WAppSettings::m_ArabicText = L"أي نص، ماذا يحدث؟";
And here is the code I use to draw the text:
This code works
pPdfDoc->Canvas->BeginText();
pPdfDoc->Canvas->TextOut(300, 400, (WideChar*)(WAppSettings::m_EnglishText.c_str()));
pPdfDoc->Canvas->TextOut(300, 500, (WideChar*)(WAppSettings::m_JapaneseText.c_str()));
pPdfDoc->Canvas->TextOut(300, 600, (WideChar*)(WAppSettings::m_HebrewText.c_str()));
pPdfDoc->Canvas->TextOut(300, 700, (WideChar*)(WAppSettings::m_ArabicText.c_str()));
pPdfDoc->Canvas->EndText();
This code not works
TPdfRect pdfRect;
pdfRect.Left = 300;
pdfRect.Top = 400;
pdfRect.Right = pdfRect.Left + 100;
pdfRect.Bottom = pdfRect.Top + 20;
pPdfDoc->Canvas->BeginText();
pPdfDoc->Canvas->TextRect(pdfRect, (WideChar*)(WAppSettings::m_EnglishText.c_str()), Synpdf::paLeftJustify, false);
pdfRect.Top = 500;
pdfRect.Bottom = pdfRect.Top + 20;
pPdfDoc->Canvas->TextRect(pdfRect, (WideChar*)(WAppSettings::m_JapaneseText.c_str()), Synpdf::paLeftJustify, false);
pdfRect.Top = 600;
pdfRect.Bottom = pdfRect.Top + 20;
pPdfDoc->Canvas->TextRect(pdfRect, (WideChar*)(WAppSettings::m_HebrewText.c_str()), Synpdf::paLeftJustify, false);
pdfRect.Top = 700;
pdfRect.Bottom = pdfRect.Top + 20;
pPdfDoc->Canvas->TextRect(pdfRect, (WideChar*)(WAppSettings::m_ArabicText.c_str()), Synpdf::paLeftJustify, false);
pPdfDoc->Canvas->EndText();
So what is the correct way to write the above texts using the TextRect() and MultilineTextRect() functions?
NOTE saying that I only can use TextOut() is not an acceptable solution for me. I need to be able to place the text on multiple lines, crop the text, word wrap it, and so on, whatever the used alphabet.
Regards
Offline