This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics.
I am attempting to write out centered or right justified text. I first add a font (PXC_AddFontA) and then set the current font (PXC_SetCurrentFont). Left justified text works fine. I then do the following steps to change the justification:
"My needs" are to make a class wrapper around your library that matches a current class we are using so we can add this without changing other code. Our class needs to be able to output both type of strings. So I need to be able to use PXC_TextOutA and PXC_DrawTextExW. So in the case of PXC_TextOutA, how would we justify the text to the right or center?
I was able to output text using PXC_TextOutA and PXC_TextOutW. I switched to us PXC_DrawTextExW and now there is no text in the PDF file. I've reviewed the sample code to see if there is something I need to setup before calling PXC_DrawTextExW. I haven't found anything yet. I'm sure I am doing something incorrect but I haven't found it yet. Is there a set of functions that must be called before PXC_DrawTextExW?
Firstly you must add your font (as with any other function that works with text) and pass its identifier via PXC_DrawTextStruct or PXC_SetCurrentFont to set the required parameters for your text and then when all is defined as required call PXC_DrawTextExW etc.
There is a VB (and others for other Tools) example showing the use of this - if you installed to the default folder you can find in :
Your problem (and the problem with the PDF format as well ! )
is because coordinate system of PDF-XChange (and in the PDF format too) is oriented not as in Windows GDI and because you pass this to the PXC_DrawTextExW function this is in fact the wrong rectangle co-ordinate detail.
please change this detail in your code in the file testDlg.cpp line 197
rect.bottom = rect.top + size.cy;
rect.bottom = rect.top - size.cy;
and all should be well
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
OK, now I am back to my original problem. When I set the "flags" argument to DTF_Align_Right, DTF_Align_Center, or DTF_Align_Left it seems to me the text is always left justified. I have attached the test app again which outputs the same string three times; once with flags as DTF_Align_Right, once with flags as DTF_Align_Left, and once with flags as DTF_Align_Center. The 'x' parameter is the same in each call to PXC_DrawTextExW. I expected the right justified string to end at that x location, the left justified string to start at that x location and the center justified string to be centered at that x location.
I know I can use PXC_GetStringWidthW and make the adjustments myself but I would like to make PXC_DrawTextExW work like I was expecting.