-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
a place to collect useful PDF transformations
- Loading branch information
Dylan McNamee
committed
May 4, 2011
1 parent
e97c0b2
commit 7b13eff
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |