Skip to content

Commit

Permalink
a place to collect useful PDF transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan McNamee committed May 4, 2011
1 parent e97c0b2 commit 7b13eff
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Text/PDF/Transformations.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--------------------------------------------------------------------
-- |
-- Module : Text.PDF.Transformations
-- Description : Functions for transforming PDF content.
-- Copyright : (c) Dylan McNamee 2011
-- License : BSD3
--
-- Maintainer: Dylan McNamee <dylan@galois.com>
-- Stability : provisional
-- Portability: portable
--
--------------------------------------------------------------------
module Text.PDF.Transformations where

import Text.PDF.Types

-- Overlay a string each page of a document
watermarkDocument :: PDFDocumentParsed -> String -> PDFDocumentParsed
watermarkDocument doc@(PDFDocumentParsed pages {- _dict -} ) markString = doc {
pageList = Prelude.map (appendStreamToPage markString) pages
-- , globals = dict
}

appendStreamToPage :: String -> PDFPageParsed -> PDFPageParsed
appendStreamToPage string page = page {
contents = case (contents page) of
(PDFStream s) -> PDFArray [(PDFStream s), (PDFStream string)]
(PDFArray streams) -> PDFArray (streams ++ [(PDFStream string)] )
_ -> error "appendStreamToPage: neither Stream nor Array in contents of a page"
}

0 comments on commit 7b13eff

Please # to comment.