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

workflow to extract text #62

Open
eflister opened this issue Sep 11, 2020 · 1 comment
Open

workflow to extract text #62

eflister opened this issue Sep 11, 2020 · 1 comment

Comments

@eflister
Copy link

hi - i just used #master to do the common thing of extracting all text from a pdf. it worked, thanks for the nice library! it took a while to figure out how to do it and required more contortions than i expected. perhaps you could add some api support for such a basic task? here's what i wound up with, is this what you expect users to do?

main = do
  withPdfFile "file.pdf" $ \pdf -> do
    txt <- extract pdf =<< catalogPageNode =<< documentCatalog =<< document pdf

extract pdf = (T.concat <$>) . (traverse ((extract' =<<) . loadPageNode pdf) =<<) . pageNodeKids
  where
    extract' (PageTreeLeaf tn) = pageExtractText tn
    extract' (PageTreeNode tn) = extract pdf tn
@Yuras
Copy link
Owner

Yuras commented Sep 17, 2020

Yeah, simpler API would be great. Though I'm not sure how exactly it should look like. I'll think about it, thank you for the input.

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

No branches or pull requests

2 participants