diff --git a/src/PDF/Body.hs b/src/PDF/Body.hs index d8903d7..f9ad4fd 100644 --- a/src/PDF/Body.hs +++ b/src/PDF/Body.hs @@ -7,7 +7,7 @@ module PDF.Body ( import Control.Applicative ((<|>)) import Control.Monad.State (get, gets, modify) import Data.ByteString.Char8 (ByteString) -import qualified Data.ByteString.Char8 as BS (drop, unpack) +import qualified Data.ByteString.Char8 as BS (cons, drop, unpack) import Data.Map ((!)) import qualified Data.Map as Map (empty, insert, lookup) import qualified PDF.EOL as EOL (charset, parser) @@ -41,8 +41,9 @@ pushOccurrence newOccurrence = modifyFlow $ \flow -> flow { } comment :: Parser u String -comment = BS.unpack <$> - (char '%' *> takeAll (not . (`elem` EOL.charset)) <* EOL.parser) +comment = BS.unpack <$> (option "" afterPercent <* EOL.parser) + where + afterPercent = BS.cons <$> char '%' <*> takeAll (not . (`elem` EOL.charset)) lookupOffset :: Int -> XRefSection -> Maybe Int lookupOffset _ [] = Nothing diff --git a/src/PDF/Object.hs b/src/PDF/Object.hs index d224a1c..3788ffc 100644 --- a/src/PDF/Object.hs +++ b/src/PDF/Object.hs @@ -242,7 +242,7 @@ data Occurrence = Comment String | Indirect IndirectObjCoordinates deriving Show outputOccurrence :: Map Int Object -> Occurrence -> OBuilder outputOccurrence _ (Comment c) = - Output.string (printf "%%%s" c) `mappend` newLine + Output.string c `mappend` newLine outputOccurrence objects (Indirect (IndirectObjCoordinates {objectId, versionNumber})) = saveOffset (ObjectId objectId) >> Output.string (printf "%d %d obj" objectId versionNumber)