kba / hocrjs

Working with hOCR in Javascript
http://kba.cloud/hocrjs
119 stars 17 forks source link

How to enable/disable options in HTML page? #14

Open zuphilip opened 6 years ago

zuphilip commented 6 years ago

I have a hocr file and want to add the hocrjs interface with some predefined options. To integrate it I add <script src="https://unpkg.com/hocrjs"></script> at the end before the closing </body> tag. But can I also enable or disable some of the options, e.g. enable the background image for that specific hocr file?

antoinezambelli commented 3 years ago

I'll jump on here, would love the ability to programmatically activate/disable elements instead of clicking on the sidebar.

kba commented 3 years ago

Currently, it is not possible to enable/disable features at load time.

However, the viewer is a Vue.JS application, assigned to window.hocrapp, which you can use to programmatically execute the methods, such as toggleFeature:

const viewer = window.hocrapp.$children[0]
viewer.toggleFeature('BackgroundImage')

or to navigate through multi-page hOCR:

viewer.nextPage()
viewer.prevPage()

or zoom

viewer.zoom(.75)
viewer.zoom('height')
viewer.zoom('reset')

etc. See vue-hocr/src/components/HocrViewer/script.js for the API.

antoinezambelli commented 3 years ago

Awesome, thanks!