On Mon, 2022-01-24 at 07:55 +0100, zyx wrote:
> I did not dive deep into this yet.

        Hi,
I tried to reproduce this, but it's tricky, because some of the
involved functions are available only under Windows. The following code
is a simple reproducer for something similar, only not involving the
r1967 change.

-------
        PdfMemDocument doc;
        PoDoFo::PdfPage* pPage;
        pPage = doc.CreatePage( PoDoFo::PdfPage::CreateStandardPageSize( 
PoDoFo::ePdfPageSize_A4, false ) );
        PdfFont * pFont = doc.CreateFont( "Helvetica", false, false, false, 
PdfEncodingFactory::GlobalWin1250EncodingInstance());
        TVecFilters filters;
        PdfMemStream output(pPage->GetObject());
        output.BeginAppend(filters);
        PdfPainter painter;
        painter.SetPage(pPage);
        painter.SetFont(pFont);

        PdfString str;
        std::string ustr;

        str = PdfString("ěščřABCĚŠČŘ");
        ustr = str.GetStringUtf8();
        printf ("1) '%s'\n", ustr.c_str());
        pFont->WriteStringToStream(str, &output);
        pFont->WriteStringToStream(ustr, &output);

        painter.DrawText(10, 780, str);
        painter.DrawText(10, 740, ustr);

        str = PdfString((const pdf_utf8 *) "ěščřABCĚŠČŘ");
        ustr = str.GetStringUtf8();
        printf ("2) '%s'\n", ustr.c_str());
        pFont->WriteStringToStream(str, &output);
        pFont->WriteStringToStream(ustr, &output);

        painter.DrawText(10, 700, str);
        painter.DrawText(10, 660, ustr);

        painter.FinishPage();
        doc.Write("/tmp/test.pdf");

        output.EndAppend();
        printf ("%s: wrote %d bytes: '%.*s'\n", __FUNCTION__, (int) 
output.GetLength(), (int) output.GetLength(), output.Get());
-------

The output on the console is:

-------
1) 'ÄłÅ¡Ä“ÅŽABCÄıŀĄş'
2) 'ěščřABCĚŠČŘ'
wrote 126 bytes:
'<C4B3C4938E414243C480C484><978796C297E2959641424397C4B196E287AC97E2959
E96B8><EC9AE8F8414243CC8AC8D8><C4B3C4938E414243C480C484>'
-------

and the PDF is also attached. The string with "2)" is supposed to be
shown in the PDF four times and twice on the console.

Why do I include it here when it does not touch the r1967 change? I
think the change in the r1967 can be correct, the problem is in the
litePDF, not using proper PdfString constructors, similarly to the
above test program. It can be the litePDF "counted" (even
unintentionally) with the previous behavior, without using correct
functions for the PdfString; or, taken it the other way around, the way
litePDF has it done was the right way to do it before the r1967 change.

I mean, I consider this solved. I'll find a way to properly adapt the
litePDF code to work as expected with the fixed PoDoFo. Maybe the above
will help someone else when dealing with the lost UTF-8/Unicode
letters.

        Bye,
        zyx

Attachment: test.pdf
Description: Adobe PDF document

_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to