packages feed

pdf-toolbox-document 0.0.5.1 → 0.0.6.0

raw patch · 9 files changed

+35/−30 lines, 9 filesdep ~pdf-toolbox-contentdep ~pdf-toolbox-corePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: pdf-toolbox-content, pdf-toolbox-core

API changes (from Hackage documentation)

- Pdf.Toolbox.Document.Encryption: instance Show Algorithm
- Pdf.Toolbox.Document.FontDict: instance Eq FontSubtype
- Pdf.Toolbox.Document.FontDict: instance Show FontSubtype
- Pdf.Toolbox.Document.Internal.Types: instance Show Catalog
- Pdf.Toolbox.Document.Internal.Types: instance Show Document
- Pdf.Toolbox.Document.Internal.Types: instance Show FontDict
- Pdf.Toolbox.Document.Internal.Types: instance Show Info
- Pdf.Toolbox.Document.Internal.Types: instance Show Page
- Pdf.Toolbox.Document.Internal.Types: instance Show PageNode
- Pdf.Toolbox.Document.Internal.Types: instance Show PageTree
- Pdf.Toolbox.Document.Pdf: instance (Monad m, Functor m) => Applicative (Pdf' m)
- Pdf.Toolbox.Document.Pdf: instance Functor m => Functor (Pdf' m)
- Pdf.Toolbox.Document.Pdf: instance Monad m => Monad (Pdf' m)
- Pdf.Toolbox.Document.Pdf: instance MonadIO m => MonadIO (Pdf' m)
- Pdf.Toolbox.Document.Pdf: instance MonadIO m => MonadPdf (Pdf' m)
- Pdf.Toolbox.Document.Pdf: instance MonadTrans Pdf'
- Pdf.Toolbox.Document.Types: instance Show a => Show (Rectangle a)
+ Pdf.Toolbox.Document.Encryption: instance GHC.Show.Show Pdf.Toolbox.Document.Encryption.Algorithm
+ Pdf.Toolbox.Document.FontDict: instance GHC.Classes.Eq Pdf.Toolbox.Document.FontDict.FontSubtype
+ Pdf.Toolbox.Document.FontDict: instance GHC.Show.Show Pdf.Toolbox.Document.FontDict.FontSubtype
+ Pdf.Toolbox.Document.Internal.Types: instance GHC.Show.Show Pdf.Toolbox.Document.Internal.Types.Catalog
+ Pdf.Toolbox.Document.Internal.Types: instance GHC.Show.Show Pdf.Toolbox.Document.Internal.Types.Document
+ Pdf.Toolbox.Document.Internal.Types: instance GHC.Show.Show Pdf.Toolbox.Document.Internal.Types.FontDict
+ Pdf.Toolbox.Document.Internal.Types: instance GHC.Show.Show Pdf.Toolbox.Document.Internal.Types.Info
+ Pdf.Toolbox.Document.Internal.Types: instance GHC.Show.Show Pdf.Toolbox.Document.Internal.Types.Page
+ Pdf.Toolbox.Document.Internal.Types: instance GHC.Show.Show Pdf.Toolbox.Document.Internal.Types.PageNode
+ Pdf.Toolbox.Document.Internal.Types: instance GHC.Show.Show Pdf.Toolbox.Document.Internal.Types.PageTree
+ Pdf.Toolbox.Document.Pdf: instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Pdf.Toolbox.Document.Pdf.Pdf' m)
+ Pdf.Toolbox.Document.Pdf: instance Control.Monad.IO.Class.MonadIO m => Pdf.Toolbox.Document.Monad.MonadPdf (Pdf.Toolbox.Document.Pdf.Pdf' m)
+ Pdf.Toolbox.Document.Pdf: instance Control.Monad.Trans.Class.MonadTrans Pdf.Toolbox.Document.Pdf.Pdf'
+ Pdf.Toolbox.Document.Pdf: instance GHC.Base.Functor m => GHC.Base.Functor (Pdf.Toolbox.Document.Pdf.Pdf' m)
+ Pdf.Toolbox.Document.Pdf: instance GHC.Base.Monad m => GHC.Base.Applicative (Pdf.Toolbox.Document.Pdf.Pdf' m)
+ Pdf.Toolbox.Document.Pdf: instance GHC.Base.Monad m => GHC.Base.Monad (Pdf.Toolbox.Document.Pdf.Pdf' m)
+ Pdf.Toolbox.Document.Types: instance GHC.Show.Show a => GHC.Show.Show (Pdf.Toolbox.Document.Types.Rectangle a)

Files

changelog.md view
@@ -1,3 +1,8 @@++0.0.6.0++* switch to errors-2.0+ 0.0.5.1  * support ghc-7.10.1
lib/Pdf/Toolbox/Document/Encryption.hs view
@@ -71,7 +71,7 @@                     -> PdfE m (Maybe Decryptor) mkStandardDecryptor tr enc pass = do   Name filterType <- lookupDict "Filter" enc >>= fromObject-  unless (filterType == "Standard") $ left $ UnexpectedError $ "Unsupported encryption handler: " ++ show filterType+  unless (filterType == "Standard") $ throwE $ UnexpectedError $ "Unsupported encryption handler: " ++ show filterType   vVal <- lookupDict "V" enc >>= fromObject >>= intValue    if vVal == 4@@ -85,7 +85,7 @@            2 -> do              len <- lookupDict "Length" enc >>= fromObject >>= intValue              return $ len `div` 8-           _ -> left $ UnexpectedError $ "Unsuported encryption handler version: " ++ show vVal+           _ -> throwE $ UnexpectedError $ "Unsuported encryption handler version: " ++ show vVal      ekey <- mkKey tr enc pass n     ok <- verifyKey tr enc ekey@@ -105,13 +105,13 @@         case algName of           "V2" -> return V2           "AESV2" -> return AESV2-          _ -> left $ UnexpectedError $ "Unknown crypto method: " ++ show algName+          _ -> throwE $ UnexpectedError $ "Unknown crypto method: " ++ show algName       ekey <- mkKey tr enc pass n       return (name, (ekey, n, alg))      (stdCfKey, _, _) <-       case lookup "StdCF" keysMap of-        Nothing -> left $ UnexpectedError "StdCF is missing"+        Nothing -> throwE $ UnexpectedError "StdCF is missing"         Just v -> return v     ok <- verifyKey tr enc stdCfKey     if not ok@@ -121,13 +121,13 @@         strFName <- lookupDict "StrF" enc >>= toName         (strFKey, strFN, strFAlg) <-           case lookup strFName keysMap of-            Nothing -> left $ UnexpectedError $ "Crypto filter not found: " ++ show strFName+            Nothing -> throwE $ UnexpectedError $ "Crypto filter not found: " ++ show strFName             Just v -> return v          stmFName <- lookupDict "StmF" enc >>= toName         (stmFKey, stmFN, stmFAlg) <-           case lookup stmFName keysMap of-            Nothing -> left $ UnexpectedError $ "Crypto filter not found: " ++ show stmFName+            Nothing -> throwE $ UnexpectedError $ "Crypto filter not found: " ++ show stmFName             Just v -> return v          return $ Just $ \ref scope is ->@@ -143,7 +143,7 @@   Str idVal <- do     Array ids <- lookupDict "ID" tr >>= fromObject     case ids of-      [] -> left $ UnexpectedError $ "ID array is empty"+      [] -> throwE $ UnexpectedError $ "ID array is empty"       (x:_) -> fromObject x   rVal <- lookupDict "R" enc >>= fromObject >>= intValue @@ -170,7 +170,7 @@   Str idVal <- do     Array ids <- lookupDict "ID" tr >>= fromObject     case ids of-      [] -> left $ UnexpectedError $ "ID array is empty"+      [] -> throwE $ UnexpectedError $ "ID array is empty"       (x:_) -> fromObject x   rVal <- lookupDict "R" enc >>= fromObject >>= intValue   Str uVal <- lookupDict "U" enc >>= fromObject
lib/Pdf/Toolbox/Document/FontDict.hs view
@@ -41,7 +41,7 @@     "MMType1" -> return FontMMType1     "Type3" -> return FontType3     "TrueType" -> return FontTrueType-    _ -> left $ UnexpectedError $ "Unexpected font subtype: " ++ show str+    _ -> throwE $ UnexpectedError $ "Unexpected font subtype: " ++ show str  -- | Load font info for the font fontDictLoadInfo :: (MonadPdf m, MonadIO m) => FontDict -> PdfE m FontInfo@@ -62,7 +62,7 @@             e' <- fromObject e >>= realValue             f' <- fromObject f >>= realValue             return $ Transform a' b' c' d' e' f'-          _ -> left $ UnexpectedError "FontMatrix: wrong number of elements"+          _ -> throwE $ UnexpectedError "FontMatrix: wrong number of elements"       return $ FontInfoSimple fi {         fiSimpleFontMatrix = fontMatrix         }@@ -75,7 +75,7 @@     descFontArr <- lookupDict "DescendantFonts" fontDict >>= deref >>= fromObject     case descFontArr of       Array [o] -> deref o >>= fromObject-      _ -> left $ UnexpectedError "Unexpected value of DescendantFonts key in font dictionary"+      _ -> throwE $ UnexpectedError "Unexpected value of DescendantFonts key in font dictionary"   defaultWidth <-     case lookupDict' "DW" descFont of       Nothing -> return 1000@@ -153,7 +153,7 @@         (ONumber n : rest) -> do           n' <- fromIntegral <$> intValue n           go [] n' rest-        _ -> left $ UnexpectedError "Differences array: the first object should be a number"+        _ -> throwE $ UnexpectedError "Differences array: the first object should be a number"   where   go res _ [] = return res   go res n (o:rest) =@@ -162,7 +162,7 @@         n'' <- fromIntegral <$> intValue n'         go res n'' rest       (OName (Name bs)) -> go (((n, bs)) : res) (n + 1) rest-      _ -> left $ UnexpectedError $ "Differences array: unexpected object: " ++ show o+      _ -> throwE $ UnexpectedError $ "Differences array: unexpected object: " ++ show o  loadUnicodeCMap :: (MonadPdf m, MonadIO m) => Dict -> PdfE m (Maybe UnicodeCMap) loadUnicodeCMap fontDict =@@ -176,6 +176,6 @@           Stream _ is <- streamContent ref s           content <- mconcat <$> liftIO (Streams.toList is)           case parseUnicodeCMap content of-            Left e -> left $ UnexpectedError $ "can't parse cmap: " ++ show e+            Left e -> throwE $ UnexpectedError $ "can't parse cmap: " ++ show e             Right cmap -> return $ Just cmap-        _ -> left $ UnexpectedError "ToUnicode: not a stream"+        _ -> throwE $ UnexpectedError "ToUnicode: not a stream"
lib/Pdf/Toolbox/Document/Internal/Util.hs view
@@ -17,7 +17,7 @@ ensureType :: Monad m => Name -> Dict -> PdfE m () ensureType name dict = do   n <- dictionaryType dict-  unless (n == name) $ left $ UnexpectedError $ "Expected type: " ++ show name ++ ", but found: " ++ show n+  unless (n == name) $ throwE $ UnexpectedError $ "Expected type: " ++ show name ++ ", but found: " ++ show n  -- | Get dictionary type, name at key \"Type\" dictionaryType :: Monad m => Dict -> PdfE m Name
lib/Pdf/Toolbox/Document/Page.hs view
@@ -38,7 +38,7 @@   node <- loadPageNode ref   case node of     PageTreeNode n -> return n-    PageTreeLeaf _ -> left $ UnexpectedError "page parent should be a note, but leaf should"+    PageTreeLeaf _ -> throwE $ UnexpectedError "page parent should be a note, but leaf should"  -- | List of references to page's content streams pageContents :: MonadPdf m => Page -> PdfE m [Ref]@@ -52,9 +52,9 @@       case o of         OStream _ -> return [ref]         OArray (Array objs) -> mapM fromObject objs-        _ -> left $ UnexpectedError $ "Unexpected value in page content ref: " ++ show o+        _ -> throwE $ UnexpectedError $ "Unexpected value in page content ref: " ++ show o     Just (OArray (Array objs)) -> mapM fromObject objs-    _ -> left $ UnexpectedError "Unexpected value in page contents"+    _ -> throwE $ UnexpectedError "Unexpected value in page contents"  -- | Media box, inheritable pageMediaBox :: MonadPdf m => Page -> PdfE m (Rectangle Double)@@ -72,7 +72,7 @@                   PageTreeNode node -> do                     parent <- pageNodeParent node                     case parent of-                      Nothing -> left $ UnexpectedError $ "Media box not found"+                      Nothing -> throwE $ UnexpectedError $ "Media box not found"                       Just p -> return $ PageTreeNode p                   PageTreeLeaf page -> PageTreeNode `liftM` pageParentNode page       mediaBox parent
lib/Pdf/Toolbox/Document/PageNode.hs view
@@ -50,7 +50,7 @@   case nodeType of     "Pages" -> return $ PageTreeNode $ PageNode ref node     "Page" -> return $ PageTreeLeaf $ Page ref node-    _ -> left $ UnexpectedError $ "Unexpected page tree node type: " ++ show nodeType+    _ -> throwE $ UnexpectedError $ "Unexpected page tree node type: " ++ show nodeType  -- | Find page by it's number --@@ -62,7 +62,7 @@ pageNodePageByNum node num = annotateError ("page #" ++ show num ++ " for node: " ++ show node) $ do   pageNodeKids node >>= loop num   where-  loop _ [] = left $ UnexpectedError "Page not found"+  loop _ [] = throwE $ UnexpectedError "Page not found"   loop i (x:xs) = do     kid <- loadPageNode x     case kid  of
lib/Pdf/Toolbox/Document/Pdf.hs view
@@ -122,7 +122,7 @@         prev <- prevXRef ris xref         case prev of           Just xref' -> loop xref'-          Nothing -> left $ UnexpectedError "There are no more xrefs"+          Nothing -> throwE $ UnexpectedError "There are no more xrefs"  lookupXRefEntry :: MonadIO m => Ref -> XRef -> Pdf m (Maybe XRefEntry) lookupXRefEntry ref (XRefTable off) = do@@ -141,7 +141,7 @@     case obj of       ONumber _ -> fromObject obj >>= intValue       ORef ref -> lookupObject ref >>= fromObject >>= intValue-      _ -> left $ UnexpectedError $ "Unexpected length object in stream: " ++ show obj+      _ -> throwE $ UnexpectedError $ "Unexpected length object in stream: " ++ show obj   ris <- getRIS   filters <- lift $ Pdf' $ gets stFilters   decodedStreamContent ris filters decryptor len s@@ -186,7 +186,7 @@  -- | Execute PDF action with 'RIS' runPdf :: MonadIO m => RIS -> [StreamFilter] -> Pdf m a -> m (Either PdfError a)-runPdf ris filters action = runPdf' ris filters $ runEitherT action+runPdf ris filters action = runPdf' ris filters $ runExceptT action  -- | Execute PDF action with 'Handle' runPdfWithHandle :: MonadIO m => Handle -> [StreamFilter] -> Pdf m a -> m (Either PdfError a)@@ -230,7 +230,7 @@   ris <- getRIS   tr <- lastXRef ris >>= trailer ris   enc <- case lookupDict' "Encrypt" tr of-    Nothing -> left $ UnexpectedError "The document is not encrypted"+    Nothing -> throwE $ UnexpectedError "The document is not encrypted"     Just enc -> deref enc >>= fromObject   decryptor <- mkStandardDecryptor tr enc $ BS.take 32 $ pass `mappend` defaultUserPassword   lift $ Pdf' $ modify $ \s -> s {stDecryptor = decryptor}
lib/Pdf/Toolbox/Document/Types.hs view
@@ -22,4 +22,4 @@   c <- fromObject c' >>= realValue   d <- fromObject d' >>= realValue   return $ Rectangle a b c d-rectangleFromArray array = left $ UnexpectedError $ "rectangleFromArray: " ++ show array+rectangleFromArray array = throwE $ UnexpectedError $ "rectangleFromArray: " ++ show array
pdf-toolbox-document.cabal view
@@ -1,5 +1,5 @@ name:                pdf-toolbox-document-version:             0.0.5.1+version:             0.0.6.0 synopsis:            A collection of tools for processing PDF files. license:             BSD3 license-file:        LICENSE@@ -47,5 +47,5 @@                        cipher-aes,                        cryptohash,                        crypto-api,-                       pdf-toolbox-core >=0.0.2 && <0.0.4,-                       pdf-toolbox-content ==0.0.3.*+                       pdf-toolbox-core ==0.0.4.*,+                       pdf-toolbox-content ==0.0.4.*