Align text

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.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software, Andrew - Tracker Support, Tracker - Clarion Support, John - Tracker Supp, Support Staff, moderators

Post Reply
ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Align text

Post by ken66 » Thu May 19, 2005 11:19 pm

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:

PXC_TextOptions opts;
opts.cbSize = sizeof(PXC_TextOptions);
PXC_GetTextOptions(m_page, &opts);
opts.nTextPosition = TextPosition_Top;
opts.nTextAlign = TextAlign_Right;
PXC_SetTextOptions(m_page, &opts);

All text is still being left justified. I am using TextOutA to write the text if that matters. Is there a step I am missing?[/u]

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Fri May 20, 2005 8:29 am

Hi,

PXC_TextOut function is not the best function to use for your needs - please use the function : PXC_DrawTextExW

Hope that helps.
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.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Fri May 20, 2005 4:43 pm

"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?

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Fri May 20, 2005 6:08 pm

I am afraid you cannot - we provided the revised function to update limitations in PXC_TextOutA which for many reasons could not be extended and cannot support your needs.

If you need the properties outlined - you have no choice but to use

PXC_DrawTextExW
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.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Sat May 21, 2005 12:08 am

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?

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Sat May 21, 2005 5:54 am

Hi,

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 :

C:\PDFX-Gold\PDFX-SDK3\PDF-XChange3ArchiveNew\PDF-XChange3\PDF-Tools3SDK\SDKExamples\VBExamples\PDFXC

If still having problem please feel to post the relevant code snippet and we will take a look see.
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.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Mon May 23, 2005 4:50 pm

I have attached a simple VC 6 project that I think should just output a PDF with a couple of strings. Please let me know what I am missing.

Thanks
Attachments
testapp.zip
(873.74 KiB) Downloaded 101 times

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Tue May 24, 2005 11:20 am

Hi Ken,

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

from

rect.bottom = rect.top + size.cy;

to

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.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Tue May 24, 2005 2:52 pm

Thank you very much, I figured I must be doing something stupid. :oops: I should have realized this since I had to do the same thing to get my images to work.

I'm still having some issues with alignment though. I'll see if I can figure out what is going on first and then maybe send you another example.

Thanks again for you help.

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Tue May 24, 2005 3:13 pm

Pleasure and good luck ;)
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.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Tue May 24, 2005 6:02 pm

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.

Thanks
Attachments
testalign.zip
(873.71 KiB) Downloaded 112 times

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Wed May 25, 2005 8:58 am

Ken,

before you output the text you calculate the size of the rectangle to be occupied by the text (using PXC_GetStringWidth),

and therefore naturally the 2 being of the same length - the text will always appear to be left aligned !

The text is aligned according to the size of the rectangle you create - not around some arbitrary position within that rectangle you define.
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.

Best regards
Tracker Support
http://www.tracker-software.com

Post Reply