• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

How to use GetTextLinesIterator

Community Beginner ,
Jun 23, 2020 Jun 23, 2020

Copy link to clipboard

Copied

Dear Friends,

   We need to seperate line by line from multiLined Single FrameText. We Found the api GetTextLinesIterator . But it not work properly . Please suggest more about this api.

Regards,

Jayashree.J

 

TOPICS
SDK

Views

385

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Jun 24, 2020 Jun 24, 2020

Copy link to clipboard

Copied

Perhaps it doesn’t work properly, perhaps you misunderstand the documentation, perhaps it is not suitable for your situation. Please describe the problem you are having in full detail, with a minimal code sample, and expected and actual result. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 24, 2020 Jun 24, 2020

Copy link to clipboard

Copied

Thanks for your reply,

     We need to take art bounds of every lines of multilined TextFrame Art.

 

AIErr result;
ArtMatcher artMatch(1);
artMatch.SetSpec(0, kAnyArt, 0, 0);
artMatch.GetMatchingArt();
ASInt32 lLength, maxLength, ret;
char *buffer = NULL;
short type;
for (int nInd = 0; nInd < artMatch.GetNumMatches(); ++nInd)
{
AIArtHandle art1 = artMatch.GetMatchedArt(nInd);
result = sAIArt->GetArtType(art1, &type);
ATE::TextLinesIteratorRef lineIter = NULL;
ATE::TextFrameRef textRef;
ATE::ATEBool8 bIter ;
ATE::ATEBool8 bLineIter ;
ATE::TextLineRef TextLineRef;
ATETextDOM::Int32 lLength, maxLength;
char *buffer = "";
if (type == kTextFrameArt)
{
result = sAITextFrame->GetATETextFrame(art1, &textRef);
result = sAIText->GetTextLinesIterator(textRef,& lineIter);
result = sAILineIterSuite->IsEmpty(lineIter, &bIter);
if (!bIter)
{
result = sAILineIterSuite->IsNotDone(lineIter, &bLineIter);
while (bLineIter)
{
TextRangeRef textrange;
result = sAILineIterSuite->Item(lineIter, &TextLineRef);
result = sTextLine->GetTextRange(TextLineRef, &textrange);
result = sTextRange->GetSize(textrange, &lLength);
maxLength = lLength * 2;
buffer = (char *)malloc(maxLength * sizeof(char));
memset(buffer, 0, maxLength);
ATETextDOM::Int32 ret = 0;
result = sTextRange->GetContents_AsChar(textrange, buffer, maxLength, &ret);
std::string str(buffer);
ai::UnicodeString strkey = ai::UnicodeString(str, kAIUTF8CharacterEncoding);
sAIUser->MessageAlert(strkey);
result = sAILineIterSuite->Next(lineIter);
result = sAILineIterSuite->IsNotDone(lineIter, &bLineIter);
}
}

 


}

}

 

 

I used this above code for iterating lines in multitexted TextFrame.

Please suggest for any other solution for our problem

 

Regards,

Jayashree.j

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 24, 2020 Jun 24, 2020

Copy link to clipboard

Copied

Expected and actual result please. In detail with precision. Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 24, 2020 Jun 24, 2020

Copy link to clipboard

Copied

SampleImage.PNG

 

Actual Result :

Illustrator crash on these line

result = sTextLine->GetTextRange(TextLineRef, &textrange);

Expectation:

kindly check the above image, the four lines are Single TextFrame. I need to seperate four inidividual TextFrame. and display through message alert

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 21, 2020 Jul 21, 2020

Copy link to clipboard

Copied

LATEST

Refer sample code of sdk: \samplecode\CodeSnippets\SnpTextIterator.cpp

ITextLinesIterator linesIter = textFrame.GetTextLinesIterator();
if (!linesIter.IsEmpty()) {
SnippetRunnerLog::Indent indent3;
ASInt32 lineCount = 0;
while (linesIter.IsNotDone()) {
ITextLine textLine = linesIter.Item();
ITextRange textLineRange = textLine.GetTextRange();
ai::AutoBuffer<ASUnicode> contents(range.GetSize());
textLineRange.GetContents(contents, textLineRange.GetSize());
log->WritePrintf("Text line %d:", lineCount);
SnippetRunnerLog::Indent indent4;
log->Write(ai::UnicodeString(contents, contents.GetCount()));
lineCount++;
linesIter.Next();
}
}
else {
log->Write("No text lines found.");
aisdk::check_ai_error(kBadParameterErr);
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines