Search code examples
pdfclown

PDF Viewer bug using Arial font where whitespaces became "question mark"


I didn't notice this bug until I run it in Google Chrome in Windows 7. It wasn't noticeable in Internet Explorer cuz it was using Adobe Acrobat, but Chrome use built-in PDF Viewer.

The text "Hello, How are you?" had became "Hello,?How?are?you?".

using pdfclownFonts = org.pdfclown.documents.contents.fonts;

private void DocumentTemplate(Document parmDocument)
{
    PrimitiveComposer primitiveComposer = new PrimitiveComposer(page);
    {
        BlockComposer blockComposer = new BlockComposer(primitiveComposer);
        pdfclownFonts::Font fontArial = pdfclownFonts::Font.Get(parmDocument, _fontArialRegularFilePath);
        primitiveComposer.SetFont(fontArial, 26 /*[Font-Size]*/);

        blockComposer.Begin(New RectangleF(5f, 5f, 500f, 30f), XAlignmentEnum.Left, YAlignment Enum.Top);
        blockComposer.ShowText("Hello, How are you?");
        blockComposer.End();

        blockComposer.Flush();
    }
}

Then I found this bug report at http://sourceforge.net/p/clown/bugs/52/ .

So my question is...

1) Is it just a Chrome bug?

2) Or is it just a PDFClown bug?

3) If PDFClown bug, then do you have any idea of estimate time will it be fixed?

Thanks.


Solution

  • This issue is masterly explained by Vadim in his answer and was the subject of at least one pdf.js' bug-tracking entry.

    The short answer is that PDF Clown generates perfectly legal PDF files (hence they are properly rendered by Adobe Acrobat, Poppler-based viewers like Evince, and even the excellent Ghostscript interpreter). The problem is that these PDF files feature "jagged" mixed-length code-points which aren't properly handled by less-mature viewers like Chrome's.

    To avoid such an inconvenience, PDF Clown will use single-length encodings only (it's among the issues due to be solved in 0.2.0).


    UPDATE 04/14/2015

    I'm glad to announce that the issue has been solved and committed to the project's repo. It will be included in next releases (0.1.2.1 and 0.2.0); in the meantime, you can download a code snapshot from the link indicated.