void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen) { fz_error *error; pdf_textline *line, *ln; int y, c; int i, p; int bx0, bx1, by0, by1; int x0 = app->image->x + app->selr.x0 - app->panx; int x1 = app->image->x + app->selr.x1 - app->panx; int y0 = app->image->y + app->selr.y0 - app->pany; int y1 = app->image->y + app->selr.y1 - app->pany; error = pdf_loadtextfromtree(&line, app->page->tree, pdfapp_viewctm(app)); if (error) pdfapp_error(app, error); p = 0; for (ln = line; ln; ln = ln->next) { y = y0 - 1; for (i = 0; i < ln->len; i++) { bx0 = ln->text[i].bbox.x0; bx1 = ln->text[i].bbox.x1; by0 = ln->text[i].bbox.y0; by1 = ln->text[i].bbox.y1; c = ln->text[i].c; if (c < 32) c = '?'; if (bx1 >= x0 && bx0 <= x1 && by1 >= y0 && by0 <= y1) if (p < ucslen - 1) ucsbuf[p++] = c; } if (by1 >= y0 && by0 <= y1) { #ifdef WIN32 if (p < ucslen - 1) ucsbuf[p++] = '\r'; #endif if (p < ucslen - 1) ucsbuf[p++] = '\n'; } } ucsbuf[p] = 0; pdf_droptextline(line); }
static void drawtxt(int pagenum) { fz_error error; pdf_textline *line; fz_matrix ctm; drawloadpage(pagenum, NULL); ctm = fz_concat( fz_translate(0, -drawpage->mediabox.y1), fz_scale(drawzoom, -drawzoom)); error = pdf_loadtextfromtree(&line, drawpage->tree, ctm); if (error) die(error); pdf_debugtextline(line); pdf_droptextline(line); drawfreepage(); }