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
, bytestring
, containers
, mtl
, Hufflepdf >= 0.2.0
, zlib
hs-source-dirs: src
ghc-options: -Wall
default-language: Haskell2010

View file

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