wxpdf 0.9.x not displaying symbols  [SOLVED]

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
worms103
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Jul 01, 2011 2:39 pm

wxpdf 0.9.x not displaying symbols

Postby worms103 » Fri Jul 01, 2011 2:44 pm

Recently upgraded to wxwidgets 0.8.12 and wxpdf 0.9.1 but this has caused symbols like ® or á to not render properly in the pdf file created, even though it works on the old verson of wxwidgets (0.6.3) and wxpdf (0.8 ).

Does anyone know what is causing this? Also what possible fixes there may be for it?

Thanks.
Last edited by worms103 on Mon Jul 04, 2011 10:50 am, edited 1 time in total.

utelle
Moderator
Moderator
Posts: 824
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxpdf 0.9.x not displaying symbols

Postby utelle » Sun Jul 03, 2011 9:47 am

worms103 wrote:Recently upgraded to wxwidgets 0.8.12 and wxpdf 0.9.1 but this has caused symbols like ® or á to not render properly in the pdf file created, even though it works on the old verson of wxwidgets (0.6.3) and wxpdf (0.8).

Does anyone know what is causing this? Also what possible fixes there may be for it?

Well, up to now I didn't receive bug reports from others regarding problems in rendering problems and I myself didn't experience such problems either. But the font handling in wxPdfDocument changed a lot from version 0.8.x to 0.9.x, so in combination with your application code there might surface a bug after all.

To give further advice I would need some more information. Which build of wxWidgets are you using? Unicode or ANSI? (I have to admit I'm a bit lazy in testing the ANSI build, since most features of wxPdfDocument work best in Unicode and in wxWidgets 2.9.x there isn't an ANSI build anymore.)

Additionally it would help to see the code you use to produce your PDF file and the resulting PDF file (please call SetCompression(false) after instantiating the wxPdfDocument instance to make analyzing the PDF file easier). Usually such text rendering problems are caused by using the wrong encoding for the font.

Regards,

Ulrich

worms103
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Jul 01, 2011 2:39 pm

Re: wxpdf 0.9.x not displaying symbols

Postby worms103 » Mon Jul 04, 2011 10:38 am

I just tried building as unicode, but it returned errors:

Code: Select all

C:\wxWidgets-2.8.12-test\include\wx\msw\winundef.h|39|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HWND__* CreateDialogParamW(HINSTANCE__*, const WCHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM), LPARAM)'|

C:\wxWidgets-2.8.12-test\include\wx\msw\winundef.h|70|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `14' to `HFONT__* CreateFontW(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, const WCHAR*)'|


Code: Select all

wxPdfDocument pdf;
    pdf.AddPage();
    pdf.SetAutoPageBreak(true,10);

    pdf.SetY(50);
    pdf.SetFont(_T("Arial"),_T("B"),36);
    pdf.Cell(190,50,_T("TEST"),0,1,wxPDF_ALIGN_CENTER);
    pdf.Cell(60,15,_T("®®®®®®®®"),0,1,wxPDF_ALIGN_RIGHT);
    pdf.Cell(60,15,_T("áááááááá"),0,1,wxPDF_ALIGN_RIGHT);
    pdf.Cell(60,15,_T("éééééééé"),0,1,wxPDF_ALIGN_RIGHT);


Thanks.
Attachments
TEST.zip
(827 Bytes) Downloaded 107 times

utelle
Moderator
Moderator
Posts: 824
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxpdf 0.9.x not displaying symbols

Postby utelle » Mon Jul 04, 2011 8:34 pm

worms103 wrote:I just tried building as unicode, but it returned errors:

Code: Select all

C:\wxWidgets-2.8.12-test\include\wx\msw\winundef.h|39|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HWND__* CreateDialogParamW(HINSTANCE__*, const WCHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM), LPARAM)'|

C:\wxWidgets-2.8.12-test\include\wx\msw\winundef.h|70|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `14' to `HFONT__* CreateFontW(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, const WCHAR*)'|

The error occurs when compiling a wxWidgets header which is not related to wxPdfDocument. Did you build the Unicode version of wxWidgets itself before trying to compile wxPdfDocument in Unicode mode? Make sure you have a valid Unicode build of wxWidgets before compiling wxPdfDocument in Unicode mode.

worms103 wrote:

Code: Select all

