Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElementList filter on visualise function does not work #255

Closed
mcrts opened this issue Oct 5, 2021 · 1 comment · Fixed by #256
Closed

ElementList filter on visualise function does not work #255

mcrts opened this issue Oct 5, 2021 · 1 comment · Fixed by #256

Comments

@mcrts
Copy link

mcrts commented Oct 5, 2021

When using a ElementList to filter Elements visualised by the visualise function, no filter is applied and all elements are displayed.

from py_pdf_parser.loaders import load_file
from py_pdf_parser.visualise import visualise
document = load_file("path_to_file.pdf")
visualise(document, elements=document.elements[0::2]) #should only display every other element

py_pdf_parser/visualise/main.py : PDFVisualiser.__plot_current_page

...
        for element in page.elements:
            style = STYLES["tagged"] if element.tags else STYLES["untagged"]
            self.__plot_element(element, style)
...

This part of the method does not take into account the elements parameter.
I propose to change it to :

...
        for element in page.elements and self.elements:
            style = STYLES["tagged"] if element.tags else STYLES["untagged"]
            self.__plot_element(element, style)
...

To perform the intersection between the two sets.

PS: I am working on a pull request.

@jstockwin
Copy link
Owner

The fix for this is included in release 0.10.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants