Hufflepdf/examples/debug.hs

26 lines
930 B
Haskell

module Main where
import Control.Monad.Reader
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C8
import qualified Data.Map as Map
import PDF.Object (Name(..), array)
import PDF.CMap (CMappers, cMap, emptyCMap)
import PDF.Parser (evalParser)
import PDF.Text
test :: CMappers -> ParserWithFont a -> BS.ByteString -> Either String a
test fonts parser =
evalParser (runReaderT parser fonts) emptyCMap
main :: IO ()
main = do
--input <- BS.readFile "20.stream"
input <- BS.readFile "array.bin"
Right font <- cMap <$> BS.readFile "6300.stream"
--mapM_ (\(k, v) -> putStr (show k) >> putStr " -> " >> BS.putStrLn v) $ Map.toList font
--case pageContents (Map.singleton (Name "R9") font) input of
--case test (Map.singleton (Name "R9") font) array input of
case test (Map.singleton (Name "R9") font) (a textOperator) input of
Left e -> putStrLn e
Right l -> putStrLn . show $ l