wxPdfDocument pdf;
    pdf.AddPage();
    pdf.SetAutoPageBreak(true,10);

    pdf.SetY(50);
    pdf.SetFont(_T("Arial"),_T("B"),36);
    pdf.Cell(190,50,_T("TEST"),0,1,wxPDF_ALIGN_CENTER);
    pdf.Cell(60,15,_T("®®®®®®®®"),0,1,wxPDF_ALIGN_RIGHT);
    pdf.Cell(60,15,_T("áááááááá"),0,1,wxPDF_ALIGN_RIGHT);
    pdf.Cell(60,15,_T("éééééééé"),0,1,wxPDF_ALIGN_RIGHT);


As you didn't follow my recommendation to call SetCompression(false) I'm not able to analyze the test PDF file easily, but I guess that there is a problem in the ANSI build of wxPdfDocument with non-ASCII characters due to the changes in the font handling. I have to analyze this further, but this might take some time. If it is really a bug and if there is a simple fix I'll post a notification.

Regards,

Ulrich

worms103
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Jul 01, 2011 2:39 pm

Re: wxpdf 0.9.x not displaying symbols

Postby worms103 » Tue Jul 05, 2011 7:40 am

I did build the wxpdf via a unicode widgets build (It doesn't let you otherwise) and that error appeared. I can create a new document with compression disabled if that is preferred?

Thanks.

utelle
Moderator
Moderator
Posts: 824
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxpdf 0.9.x not displaying symbols

Postby utelle » Tue Jul 05, 2011 11:16 am

worms103 wrote:I did build the wxpdf via a unicode widgets build (It doesn't let you otherwise) and that error appeared.

This is really strange. I never experienced such an error within all the years I'm using wxWidgets, and I have no idea, what's causing the problem.

Could you please give some details in which environment you are working, i.e. operating system, compiler and/or IDE. And it would probably help to see the whole output of the compiler.

I definitely recommend to use wxPdfDocument together with a Unicode build of wxWidgets, since most advanced font handling features require the Unicode build.

worms103 wrote:I can create a new document with compression disabled if that is preferred?

I don't think this is necessary. As far as I can see the special characters are replaced by question marks. This is probably the effect of a codepage conversion method. I have to create an ANSI wxWidgets build first for further testing. I keep you informed on the results.

Regards,

Ulrich

worms103
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Jul 01, 2011 2:39 pm

Re: wxpdf 0.9.x not displaying symbols

Postby worms103 » Tue Jul 05, 2011 12:01 pm

This is what is outputted when using unicode on 2.8.18 and 0.9.1:

Code: Select all

C:\MinGW\include\tchar.h|63|warning: "__TEXT" redefined|
C:\MinGW\include\winnt.h|136|warning: this is the location of the previous definition|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* CreateDialog(HINSTANCE__*, const CHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM))':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|39|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HWND__* CreateDialogParamW(HINSTANCE__*, const WCHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM), LPARAM)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HFONT__* CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|70|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `14' to `HFONT__* CreateFontW(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* CreateWindow(const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|95|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HWND__* CreateWindowExW(DWORD, const WCHAR*, const WCHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HMENU__* LoadMenu(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|112|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HMENU__* LoadMenuW(HINSTANCE__*, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* FindText(FINDREPLACEA*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|127|error: cannot convert `FINDREPLACEA*' to `FINDREPLACEW*' for argument `1' to `HWND__* FindTextW(FINDREPLACEW*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HICON__* LoadIcon(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|318|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HICON__* LoadIconW(HINSTANCE__*, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HBITMAP__* LoadBitmap(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|331|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HBITMAP__* LoadBitmapW(HINSTANCE__*, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* CreateDialog(HINSTANCE__*, const CHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM))':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|39|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HWND__* CreateDialogParamW(HINSTANCE__*, const WCHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM), LPARAM)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HFONT__* CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|70|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `14' to `HFONT__* CreateFontW(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* CreateWindow(const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|95|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HWND__* CreateWindowExW(DWORD, const WCHAR*, const WCHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HMENU__* LoadMenu(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|112|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HMENU__* LoadMenuW(HINSTANCE__*, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* FindText(FINDREPLACEA*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|127|error: cannot convert `FINDREPLACEA*' to `FINDREPLACEW*' for argument `1' to `HWND__* FindTextW(FINDREPLACEW*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HICON__* LoadIcon(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|318|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HICON__* LoadIconW(HINSTANCE__*, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HBITMAP__* LoadBitmap(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|331|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HBITMAP__* LoadBitmapW(HINSTANCE__*, const WCHAR*)'|


I am using windows 7, with GNU GCC compiler and codeblocks.

Its odd because when I used widgets 2.6.3 and pdfdoc 0.8 with ascii it renders the symbols fine, just seems a bit strange :|

Thanks.

utelle
Moderator
Moderator
Posts: 824
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxpdf 0.9.x not displaying symbols  [SOLVED]

Postby utelle » Tue Jul 05, 2011 3:54 pm

worms103 wrote:This is what is outputted when using unicode on 2.8.18 and 0.9.1:

Code: Select all

C:\MinGW\include\tchar.h|63|warning: "__TEXT" redefined|
C:\MinGW\include\winnt.h|136|warning: this is the location of the previous definition|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* CreateDialog(HINSTANCE__*, const CHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM))':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|39|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HWND__* CreateDialogParamW(HINSTANCE__*, const WCHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM), LPARAM)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HFONT__* CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|70|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `14' to `HFONT__* CreateFontW(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* CreateWindow(const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|95|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HWND__* CreateWindowExW(DWORD, const WCHAR*, const WCHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HMENU__* LoadMenu(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|112|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HMENU__* LoadMenuW(HINSTANCE__*, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* FindText(FINDREPLACEA*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|127|error: cannot convert `FINDREPLACEA*' to `FINDREPLACEW*' for argument `1' to `HWND__* FindTextW(FINDREPLACEW*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HICON__* LoadIcon(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|318|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HICON__* LoadIconW(HINSTANCE__*, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HBITMAP__* LoadBitmap(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|331|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HBITMAP__* LoadBitmapW(HINSTANCE__*, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* CreateDialog(HINSTANCE__*, const CHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM))':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|39|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HWND__* CreateDialogParamW(HINSTANCE__*, const WCHAR*, HWND__*, BOOL (*)(HWND__*, UINT, WPARAM, LPARAM), LPARAM)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HFONT__* CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|70|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `14' to `HFONT__* CreateFontW(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* CreateWindow(const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|95|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HWND__* CreateWindowExW(DWORD, const WCHAR*, const WCHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HMENU__* LoadMenu(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|112|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HMENU__* LoadMenuW(HINSTANCE__*, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HWND__* FindText(FINDREPLACEA*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|127|error: cannot convert `FINDREPLACEA*' to `FINDREPLACEW*' for argument `1' to `HWND__* FindTextW(FINDREPLACEW*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HICON__* LoadIcon(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|318|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HICON__* LoadIconW(HINSTANCE__*, const WCHAR*)'|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h||In function `HBITMAP__* LoadBitmap(HINSTANCE__*, const CHAR*)':|
C:\wxWidgets-2.8.12\include\wx\msw\winundef.h|331|error: cannot convert `const CHAR*' to `const WCHAR*' for argument `2' to `HBITMAP__* LoadBitmapW(HINSTANCE__*, const WCHAR*)'|


I am using windows 7, with GNU GCC compiler and codeblocks.

My guess is that a preprocessor symbol regarding Unicode support is misspelled or missing, so that the string type is not mapped to wide characters. Which symbols did you define?

worms103 wrote:Its odd because when I used widgets 2.6.3 and pdfdoc 0.8 with ascii it renders the symbols fine, just seems a bit strange :|

As I said the font handling changed a lot from wxPdfDocument version 0.8.x to 0.9.x. And that is the explanation for this odd behaviour. This is a bug in the ANSI build. You need to modify method wxPdfFontDataCore::ConvertCID2GID in file pdffontdatacore.cpp. Do the following:

Add the line

Code: Select all

#if wxUSE_UNICODE

before line 177 (const wxPdfChar2GlyphMap* convMap ...) and add

Code: Select all

#else
  return s;
#endif

after line 205 (return t;).

This should give you back the behaviour as of wxPdfDocument 0.8.x for the ANSI build.

Similar changes might be required at other places.

Regards,

Ulrich

worms103
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Jul 01, 2011 2:39 pm

Re: wxpdf 0.9.x not displaying symbols

Postby worms103 » Wed Jul 06, 2011 9:47 am

Works now, thanks! The only problem is that the registered symbols now clip into text to left and right which is odd, but easily fixed by applying white spaces.

Thanks again! =D>


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 2 guests