Skip to main content
Known Participant
March 30, 2017
Answered

How to get text from PDEText element

  • March 30, 2017
  • 2 replies
  • 889 views

I wrote the following code to get the text from a PDEtext  element, however, the AVAlertNote is appearing blank. How would I go about fixing the problem.

int blen;

blen=PDETextGetText(pdeText,kPDETextRun,k,NULL);

char* stringBuffer = (char*)calloc( blen + 1, sizeof(char) );

PDETextGetText(pdeText,kPDETextRun,k, (ASUns8*)stringBuffer);

AVAlertNote(stringBuffer);

This topic has been closed for replies.
Correct answer lrosenth

It’s indirect, but you can go through the CosObj.

CosObj co;

PDEFontGetCosObj( &co )

PDFont pf = PDFontFromCosObj( co )

2 replies

LWShayAuthor
Known Participant
March 30, 2017

In order to use that function I need a PDFont element. I'm know to get a PDEFont element from a PDEText element, but I'm not sure how to convert that to PDFont

Legend
March 30, 2017

You should position yourself to answer these questions about your text run.

* What is the binary data returned to you?

* What is the encoding of the font?

* Does the font have a ToUnicode CMap?

* Does the data make sense in the context of the rules for PDF text extraction in 32000-1?

Only if this seems all correct proceed to automating.

Of course, AVAlertNote is not a Unicode method!

lrosenth
Adobe Employee
Adobe Employee
March 30, 2017

That will simply get you the “char codes” but not necessary the text – entirely depending on the type of fonts and encoding used for the text.

You will most likely need to also do a PDFontXlateToUCS() to turn that into Unicode.