module Graphics.PDF.Action(
Action
, GoToURL(..)
) where
import Graphics.PDF.LowLevel.Types
import Network.URI
class PdfObject a => Action a
newtype GoToURL = GoToURL URI
urlToPdfString :: URI -> AsciiString
urlToPdfString :: URI -> AsciiString
urlToPdfString URI
uri =
let s :: String
s = (String -> String) -> URI -> String -> String
uriToString String -> String
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) = PDFDictionary -> Builder
forall a. PdfObject a => a -> Builder
toPDF (PDFDictionary -> Builder)
-> ([(PDFName, AnyPdfObject)] -> PDFDictionary)
-> [(PDFName, AnyPdfObject)]
-> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(PDFName, AnyPdfObject)] -> PDFDictionary
dictFromList ([(PDFName, AnyPdfObject)] -> Builder)
-> [(PDFName, AnyPdfObject)] -> Builder
forall a b. (a -> b) -> a -> b
$
[ String -> PDFName -> (PDFName, AnyPdfObject)
forall a.
(PdfObject a, PdfLengthInfo a) =>
String -> a -> (PDFName, AnyPdfObject)
entry String
"Type" (String -> PDFName
PDFName (String -> PDFName) -> String -> PDFName
forall a b. (a -> b) -> a -> b
$ String
"Action")
, String -> PDFName -> (PDFName, AnyPdfObject)
forall a.
(PdfObject a, PdfLengthInfo a) =>
String -> a -> (PDFName, AnyPdfObject)
entry String
"S" (String -> PDFName
PDFName String
"URI")
, String -> AsciiString -> (PDFName, AnyPdfObject)
forall a.
(PdfObject a, PdfLengthInfo a) =>
String -> a -> (PDFName, AnyPdfObject)
entry String
"URI" (URI -> AsciiString
urlToPdfString URI
s)
]
instance Action GoToURL
instance PdfLengthInfo GoToURL where