lfoppiano / streamlit-pdf-viewer

Streamlit PDF viewer
https://structure-vision.streamlit.app/
Apache License 2.0
63 stars 3 forks source link

Show annotations on the PDF document #3

Closed lfoppiano closed 5 months ago

lfoppiano commented 7 months ago

The usage should be something like:

 st.viewer.push_annotation(annotations)

annotations should contains data in the following format:

annotation = [
{
"page": x, 
"x": 1 
"y": 3
"height": 10
"width": 10
"color": blue
}
...
]

Tasks:

lfoppiano commented 6 months ago

is it possible to add two more methods:

lfoppiano commented 6 months ago

In this document there seems to be a problem with the annotations.

image

We could ask each page heights and width as an optional argument of the main method

lfoppiano commented 6 months ago

This is what grobid could provide as information about pages:

    <facsimile>
        <surface n="1" ulx="0.0" uly="0.0" lrx="634.32" lry="833.04"/>
        <surface n="2" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="3" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="4" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="5" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="6" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="7" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="8" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="9" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="10" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="11" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="12" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="13" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="14" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="15" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="16" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
        <surface n="17" ulx="0.0" uly="0.0" lrx="595.276" lry="841.89"/>
    </facsimile>
t29mato commented 5 months ago

To show annotations generated by GROBID, which branch or environment are you using?

What I use is below

Now, I am trying to integrate the show annotations button. https://github.com/lfoppiano/document-qa/commit/b325c610c654505266d5a7dbef11439015bf4eed

Screenshot 2024-01-10 at 19 56 45
lfoppiano commented 5 months ago

The branch show-annotations was already merged, so you can keep using it or create a new one. For testing or development, at this stage, please use the https://github.com/lfoppiano/structure-vision project instead of document-qa.