Start adapting the code to make use of the new PDF.Box class type

This commit is contained in:
Tissevert 2020-02-24 21:13:31 +01:00
parent 7f889cf168
commit 308cfd4cbe
2 changed files with 9 additions and 10 deletions

View file

@ -24,7 +24,9 @@ executable reveal
build-depends: base >=4.9.1 && <4.13 build-depends: base >=4.9.1 && <4.13
, bytestring , bytestring
, containers , containers
, mtl
, Hufflepdf >= 0.2.0 , Hufflepdf >= 0.2.0
, zlib , zlib
hs-source-dirs: src hs-source-dirs: src
ghc-options: -Wall
default-language: Haskell2010 default-language: Haskell2010

View file

@ -3,6 +3,7 @@
module Main where module Main where
import Codec.Compression.Zlib (compress, decompress) import Codec.Compression.Zlib (compress, decompress)
import Control.Monad.State (execState)
import Data.ByteString.Char8 (ByteString) import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BS ( import qualified Data.ByteString.Char8 as BS (
length, readFile length, readFile
@ -11,8 +12,10 @@ import qualified Data.ByteString.Lazy.Char8 as Lazy (
fromStrict, intercalate, split, toStrict, writeFile fromStrict, intercalate, split, toStrict, writeFile
) )
import qualified Data.Map as Map (insert, lookup) import qualified Data.Map as Map (insert, lookup)
import PDF (Document(..), parseDocument, render) import PDF (Document(..), UnifiedLayers(..), parseDocument, render)
import PDF.Object (Content(..), DirectObject(..), Object(..), Name(..), Number(..)) import PDF.Box ((.@), modifyAt)
import PDF.Layer (AllObjects(..))
import PDF.Object (DirectObject(..), Object(..), Name(..), Number(..))
import PDF.TextRendering (TextRendering(..), update) import PDF.TextRendering (TextRendering(..), update)
import Prelude hiding (lines, unlines) import Prelude hiding (lines, unlines)
import System.Environment (getArgs) import System.Environment (getArgs)
@ -40,15 +43,9 @@ revealObject obj@(Stream {header, streamContent}) =
_ -> obj _ -> obj
revealObject obj = obj revealObject obj = obj
revealContent :: Content -> Content
revealContent content = content {
objects = revealObject <$> (objects content)
}
reveal :: Document -> Document reveal :: Document -> Document
reveal document = document { reveal = execState $ do
updates = revealContent <$> (updates document) modifyAt (UnifiedLayers .@ AllObjects) (return . fmap revealObject)
}
main :: IO () main :: IO ()
main = do main = do