java - How to make PDF text selectable using Apache PDFBox? -


i trying make text selectable @ pdf reading application made on javafx. have pdf files contain screenshots text , ocr layer. need text selectable @ regular viewer. set getting image page , trying figure out how highlight text.

i tried following:

    inputstream = this.getclass().getresourceasstream(currentpdf);     image convertedimage;     try {         pddocument document = pddocument.load(is);         list<pdpage> list = document.getdocumentcatalog().getallpages();         pdpage page = list.get(pagenum);         list annotations = page.getannotations();         pdannotationtextmarkup markup = new pdannotationtextmarkup(pdannotationtextmarkup.sub_type_highlight);         markup.setrectangle(new pdrectangle(600, 600));         markup.setquadpoints(new float[]{100, 100, 200, 100, 100, 500, 200, 500});         annotations.add(markup);         page.setannotations(annotations);         bufferedimage image = page.converttoimage(bufferedimage.type_int_rgb, 128);         convertedimage = swingfxutils.tofximage(image, null);         document.close();         imageview.setimage(convertedimage);     } catch (exception e) {         throw new runtimeexception(e);     } 

but results in image without highlights.

i tried find information @ stack overflow or other resources, haven't found anything.

would appreciate java code sample enables text highlighting mouse.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -