Skip to content

workflow to extract text #62

Description

@eflister

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions