{-# LANGUAGE CPP #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
module Graphics.PDF.LowLevel.Types where
import qualified Data.Map.Strict as M
import Data.List(intersperse)
import Data.Int
import Control.Monad.State
import Control.Monad.Writer
import Data.Binary.Builder(Builder,fromByteString)
import Graphics.PDF.LowLevel.Serializer
import Data.Complex
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy.Internal as L(ByteString(..))
import Data.Text.Encoding
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as C
import Data.Word
import Data.Char(ord)
import Text.Printf(printf)
data SpecialChar = NormalChar !Char
| BreakingHyphen
| BiggerSpace
| NormalSpace
class PdfObject a where
toPDF :: a -> Builder
class PdfLengthInfo a where
pdfLengthInfo :: a -> Maybe (Int64 , PDFReference MaybeLength)
pdfLengthInfo a
_ = forall a. Maybe a
Nothing
data AnyPdfObject = forall a . (PdfObject a, PdfLengthInfo a) => AnyPdfObject !a
instance PdfObject AnyPdfObject where
toPDF :: AnyPdfObject -> Builder
toPDF (AnyPdfObject a
a) = forall a. PdfObject a => a -> Builder
toPDF a
a
instance PdfLengthInfo AnyPdfObject where
pdfLengthInfo :: AnyPdfObject -> Maybe (Int64, PDFReference MaybeLength)
pdfLengthInfo (AnyPdfObject a
a) = forall a.
PdfLengthInfo a =>
a -> Maybe (Int64, PDFReference MaybeLength)
pdfLengthInfo a
a
newtype PDFInteger = PDFInteger Int deriving(PDFInteger -> PDFInteger -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PDFInteger -> PDFInteger -> Bool
$c/= :: PDFInteger -> PDFInteger -> Bool
== :: PDFInteger -> PDFInteger -> Bool
$c== :: PDFInteger -> PDFInteger -> Bool
Eq,Int -> PDFInteger -> ShowS
[PDFInteger] -> ShowS
PDFInteger -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PDFInteger] -> ShowS
$cshowList :: [PDFInteger] -> ShowS
show :: PDFInteger -> String
$cshow :: PDFInteger -> String
showsPrec :: Int -> PDFInteger -> ShowS
$cshowsPrec :: Int -> PDFInteger -> ShowS
Show,Eq PDFInteger
PDFInteger -> PDFInteger -> Bool
PDFInteger -> PDFInteger -> Ordering
PDFInteger -> PDFInteger -> PDFInteger
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: PDFInteger -> PDFInteger -> PDFInteger
$cmin :: PDFInteger -> PDFInteger -> PDFInteger
max :: PDFInteger -> PDFInteger -> PDFInteger
$cmax :: PDFInteger -> PDFInteger -> PDFInteger
>= :: PDFInteger -> PDFInteger -> Bool
$c>= :: PDFInteger -> PDFInteger -> Bool
> :: PDFInteger -> PDFInteger -> Bool
$c> :: PDFInteger -> PDFInteger -> Bool
<= :: PDFInteger -> PDFInteger -> Bool
$c<= :: PDFInteger -> PDFInteger -> Bool
< :: PDFInteger -> PDFInteger -> Bool
$c< :: PDFInteger -> PDFInteger -> Bool
compare :: PDFInteger -> PDFInteger -> Ordering
$ccompare :: PDFInteger -> PDFInteger -> Ordering
Ord,Integer -> PDFInteger
PDFInteger -> PDFInteger
PDFInteger -> PDFInteger -> PDFInteger
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> PDFInteger
$cfromInteger :: Integer -> PDFInteger
signum :: PDFInteger -> PDFInteger
$csignum :: PDFInteger -> PDFInteger
abs :: PDFInteger -> PDFInteger
$cabs :: PDFInteger -> PDFInteger
negate :: PDFInteger -> PDFInteger
$cnegate :: PDFInteger -> PDFInteger
* :: PDFInteger -> PDFInteger -> PDFInteger
$c* :: PDFInteger -> PDFInteger -> PDFInteger
- :: PDFInteger -> PDFInteger -> PDFInteger
$c- :: PDFInteger -> PDFInteger -> PDFInteger
+ :: PDFInteger -> PDFInteger -> PDFInteger
$c+ :: PDFInteger -> PDFInteger -> PDFInteger
Num)
newtype PDFLength = PDFLength Int64 deriving(PDFLength -> PDFLength -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PDFLength -> PDFLength -> Bool
$c/= :: PDFLength -> PDFLength -> Bool
== :: PDFLength -> PDFLength -> Bool
$c== :: PDFLength -> PDFLength -> Bool
Eq,Int -> PDFLength -> ShowS
[PDFLength] -> ShowS
PDFLength -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PDFLength] -> ShowS
$cshowList :: [PDFLength] -> ShowS
show :: PDFLength -> String
$cshow :: PDFLength -> String
showsPrec :: Int -> PDFLength -> ShowS
$cshowsPrec :: Int -> PDFLength -> ShowS
Show,Eq PDFLength
PDFLength -> PDFLength -> Bool
PDFLength -> PDFLength -> Ordering
PDFLength -> PDFLength -> PDFLength
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: PDFLength -> PDFLength -> PDFLength
$cmin :: PDFLength -> PDFLength -> PDFLength
max :: PDFLength -> PDFLength -> PDFLength
$cmax :: PDFLength -> PDFLength -> PDFLength
>= :: PDFLength -> PDFLength -> Bool
$c>= :: PDFLength -> PDFLength -> Bool
> :: PDFLength -> PDFLength -> Bool
$c> :: PDFLength -> PDFLength -> Bool
<= :: PDFLength -> PDFLength -> Bool
$c<= :: PDFLength -> PDFLength -> Bool
< :: PDFLength -> PDFLength -> Bool
$c< :: PDFLength -> PDFLength -> Bool
compare :: PDFLength -> PDFLength -> Ordering
$ccompare :: PDFLength -> PDFLength -> Ordering
Ord,Integer -> PDFLength
PDFLength -> PDFLength
PDFLength -> PDFLength -> PDFLength
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> PDFLength
$cfromInteger :: Integer -> PDFLength
signum :: PDFLength -> PDFLength
$csignum :: PDFLength -> PDFLength
abs :: PDFLength -> PDFLength
$cabs :: PDFLength -> PDFLength
negate :: PDFLength -> PDFLength
$cnegate :: PDFLength -> PDFLength
* :: PDFLength -> PDFLength -> PDFLength
$c* :: PDFLength -> PDFLength -> PDFLength
- :: PDFLength -> PDFLength -> PDFLength
$c- :: PDFLength -> PDFLength -> PDFLength
+ :: PDFLength -> PDFLength -> PDFLength
$c+ :: PDFLength -> PDFLength -> PDFLength
Num)
data MaybeLength = UnknownLength
| KnownLength !PDFLength
instance PdfObject MaybeLength where
toPDF :: MaybeLength -> Builder
toPDF (KnownLength PDFLength
a) = forall a. PdfObject a => a -> Builder
toPDF PDFLength
a
toPDF (MaybeLength
UnknownLength) = forall a. HasCallStack => String -> a
error String
"Trying to process an unknown length during PDF generation"
instance PdfLengthInfo MaybeLength where
type PDFFloat = Double
instance PdfObject PDFInteger where
toPDF :: PDFInteger -> Builder
toPDF (PDFInteger Int
a) = forall s a. SerializeValue s a => a -> s
serialize Int
a
instance PdfLengthInfo PDFInteger where
instance PdfObject Int where
toPDF :: Int -> Builder
toPDF Int
a = forall s a. SerializeValue s a => a -> s
serialize Int
a
instance PdfLengthInfo Int where
instance PdfObject PDFLength where
toPDF :: PDFLength -> Builder
toPDF (PDFLength Int64
a) = forall s a. SerializeValue s a => a -> s
serialize (forall a. Show a => a -> String
show Int64
a)
instance PdfLengthInfo PDFLength where
instance PdfObject PDFFloat where
toPDF :: PDFFloat -> Builder
toPDF PDFFloat
a = forall s a. SerializeValue s a => a -> s
serialize PDFFloat
a
instance PdfLengthInfo PDFFloat where
instance PdfObject (Complex PDFFloat) where
toPDF :: Complex PDFFloat -> Builder
toPDF (PDFFloat
x :+ PDFFloat
y) = forall a. Monoid a => [a] -> a
mconcat [ forall s a. SerializeValue s a => a -> s
serialize PDFFloat
x
, forall s a. SerializeValue s a => a -> s
serialize Char
' '
, forall s a. SerializeValue s a => a -> s
serialize PDFFloat
y
]
instance PdfLengthInfo (Complex PDFFloat) where
instance PdfObject Bool where
toPDF :: Bool -> Builder
toPDF (Bool
True) = forall s a. SerializeValue s a => a -> s
serialize (String
"true" :: String)
toPDF (Bool
False) = forall s a. SerializeValue s a => a -> s
serialize (String
"false" :: String)
instance PdfLengthInfo Bool where
newtype PDFString = PDFString S.ByteString deriving(PDFString -> PDFString -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PDFString -> PDFString -> Bool
$c/= :: PDFString -> PDFString -> Bool
== :: PDFString -> PDFString -> Bool
$c== :: PDFString -> PDFString -> Bool
Eq,Eq PDFString
PDFString -> PDFString -> Bool
PDFString -> PDFString -> Ordering
PDFString -> PDFString -> PDFString
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: PDFString -> PDFString -> PDFString
$cmin :: PDFString -> PDFString -> PDFString
max :: PDFString -> PDFString -> PDFString
$cmax :: PDFString -> PDFString -> PDFString
>= :: PDFString -> PDFString -> Bool
$c>= :: PDFString -> PDFString -> Bool
> :: PDFString -> PDFString -> Bool
$c> :: PDFString -> PDFString -> Bool
<= :: PDFString -> PDFString -> Bool
$c<= :: PDFString -> PDFString -> Bool
< :: PDFString -> PDFString -> Bool
$c< :: PDFString -> PDFString -> Bool
compare :: PDFString -> PDFString -> Ordering
$ccompare :: PDFString -> PDFString -> Ordering
Ord,Int -> PDFString -> ShowS
[PDFString] -> ShowS
PDFString -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PDFString] -> ShowS
$cshowList :: [PDFString] -> ShowS
show :: PDFString -> String
$cshow :: PDFString -> String
showsPrec :: Int -> PDFString -> ShowS
$cshowsPrec :: Int -> PDFString -> ShowS
Show)
newtype PDFGlyph = PDFGlyph S.ByteString deriving(PDFGlyph -> PDFGlyph -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PDFGlyph -> PDFGlyph -> Bool
$c/= :: PDFGlyph -> PDFGlyph -> Bool
== :: PDFGlyph -> PDFGlyph -> Bool
$c== :: PDFGlyph -> PDFGlyph -> Bool
Eq,Eq PDFGlyph
PDFGlyph -> PDFGlyph -> Bool
PDFGlyph -> PDFGlyph -> Ordering
PDFGlyph -> PDFGlyph -> PDFGlyph
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: PDFGlyph -> PDFGlyph -> PDFGlyph
$cmin :: PDFGlyph -> PDFGlyph -> PDFGlyph
max :: PDFGlyph -> PDFGlyph -> PDFGlyph
$cmax :: PDFGlyph -> PDFGlyph -> PDFGlyph
>= :: PDFGlyph -> PDFGlyph -> Bool
$c>= :: PDFGlyph -> PDFGlyph -> Bool
> :: PDFGlyph -> PDFGlyph -> Bool
$c> :: PDFGlyph -> PDFGlyph -> Bool
<= :: PDFGlyph -> PDFGlyph -> Bool
$c<= :: PDFGlyph -> PDFGlyph -> Bool
< :: PDFGlyph -> PDFGlyph -> Bool
$c< :: PDFGlyph -> PDFGlyph -> Bool
compare :: PDFGlyph -> PDFGlyph -> Ordering
$ccompare :: PDFGlyph -> PDFGlyph -> Ordering
Ord,Int -> PDFGlyph -> ShowS
[PDFGlyph] -> ShowS
PDFGlyph -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PDFGlyph] -> ShowS
$cshowList :: [PDFGlyph] -> ShowS
show :: PDFGlyph -> String
$cshow :: PDFGlyph -> String
showsPrec :: Int -> PDFGlyph -> ShowS
$cshowsPrec :: Int -> PDFGlyph -> ShowS
Show)
newtype EscapedPDFGlyph = EscapedPDFGlyph S.ByteString deriving(EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
$c/= :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
== :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
$c== :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
Eq,Eq EscapedPDFGlyph
EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
EscapedPDFGlyph -> EscapedPDFGlyph -> Ordering
EscapedPDFGlyph -> EscapedPDFGlyph -> EscapedPDFGlyph
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: EscapedPDFGlyph -> EscapedPDFGlyph -> EscapedPDFGlyph
$cmin :: EscapedPDFGlyph -> EscapedPDFGlyph -> EscapedPDFGlyph
max :: EscapedPDFGlyph -> EscapedPDFGlyph -> EscapedPDFGlyph
$cmax :: EscapedPDFGlyph -> EscapedPDFGlyph -> EscapedPDFGlyph
>= :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
$c>= :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
> :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
$c> :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
<= :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
$c<= :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
< :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
$c< :: EscapedPDFGlyph -> EscapedPDFGlyph -> Bool
compare :: EscapedPDFGlyph -> EscapedPDFGlyph -> Ordering
$ccompare :: EscapedPDFGlyph -> EscapedPDFGlyph -> Ordering
Ord,Int -> EscapedPDFGlyph -> ShowS
[EscapedPDFGlyph] -> ShowS
EscapedPDFGlyph -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EscapedPDFGlyph] -> ShowS
$cshowList :: [EscapedPDFGlyph] -> ShowS
show :: EscapedPDFGlyph -> String
$cshow :: EscapedPDFGlyph -> String
showsPrec :: Int -> EscapedPDFGlyph -> ShowS
$cshowsPrec :: Int -> EscapedPDFGlyph -> ShowS
Show)
newtype AsciiString = AsciiString S.ByteString deriving(AsciiString -> AsciiString -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AsciiString -> AsciiString -> Bool
$c/= :: AsciiString -> AsciiString -> Bool
== :: AsciiString -> AsciiString -> Bool
$c== :: AsciiString -> AsciiString -> Bool
Eq,Eq AsciiString
AsciiString -> AsciiString -> Bool
AsciiString -> AsciiString -> Ordering
AsciiString -> AsciiString -> AsciiString
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AsciiString -> AsciiString -> AsciiString
$cmin :: AsciiString -> AsciiString -> AsciiString
max :: AsciiString -> AsciiString -> AsciiString
$cmax :: AsciiString -> AsciiString -> AsciiString
>= :: AsciiString -> AsciiString -> Bool
$c>= :: AsciiString -> AsciiString -> Bool
> :: AsciiString -> AsciiString -> Bool
$c> :: AsciiString -> AsciiString -> Bool
<= :: AsciiString -> AsciiString -> Bool
$c<= :: AsciiString -> AsciiString -> Bool
< :: AsciiString -> AsciiString -> Bool
$c< :: AsciiString -> AsciiString -> Bool
compare :: AsciiString -> AsciiString -> Ordering
$ccompare :: AsciiString -> AsciiString -> Ordering
Ord,Int -> AsciiString -> ShowS
[AsciiString] -> ShowS
AsciiString -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AsciiString] -> ShowS
$cshowList :: [AsciiString] -> ShowS
show :: AsciiString -> String
$cshow :: AsciiString -> String
showsPrec :: Int -> AsciiString -> ShowS
$cshowsPrec :: Int -> AsciiString -> ShowS
Show)
newtype EscapedAsciiString = EscapedAsciiString S.ByteString deriving(EscapedAsciiString -> EscapedAsciiString -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EscapedAsciiString -> EscapedAsciiString -> Bool
$c/= :: EscapedAsciiString -> EscapedAsciiString -> Bool
== :: EscapedAsciiString -> EscapedAsciiString -> Bool
$c== :: EscapedAsciiString -> EscapedAsciiString -> Bool
Eq,Eq EscapedAsciiString
EscapedAsciiString -> EscapedAsciiString -> Bool
EscapedAsciiString -> EscapedAsciiString -> Ordering
EscapedAsciiString -> EscapedAsciiString -> EscapedAsciiString
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: EscapedAsciiString -> EscapedAsciiString -> EscapedAsciiString
$cmin :: EscapedAsciiString -> EscapedAsciiString -> EscapedAsciiString
max :: EscapedAsciiString -> EscapedAsciiString -> EscapedAsciiString
$cmax :: EscapedAsciiString -> EscapedAsciiString -> EscapedAsciiString
>= :: EscapedAsciiString -> EscapedAsciiString -> Bool
$c>= :: EscapedAsciiString -> EscapedAsciiString -> Bool
> :: EscapedAsciiString -> EscapedAsciiString -> Bool
$c> :: EscapedAsciiString -> EscapedAsciiString -> Bool
<= :: EscapedAsciiString -> EscapedAsciiString -> Bool
$c<= :: EscapedAsciiString -> EscapedAsciiString -> Bool
< :: EscapedAsciiString -> EscapedAsciiString -> Bool
$c< :: EscapedAsciiString -> EscapedAsciiString -> Bool
compare :: EscapedAsciiString -> EscapedAsciiString -> Ordering
$ccompare :: EscapedAsciiString -> EscapedAsciiString -> Ordering
Ord,Int -> EscapedAsciiString -> ShowS
[EscapedAsciiString] -> ShowS
EscapedAsciiString -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EscapedAsciiString] -> ShowS
$cshowList :: [EscapedAsciiString] -> ShowS
show :: EscapedAsciiString -> String
$cshow :: EscapedAsciiString -> String
showsPrec :: Int -> EscapedAsciiString -> ShowS
$cshowsPrec :: Int -> EscapedAsciiString -> ShowS
Show)
escapeText :: Char -> T.Text
escapeText :: Char -> Text
escapeText Char
'(' = Text
"\\("
escapeText Char
')' = Text
"\\)"
escapeText Char
'\\' = Text
"\\\\"
escapeText Char
a = Char -> Text
T.singleton Char
a
escapeByteString :: Char -> S.ByteString
escapeByteString :: Char -> ByteString
escapeByteString Char
'(' = String -> ByteString
C.pack String
"\\("
escapeByteString Char
')' = String -> ByteString
C.pack String
"\\)"
escapeByteString Char
'\\' = String -> ByteString
C.pack String
"\\\\"
escapeByteString Char
a = Char -> ByteString
C.singleton Char
a
toPDFString :: T.Text -> PDFString
toPDFString :: Text -> PDFString
toPDFString = ByteString -> PDFString
PDFString forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
encodeUtf16BE
toPDFGlyph :: S.ByteString -> PDFGlyph
toPDFGlyph :: ByteString -> PDFGlyph
toPDFGlyph = ByteString -> PDFGlyph
PDFGlyph
toAsciiString :: String -> AsciiString
toAsciiString :: String -> AsciiString
toAsciiString String
s = ByteString -> AsciiString
AsciiString (String -> ByteString
C.pack String
s)
class HasHexaStream a where
toHexaStream :: a -> S.ByteString
instance HasHexaStream S.ByteString where
toHexaStream :: ByteString -> ByteString
toHexaStream ByteString
x =
let hexChar :: Char -> ByteString
hexChar Char
c = String -> ByteString
C.pack (forall r. PrintfType r => String -> r
printf String
"%02X" (Char -> Int
ord Char
c) :: String)
in
Char -> ByteString -> ByteString
C.cons Char
'F' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ByteString -> ByteString
C.cons Char
'E' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ByteString -> ByteString
C.cons Char
'F' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ByteString -> ByteString
C.cons Char
'F' forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> ByteString) -> ByteString -> ByteString
C.concatMap Char -> ByteString
hexChar forall a b. (a -> b) -> a -> b
$ ByteString
x
instance HasHexaStream PDFString where
toHexaStream :: PDFString -> ByteString
toHexaStream (PDFString ByteString
x) = forall a. HasHexaStream a => a -> ByteString
toHexaStream ByteString
x
instance HasHexaStream PDFGlyph where
toHexaStream :: PDFGlyph -> ByteString
toHexaStream (PDFGlyph ByteString
x) =
let hexChar :: Char -> ByteString
hexChar Char
c = String -> ByteString
C.pack (forall r. PrintfType r => String -> r
printf String
"%02X" (Char -> Int
ord Char
c) :: String)
in
(Char -> ByteString) -> ByteString -> ByteString
C.concatMap Char -> ByteString
hexChar forall a b. (a -> b) -> a -> b
$ ByteString
x
newtype GlyphCode = GlyphCode Word8 deriving(GlyphCode -> GlyphCode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlyphCode -> GlyphCode -> Bool
$c/= :: GlyphCode -> GlyphCode -> Bool
== :: GlyphCode -> GlyphCode -> Bool
$c== :: GlyphCode -> GlyphCode -> Bool
Eq,Eq GlyphCode
GlyphCode -> GlyphCode -> Bool
GlyphCode -> GlyphCode -> Ordering
GlyphCode -> GlyphCode -> GlyphCode
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: GlyphCode -> GlyphCode -> GlyphCode
$cmin :: GlyphCode -> GlyphCode -> GlyphCode
max :: GlyphCode -> GlyphCode -> GlyphCode
$cmax :: GlyphCode -> GlyphCode -> GlyphCode
>= :: GlyphCode -> GlyphCode -> Bool
$c>= :: GlyphCode -> GlyphCode -> Bool
> :: GlyphCode -> GlyphCode -> Bool
$c> :: GlyphCode -> GlyphCode -> Bool
<= :: GlyphCode -> GlyphCode -> Bool
$c<= :: GlyphCode -> GlyphCode -> Bool
< :: GlyphCode -> GlyphCode -> Bool
$c< :: GlyphCode -> GlyphCode -> Bool
compare :: GlyphCode -> GlyphCode -> Ordering
$ccompare :: GlyphCode -> GlyphCode -> Ordering
Ord,Int -> GlyphCode -> ShowS
[GlyphCode] -> ShowS
GlyphCode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlyphCode] -> ShowS
$cshowList :: [GlyphCode] -> ShowS
show :: GlyphCode -> String
$cshow :: GlyphCode -> String
showsPrec :: Int -> GlyphCode -> ShowS
$cshowsPrec :: Int -> GlyphCode -> ShowS
Show,Enum GlyphCode
Real GlyphCode
GlyphCode -> Integer
GlyphCode -> GlyphCode -> (GlyphCode, GlyphCode)
GlyphCode -> GlyphCode -> GlyphCode
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: GlyphCode -> Integer
$ctoInteger :: GlyphCode -> Integer
divMod :: GlyphCode -> GlyphCode -> (GlyphCode, GlyphCode)
$cdivMod :: GlyphCode -> GlyphCode -> (GlyphCode, GlyphCode)
quotRem :: GlyphCode -> GlyphCode -> (GlyphCode, GlyphCode)
$cquotRem :: GlyphCode -> GlyphCode -> (GlyphCode, GlyphCode)
mod :: GlyphCode -> GlyphCode -> GlyphCode
$cmod :: GlyphCode -> GlyphCode -> GlyphCode
div :: GlyphCode -> GlyphCode -> GlyphCode
$cdiv :: GlyphCode -> GlyphCode -> GlyphCode
rem :: GlyphCode -> GlyphCode -> GlyphCode
$crem :: GlyphCode -> GlyphCode -> GlyphCode
quot :: GlyphCode -> GlyphCode -> GlyphCode
$cquot :: GlyphCode -> GlyphCode -> GlyphCode
Integral,GlyphCode
forall a. a -> a -> Bounded a
maxBound :: GlyphCode
$cmaxBound :: GlyphCode
minBound :: GlyphCode
$cminBound :: GlyphCode
Bounded,Int -> GlyphCode
GlyphCode -> Int
GlyphCode -> [GlyphCode]
GlyphCode -> GlyphCode
GlyphCode -> GlyphCode -> [GlyphCode]
GlyphCode -> GlyphCode -> GlyphCode -> [GlyphCode]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: GlyphCode -> GlyphCode -> GlyphCode -> [GlyphCode]
$cenumFromThenTo :: GlyphCode -> GlyphCode -> GlyphCode -> [GlyphCode]
enumFromTo :: GlyphCode -> GlyphCode -> [GlyphCode]
$cenumFromTo :: GlyphCode -> GlyphCode -> [GlyphCode]
enumFromThen :: GlyphCode -> GlyphCode -> [GlyphCode]
$cenumFromThen :: GlyphCode -> GlyphCode -> [GlyphCode]
enumFrom :: GlyphCode -> [GlyphCode]
$cenumFrom :: GlyphCode -> [GlyphCode]
fromEnum :: GlyphCode -> Int
$cfromEnum :: GlyphCode -> Int
toEnum :: Int -> GlyphCode
$ctoEnum :: Int -> GlyphCode
pred :: GlyphCode -> GlyphCode
$cpred :: GlyphCode -> GlyphCode
succ :: GlyphCode -> GlyphCode
$csucc :: GlyphCode -> GlyphCode
Enum,Num GlyphCode
Ord GlyphCode
GlyphCode -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: GlyphCode -> Rational
$ctoRational :: GlyphCode -> Rational
Real,Integer -> GlyphCode
GlyphCode -> GlyphCode
GlyphCode -> GlyphCode -> GlyphCode
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> GlyphCode
$cfromInteger :: Integer -> GlyphCode
signum :: GlyphCode -> GlyphCode
$csignum :: GlyphCode -> GlyphCode
abs :: GlyphCode -> GlyphCode
$cabs :: GlyphCode -> GlyphCode
negate :: GlyphCode -> GlyphCode
$cnegate :: GlyphCode -> GlyphCode
* :: GlyphCode -> GlyphCode -> GlyphCode
$c* :: GlyphCode -> GlyphCode -> GlyphCode
- :: GlyphCode -> GlyphCode -> GlyphCode
$c- :: GlyphCode -> GlyphCode -> GlyphCode
+ :: GlyphCode -> GlyphCode -> GlyphCode
$c+ :: GlyphCode -> GlyphCode -> GlyphCode
Num)
instance SerializeValue L.ByteString PDFString where
serialize :: PDFString -> ByteString
serialize (PDFString ByteString
t) = ByteString -> ByteString -> ByteString
L.Chunk ByteString
t ByteString
L.Empty
instance SerializeValue Builder PDFString where
serialize :: PDFString -> Builder
serialize (PDFString ByteString
t) = ByteString -> Builder
fromByteString ByteString
t
instance SerializeValue L.ByteString PDFGlyph where
serialize :: PDFGlyph -> ByteString
serialize (PDFGlyph ByteString
t) = ByteString -> ByteString -> ByteString
L.Chunk ByteString
t ByteString
L.Empty
instance SerializeValue Builder EscapedPDFGlyph where
serialize :: EscapedPDFGlyph -> Builder
serialize (EscapedPDFGlyph ByteString
t) = ByteString -> Builder
fromByteString ByteString
t
instance SerializeValue L.ByteString AsciiString where
serialize :: AsciiString -> ByteString
serialize (AsciiString ByteString
t) = ByteString -> ByteString -> ByteString
L.Chunk ByteString
t ByteString
L.Empty
instance SerializeValue Builder EscapedAsciiString where
serialize :: EscapedAsciiString -> Builder
serialize (EscapedAsciiString ByteString
t) = ByteString -> Builder
fromByteString ByteString
t
lparen :: SerializeValue s Char => s
lparen :: forall s. SerializeValue s Char => s
lparen = forall s a. SerializeValue s a => a -> s
serialize Char
'('
rparen :: SerializeValue s Char => s
rparen :: forall s. SerializeValue s Char => s
rparen = forall s a. SerializeValue s a => a -> s
serialize Char
')'
lbracket :: SerializeValue s Char => s
lbracket :: forall s. SerializeValue s Char => s
lbracket = forall s a. SerializeValue s a => a -> s
serialize Char
'['
rbracket :: SerializeValue s Char => s
rbracket :: forall s. SerializeValue s Char => s
rbracket = forall s a. SerializeValue s a => a -> s
serialize Char
']'
bspace :: SerializeValue s Char => s
bspace :: forall s. SerializeValue s Char => s
bspace = forall s a. SerializeValue s a => a -> s
serialize Char
' '
blt :: SerializeValue s Char => s
blt :: forall s. SerializeValue s Char => s
blt = forall s a. SerializeValue s a => a -> s
serialize Char
'<'
bgt :: SerializeValue s Char => s
bgt :: forall s. SerializeValue s Char => s
bgt = forall s a. SerializeValue s a => a -> s
serialize Char
'>'
newline :: SerializeValue s Char => s
newline :: forall s. SerializeValue s Char => s
newline = forall s a. SerializeValue s a => a -> s
serialize Char
'\n'
noPdfObject :: Monoid s => s
noPdfObject :: forall s. Monoid s => s
noPdfObject = forall s. Monoid s => s
mempty
espacePDFGlyph :: PDFGlyph -> EscapedPDFGlyph
espacePDFGlyph :: PDFGlyph -> EscapedPDFGlyph
espacePDFGlyph (PDFGlyph ByteString
t) = ByteString -> EscapedPDFGlyph
EscapedPDFGlyph forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> ByteString) -> ByteString -> ByteString
C.concatMap Char -> ByteString
escapeByteString forall a b. (a -> b) -> a -> b
$ ByteString
t
espaceAsciiString :: AsciiString -> EscapedAsciiString
espaceAsciiString :: AsciiString -> EscapedAsciiString
espaceAsciiString (AsciiString ByteString
t) = ByteString -> EscapedAsciiString
EscapedAsciiString forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> ByteString) -> ByteString -> ByteString
C.concatMap Char -> ByteString
escapeByteString forall a b. (a -> b) -> a -> b
$ ByteString
t
instance PdfObject PDFString where
toPDF :: PDFString -> Builder
toPDF PDFString
a = forall a. Monoid a => [a] -> a
mconcat [ forall s. SerializeValue s Char => s
blt
, ByteString -> Builder
fromByteString forall a b. (a -> b) -> a -> b
$ forall a. HasHexaStream a => a -> ByteString
toHexaStream PDFString
a
, forall s. SerializeValue s Char => s
bgt
]
instance PdfLengthInfo PDFString where
instance PdfObject PDFGlyph where
toPDF :: PDFGlyph -> Builder
toPDF PDFGlyph
a = forall a. Monoid a => [a] -> a
mconcat [ forall s. SerializeValue s Char => s
blt
, ByteString -> Builder
fromByteString forall a b. (a -> b) -> a -> b
$ forall a. HasHexaStream a => a -> ByteString
toHexaStream PDFGlyph
a
, forall s. SerializeValue s Char => s
bgt
]
instance PdfLengthInfo PDFGlyph where
instance PdfLengthInfo AsciiString where
instance PdfObject AsciiString where
toPDF :: AsciiString -> Builder
toPDF AsciiString
a = forall a. Monoid a => [a] -> a
mconcat [ forall s. SerializeValue s Char => s
lparen
, forall s a. SerializeValue s a => a -> s
serialize forall b c a. (b -> c) -> (a -> b) -> a -> c
. AsciiString -> EscapedAsciiString
espaceAsciiString forall a b. (a -> b) -> a -> b
$ AsciiString
a
, forall s. SerializeValue s Char => s
rparen
]
newtype PDFName = PDFName String deriving(PDFName -> PDFName -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PDFName -> PDFName -> Bool
$c/= :: PDFName -> PDFName -> Bool
== :: PDFName -> PDFName -> Bool
$c== :: PDFName -> PDFName -> Bool
Eq,Eq PDFName
PDFName -> PDFName -> Bool
PDFName -> PDFName -> Ordering
PDFName -> PDFName -> PDFName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: PDFName -> PDFName -> PDFName
$cmin :: PDFName -> PDFName -> PDFName
max :: PDFName -> PDFName -> PDFName
$cmax :: PDFName -> PDFName -> PDFName
>= :: PDFName -> PDFName -> Bool
$c>= :: PDFName -> PDFName -> Bool
> :: PDFName -> PDFName -> Bool
$c> :: PDFName -> PDFName -> Bool
<= :: PDFName -> PDFName -> Bool
$c<= :: PDFName -> PDFName -> Bool
< :: PDFName -> PDFName -> Bool
$c< :: PDFName -> PDFName -> Bool
compare :: PDFName -> PDFName -> Ordering
$ccompare :: PDFName -> PDFName -> Ordering
Ord)
instance PdfObject PDFName where
toPDF :: PDFName -> Builder
toPDF (PDFName String
a) = forall s a. SerializeValue s a => a -> s
serialize (String
"/" forall a. [a] -> [a] -> [a]
++ String
a)
instance PdfLengthInfo PDFName where
type PDFArray = [AnyPdfObject]
instance PdfObject a => PdfObject [a] where
toPDF :: [a] -> Builder
toPDF [a]
l = forall a. Monoid a => [a] -> a
mconcat forall a b. (a -> b) -> a -> b
$ (forall s. SerializeValue s Char => s
lbracketforall a. a -> [a] -> [a]
:forall a. a -> [a] -> [a]
intersperse forall s. SerializeValue s Char => s
bspace (forall a b. (a -> b) -> [a] -> [b]
map forall a. PdfObject a => a -> Builder
toPDF [a]
l)) forall a. [a] -> [a] -> [a]
++ [forall s. SerializeValue s Char => s
bspace] forall a. [a] -> [a] -> [a]
++ [forall s. SerializeValue s Char => s
rbracket]
instance PdfObject a => PdfLengthInfo [a] where
newtype PDFDictionary = PDFDictionary (M.Map PDFName AnyPdfObject)
instance PdfObject PDFDictionary where
toPDF :: PDFDictionary -> Builder
toPDF (PDFDictionary Map PDFName AnyPdfObject
a) = forall a. Monoid a => [a] -> a
mconcat forall a b. (a -> b) -> a -> b
$ [forall s. SerializeValue s Char => s
blt,forall s. SerializeValue s Char => s
blt,forall s. SerializeValue s Char => s
newline]
forall a. [a] -> [a] -> [a]
++ [forall {p}. p -> Builder
convertLevel Map PDFName AnyPdfObject
a]
forall a. [a] -> [a] -> [a]
++ [forall s. SerializeValue s Char => s
bgt,forall s. SerializeValue s Char => s
bgt]
where
convertLevel :: p -> Builder
convertLevel p
_ = let convertItem :: a -> a -> Builder -> Builder
convertItem a
key a
value Builder
current = forall a. Monoid a => [a] -> a
mconcat forall a b. (a -> b) -> a -> b
$ [ forall a. PdfObject a => a -> Builder
toPDF a
key
, forall s. SerializeValue s Char => s
bspace
, forall a. PdfObject a => a -> Builder
toPDF a
value
, forall s. SerializeValue s Char => s
newline
, Builder
current
]
in
forall k a b. (k -> a -> b -> b) -> b -> Map k a -> b
M.foldrWithKey forall {a} {a}.
(PdfObject a, PdfObject a) =>
a -> a -> Builder -> Builder
convertItem forall s. Monoid s => s
mempty Map PDFName AnyPdfObject
a
instance PdfLengthInfo PDFDictionary where
emptyDictionary :: PDFDictionary
emptyDictionary :: PDFDictionary
emptyDictionary = Map PDFName AnyPdfObject -> PDFDictionary
PDFDictionary forall k a. Map k a
M.empty
isEmptyDictionary :: PDFDictionary -> Bool
isEmptyDictionary :: PDFDictionary -> Bool
isEmptyDictionary (PDFDictionary Map PDFName AnyPdfObject
d) = forall k a. Map k a -> Bool
M.null Map PDFName AnyPdfObject
d
insertInPdfDict :: PDFName -> AnyPdfObject -> PDFDictionary -> PDFDictionary
insertInPdfDict :: PDFName -> AnyPdfObject -> PDFDictionary -> PDFDictionary
insertInPdfDict PDFName
key AnyPdfObject
obj (PDFDictionary Map PDFName AnyPdfObject
d) = Map PDFName AnyPdfObject -> PDFDictionary
PDFDictionary forall a b. (a -> b) -> a -> b
$ forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert PDFName
key AnyPdfObject
obj Map PDFName AnyPdfObject
d
pdfDictUnion :: PDFDictionary -> PDFDictionary -> PDFDictionary
pdfDictUnion :: PDFDictionary -> PDFDictionary -> PDFDictionary
pdfDictUnion (PDFDictionary Map PDFName AnyPdfObject
a) (PDFDictionary Map PDFName AnyPdfObject
b) = Map PDFName AnyPdfObject -> PDFDictionary
PDFDictionary forall a b. (a -> b) -> a -> b
$ forall k a. Ord k => Map k a -> Map k a -> Map k a
M.union Map PDFName AnyPdfObject
a Map PDFName AnyPdfObject
b
data PDFRect = PDFRect !Double !Double !Double !Double
instance PdfObject PDFRect where
toPDF :: PDFRect -> Builder
toPDF (PDFRect PDFFloat
a PDFFloat
b PDFFloat
c PDFFloat
d) = forall a. PdfObject a => a -> Builder
toPDF forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map forall a. (PdfObject a, PdfLengthInfo a) => a -> AnyPdfObject
AnyPdfObject forall a b. (a -> b) -> a -> b
$ [PDFFloat
a,PDFFloat
b,PDFFloat
c,PDFFloat
d]
instance PdfLengthInfo PDFRect where
data PDFReferencedObject a = PDFReferencedObject !Int !a
instance PdfObject a => PdfObject (PDFReferencedObject a) where
toPDF :: PDFReferencedObject a -> Builder
toPDF (PDFReferencedObject Int
referenceId a
obj) =
forall a. Monoid a => [a] -> a
mconcat forall a b. (a -> b) -> a -> b
$ [ forall s a. SerializeValue s a => a -> s
serialize forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ Int
referenceId
, forall s a. SerializeValue s a => a -> s
serialize (String
" 0 obj" :: String)
, forall s. SerializeValue s Char => s
newline
, forall a. PdfObject a => a -> Builder
toPDF a
obj
, forall s. SerializeValue s Char => s
newline
, forall s a. SerializeValue s a => a -> s
serialize (String
"endobj" :: String)
, forall s. SerializeValue s Char => s
newline , forall s. SerializeValue s Char => s
newline
]
instance PdfObject a => PdfLengthInfo (PDFReferencedObject a) where
data PDFReference s = PDFReference !Int deriving(PDFReference s -> PDFReference s -> Bool
forall s. PDFReference s -> PDFReference s -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PDFReference s -> PDFReference s -> Bool
$c/= :: forall s. PDFReference s -> PDFReference s -> Bool
== :: PDFReference s -> PDFReference s -> Bool
$c== :: forall s. PDFReference s -> PDFReference s -> Bool
Eq,PDFReference s -> PDFReference s -> Bool
PDFReference s -> PDFReference s -> Ordering
forall s. Eq (PDFReference s)
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall s. PDFReference s -> PDFReference s -> Bool
forall s. PDFReference s -> PDFReference s -> Ordering
forall s. PDFReference s -> PDFReference s -> PDFReference s
min :: PDFReference s -> PDFReference s -> PDFReference s
$cmin :: forall s. PDFReference s -> PDFReference s -> PDFReference s
max :: PDFReference s -> PDFReference s -> PDFReference s
$cmax :: forall s. PDFReference s -> PDFReference s -> PDFReference s
>= :: PDFReference s -> PDFReference s -> Bool
$c>= :: forall s. PDFReference s -> PDFReference s -> Bool
> :: PDFReference s -> PDFReference s -> Bool
$c> :: forall s. PDFReference s -> PDFReference s -> Bool
<= :: PDFReference s -> PDFReference s -> Bool
$c<= :: forall s. PDFReference s -> PDFReference s -> Bool
< :: PDFReference s -> PDFReference s -> Bool
$c< :: forall s. PDFReference s -> PDFReference s -> Bool
compare :: PDFReference s -> PDFReference s -> Ordering
$ccompare :: forall s. PDFReference s -> PDFReference s -> Ordering
Ord,Int -> PDFReference s -> ShowS
forall s. Int -> PDFReference s -> ShowS
forall s. [PDFReference s] -> ShowS
forall s. PDFReference s -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PDFReference s] -> ShowS
$cshowList :: forall s. [PDFReference s] -> ShowS
show :: PDFReference s -> String
$cshow :: forall s. PDFReference s -> String
showsPrec :: Int -> PDFReference s -> ShowS
$cshowsPrec :: forall s. Int -> PDFReference s -> ShowS
Show)
referenceValue :: PDFReference s -> Int
referenceValue :: forall s. PDFReference s -> Int
referenceValue (PDFReference Int
i) = Int
i
instance PdfObject s => Num (PDFReference s) where
+ :: PDFReference s -> PDFReference s -> PDFReference s
(+) (PDFReference Int
a) (PDFReference Int
b) = forall s. Int -> PDFReference s
PDFReference (Int
aforall a. Num a => a -> a -> a
+Int
b)
* :: PDFReference s -> PDFReference s -> PDFReference s
(*) (PDFReference Int
a) (PDFReference Int
b) = forall s. Int -> PDFReference s
PDFReference (Int
aforall a. Num a => a -> a -> a
*Int
b)
negate :: PDFReference s -> PDFReference s
negate (PDFReference Int
a) = forall s. Int -> PDFReference s
PDFReference (forall a. Num a => a -> a
negate Int
a)
abs :: PDFReference s -> PDFReference s
abs (PDFReference Int
a) = forall s. Int -> PDFReference s
PDFReference (forall a. Num a => a -> a
abs Int
a)
signum :: PDFReference s -> PDFReference s
signum (PDFReference Int
a) = forall s. Int -> PDFReference s
PDFReference (forall a. Num a => a -> a
signum Int
a)
fromInteger :: Integer -> PDFReference s
fromInteger Integer
a = forall s. Int -> PDFReference s
PDFReference (forall a. Num a => Integer -> a
fromInteger Integer
a)
instance PdfObject s => PdfObject (PDFReference s) where
toPDF :: PDFReference s -> Builder
toPDF (PDFReference Int
i) = forall a. Monoid a => [a] -> a
mconcat forall a b. (a -> b) -> a -> b
$ [ forall s a. SerializeValue s a => a -> s
serialize forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ Int
i
, forall s a. SerializeValue s a => a -> s
serialize (String
" 0 R" :: String)]
instance PdfObject s => PdfLengthInfo (PDFReference s) where
instance (PdfObject a,PdfObject b) => PdfObject (Either a b) where
toPDF :: Either a b -> Builder
toPDF (Left a
a) = forall a. PdfObject a => a -> Builder
toPDF a
a
toPDF (Right b
a) = forall a. PdfObject a => a -> Builder
toPDF b
a
instance (PdfObject a, PdfObject b) => PdfLengthInfo (Either a b) where
modifyStrict :: (MonadState s m) => (s -> s) -> m ()
modifyStrict :: forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modifyStrict s -> s
f = do
s
s <- forall s (m :: * -> *). MonadState s m => m s
get
forall s (m :: * -> *). MonadState s m => s -> m ()
put forall a b. (a -> b) -> a -> b
$! (s -> s
f s
s)
class MonadWriter Builder m => MonadPath m
data EmbeddedFont
instance PdfObject EmbeddedFont where
toPDF :: EmbeddedFont -> Builder
toPDF EmbeddedFont
_ = forall s. Monoid s => s
noPdfObject
instance PdfLengthInfo EmbeddedFont where