Skip to main content
Participant
Feb 6, 2023 10:27 AM UTC
Question

How to get the character '±' correctly?

I use the function 'AVDocGetPageText' to get the '±' character in the page, but keep returning '? '

My code is as follows:

PDTextSelect textSelect = PDDocCreateTextSelect(pdDoc, 0, &rect);
bool ret = AVDocSetSelection(avDoc, ASAtomFromString("Text"), textSelect,true);
ASAtom format = ASAtomFromString("Text");
string title = "";
AVDocGetPageText(m_avDoc, vecPages[i], textSelect, format, TextSelectProc, &title);

 

void TextSelectProc(ASAtom format, void *buf, AVTBufferSize bufLen, void *clientData)
{

          // Look at the memory of *buf and it returns 3f

}

This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

MikelKlink
Participating Frequently
Feb 7, 2023 7:35 AM UTC

You have chosen "Text" as format. Thus, TextSelectProc is called twice for your selection. Have you verified that on both calls the '±' character is transformed to the replacement character?

Translate
Participant
Feb 7, 2023 9:54 AM UTC

Yes, I tried it twice, and it returned 0x3f

Translate
Legend
Feb 7, 2023 1:00 PM UTC

Maybe there is a problem with the encoding inside the PDF. Are you able to copy/paste the text including the plusminus character into other apps? Maybe you can share a PDF.

Translate
Thom Parker
Community Expert
Community Expert
Feb 6, 2023 5:59 PM UTC

Have you tested with other selections to ensure that other selected text is returned correctly?  Did you check the entire buffer to ensure that ASCII text is returned?  Have you checked the same character codes using a different method?  

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
Feb 7, 2023 12:58 AM UTC

Thank you for your reply.Please confirm the attached file. 

The memory returned is shown below

The character returned by AVDocGetPageText is incorrect.

Translate
Thom Parker
Community Expert
Community Expert
Feb 7, 2023 2:03 AM UTC

Looks like several special characters may be off. Have no idea.

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often