wchar_t *PDFTextWordInterop::getText() { if(_textWord != NULL) { globalParams->setTextEncoding("UTF-8"); TextWord *word = (TextWord *)_textWord; GString *text = word->getText(); wchar_t *utfText = GetUTF8String(text); delete text; return utfText; } else if(_wordList != NULL) { TextWordList *wordList =(TextWordList *)_wordList; TextWord *word = wordList->get(_currentWord); if(word != NULL) { GString *text = word->getText(); wchar_t *utfText = GetUTF8String(text); // delete text; return utfText; } } return NULL; }
double PDFTextWordInterop::getFontSize() { if(_textWord != NULL) { TextWord *word = (TextWord *)_textWord; return word->getFontSize(); } else if(_wordList != NULL) { TextWordList *wordList =(TextWordList *)_wordList; TextWord *word = wordList->get(_currentWord); if(word != NULL) return word->getFontSize(); } return 0; }
void PDFTextWordInterop::getFontColor(double *r, double *g, double *b) { if(_textWord != NULL) { TextWord *word = (TextWord *)_textWord; word->getColor(r,g,b); } else if(_wordList != NULL) { TextWordList *wordList =(TextWordList *)_wordList; TextWord *word = wordList->get(_currentWord); if(word != NULL) word->getColor(r,g,b); } }
int PDFTextWordInterop::getCharCount() { if(_textWord != NULL) { TextWord *word = (TextWord *)_textWord; return word->getCharLen(); } else if(_wordList != NULL) { TextWordList *wordList =(TextWordList *)_wordList; TextWord *word = wordList->get(_currentWord); if(word != NULL) return word->getLength(); } return 0; }
void PDFTextWordInterop::getBBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA) { if(_textWord != NULL) { TextWord *word = (TextWord *)_textWord; word->getBBox(xMinA, yMinA, xMaxA, yMaxA); } else if(_wordList != NULL) { TextWordList *wordList =(TextWordList *)_wordList; TextWord *word = wordList->get(_currentWord); if(word != NULL) word->getBBox(xMinA, yMinA, xMaxA, yMaxA); } else { xMinA = yMinA = xMaxA = yMaxA = 0; } }
char *PDFTextWordInterop::getFontName() { if(_textWord != NULL) { TextWord *word = (TextWord *)_textWord; GString *fontName = word->getFontName(); return fontName->getCString(); } else if(_wordList != NULL) { TextWordList *wordList =(TextWordList *)_wordList; TextWord *word = wordList->get(_currentWord); if(word != NULL) { GString *fontName = word->getFontName(); return fontName->getCString(); } } return NULL; }
PDFTextWordInterop *PDFTextWordInterop::getNext() { if(next == NULL) { if(_textWord != NULL) { TextWord *word = (TextWord *)_textWord; TextWord *nextWord = word->getNext(); if(nextWord == NULL) return NULL; next = new PDFTextWordInterop(_textBlock, _textLine,(void *)nextWord, _currentWord +1); }else if(_wordList != NULL) { TextWordList *wordList =(TextWordList *)_wordList; TextWord *nextWord = wordList->get(++_currentWord); if(nextWord == NULL) return NULL; next = new PDFTextWordInterop(wordList, _currentWord); } } return next; }
int get_page_word_list(iv_wlist** word_list, int* wlist_len, int page) { int result = 0, i; if (word_list && wlist_len) { if (diclist) { for (i = 0; i < diclen; i++) free(diclist[i].word); free(diclist); diclist = NULL; } if (reflow_mode) { splashOut->getWordList(&diclist, &diclen, page != -1 ? page : subpage); } else { FixedPoint fx1, fx2, fy1, fy2; int x1, x2, y1, y2; char* s; int i, sw, sh, pw, ph, marginx, marginy, len; double sres; sw = ScreenWidth(); sh = ScreenHeight(); textout = new TextOutputDev(NULL, gFalse, gFalse, gFalse); getpagesize(page != -1 ? page : cpage, &pw, &ph, &sres, &marginx, &marginy); doc->displayPage(textout, page != -1 ? page : cpage, sres, sres, 0, false, true, false); TextWordList* wlist = textout->makeWordList(); if (wlist == NULL) { fprintf(stderr, "wlist=NULL\n"); len = 0; } else { len = wlist->getLength(); } diclist = (iv_wlist*) malloc((len + 1) * sizeof(iv_wlist)); diclen = 0; fprintf(stderr, "len=%i\n", len); for (i = 0; i < len; i++) { TextWord* tw = wlist->get(i); s = tw->getText()->getCString(); tw->getBBox(&fx1, &fy1, &fx2, &fy2); x1 = (int)fx1 + scrx - offx; x2 = (int)fx2 + scrx - offx; y1 = (int)fy1 + scry - offy; y2 = (int)fy2 + scry - offy; if (s != NULL && *s != '\0' && x1 < sw && x2 > 0 && y1 < sh && y2 > 0) { diclist[diclen].word = strdup(s); diclist[diclen].x1 = x1 - 1; diclist[diclen].y1 = y1 - 1; diclist[diclen].x2 = x2 + 1; diclist[diclen].y2 = y2 + 1; diclen++; } } diclist[diclen].word = NULL; delete wlist; delete textout; } *word_list = diclist; *wlist_len = diclen; result = 1; } return result; }