--------------------------------------------------------- -- | -- Copyright : (c) 2006-2016, alpheccar.org -- License : BSD-style -- -- Maintainer : misc@NOSPAMalpheccar.org -- Stability : experimental -- Portability : portable -- -- PDF Actions --------------------------------------------------------- module Graphics.PDF.Action( -- * Actions -- ** Types Action , GoToURL(..) -- ** Functions ) where import Graphics.PDF.LowLevel.Types import qualified Data.Map.Strict as M import Network.URI -- Media action --data MediaAction = Play -- | Stop -- | Pause -- | Resume -- deriving(Enum) class PdfObject a => Action a -- | Action of going to an URL newtype GoToURL = GoToURL URI --data Rendition = Rendition --instance PdfObject Rendition where -- toPDF a = toPDF . PDFDictionary . M.fromList $ -- [ (PDFName "Type",AnyPdfObject . PDFName $ "Rendition") -- , (PDFName "S",AnyPdfObject . PDFName $ "MR") -- , (PDFName "C",AnyPdfObject movie) -- ] -- where -- movie = PDFDictionary . M.fromList $ -- [ (PDFName "Type",AnyPdfObject . PDFName $ "MediaClip") -- , (PDFName "S",AnyPdfObject . PDFName $ "MCD") -- , (PDFName "CT",AnyPdfObject . toPDFString $ "video/3gpp") -- , (PDFName "D",AnyPdfObject (toPDFString "17.3gp")) -- ] -- Action to control a media --data ControlMedia = ControlMedia MediaAction Int (PDFReference Rendition) urlToPdfString :: URI -> AsciiString urlToPdfString :: URI -> AsciiString urlToPdfString URI uri = let s :: String s = (String -> String) -> URI -> String -> String uriToString forall a. a -> a id URI uri String "" in String -> AsciiString toAsciiString String s instance PdfObject GoToURL where toPDF :: GoToURL -> Builder toPDF (GoToURL URI s) = forall a. PdfObject a => a -> Builder toPDF forall b c a. (b -> c) -> (a -> b) -> a -> c . Map PDFName AnyPdfObject -> PDFDictionary PDFDictionary forall b c a. (b -> c) -> (a -> b) -> a -> c . forall k a. Ord k => [(k, a)] -> Map k a M.fromList forall a b. (a -> b) -> a -> b $ [ (String -> PDFName PDFName String "Type",forall a. (PdfObject a, PdfLengthInfo a) => a -> AnyPdfObject AnyPdfObject forall b c a. (b -> c) -> (a -> b) -> a -> c . String -> PDFName PDFName forall a b. (a -> b) -> a -> b $ String "Action") , (String -> PDFName PDFName String "S",forall a. (PdfObject a, PdfLengthInfo a) => a -> AnyPdfObject AnyPdfObject (String -> PDFName PDFName String "URI")) , (String -> PDFName PDFName String "URI",forall a. (PdfObject a, PdfLengthInfo a) => a -> AnyPdfObject AnyPdfObject (URI -> AsciiString urlToPdfString URI s)) ] instance Action GoToURL instance PdfLengthInfo GoToURL where --instance PdfObject ControlMedia where -- toPDF (ControlMedia operation relatedScreenAnnotation rendition) = toPDF . PDFDictionary . M.fromList $ -- [ (PDFName "Type",AnyPdfObject . PDFName $ "Action") -- , (PDFName "S",AnyPdfObject (PDFName "Rendition")) -- , (PDFName "R",AnyPdfObject rendition) -- , (PDFName "OP",AnyPdfObject . PDFInteger $ (fromEnum operation)) -- , (PDFName "AN",AnyPdfObject $ (PDFReference relatedScreenAnnotation :: PDFReference AnyPdfObject)) -- ] -- --instance Action ControlMedia