wxpdf 0.9.x not displaying symbols Topic is solved
wxpdf 0.9.x not displaying symbols
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.
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.
Re: wxpdf 0.9.x not displaying symbols
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.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..
Does anyone know what is causing this? Also what possible fixes there may be for it?
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
Re: wxpdf 0.9.x not displaying symbols
I just tried building as unicode, but it returned errors:
Thanks.
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);
- Attachments
-
- TEST.zip
- (827 Bytes) Downloaded 190 times
Re: wxpdf 0.9.x not displaying symbols
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: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*)'|
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.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);
Regards,
Ulrich
Re: wxpdf 0.9.x not displaying symbols
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.
Thanks.
Re: wxpdf 0.9.x not displaying symbols
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.worms103 wrote:I did build the wxpdf via a unicode widgets build (It doesn't let you otherwise) and that error appeared.
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.
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.worms103 wrote:I can create a new document with compression disabled if that is preferred?
Regards,
Ulrich
Re: wxpdf 0.9.x not displaying symbols
This is what is outputted when using unicode on 2.8.18 and 0.9.1:
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.
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*)'|
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.
Re: wxpdf 0.9.x not displaying symbols
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:This is what is outputted when using unicode on 2.8.18 and 0.9.1:
I am using windows 7, with GNU GCC compiler and codeblocks.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*)'|
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: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
Add the line
Code: Select all
#if wxUSE_UNICODE
Code: Select all
#else
return s;
#endif
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
Re: wxpdf 0.9.x not displaying symbols
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!
Thanks again!