summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-12-21 23:47:03 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-12-21 23:47:03 -0800
commit46e38d0a0a8d4e0cd4054dff19c4dd383ac7ae1c (patch)
tree1a8788eed31ccd7da5af22b734b3cd56b5a4c634 /src/Text/Pandoc
parent8b8bdca56a77ff9c8d6b450547064e75b5997d1e (diff)
Improved treatment of margins in wkhtmltopdf.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/PDF.hs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index e7a19c81e..766827a71 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -79,16 +79,20 @@ makePDF "wkhtmltopdf" writer opts doc@(Pandoc meta _) = do
"--window-status", "mathjax_loaded"]
_ -> []
meta' <- metaToJSON opts (return . stringify) (return . stringify) meta
- let toArgs (f, d) = maybe (maybe [] (\x -> ['-':'-':f, x]) d)
- (\x -> ['-':'-':f, x]) $ getField f meta'
+ let toArgs (f, mbd) = maybe [] (\d -> ['-':'-':f, d]) mbd
let args = mathArgs ++
- concatMap toArgs [("page-size", Just "letter")
- ,("title", Nothing)
- ,("margin-bottom", Just "1in")
- ,("margin-top", Just "1in")
- ,("margin-left", Just "1in")
- ,("margin-right", Just "1in")
- ]
+ concatMap toArgs
+ [("page-size", getField "papersize" meta')
+ ,("title", getField "title" meta')
+ ,("margin-bottom", fromMaybe (Just "1.2in")
+ (getField "margin-bottom" meta'))
+ ,("margin-top", fromMaybe (Just "1.25in")
+ (getField "margin-top" meta'))
+ ,("margin-right", fromMaybe (Just "1.25in")
+ (getField "margin-right" meta'))
+ ,("margin-left", fromMaybe (Just "1.25in")
+ (getField "margin-left" meta'))
+ ]
let source = writer opts doc
html2pdf (writerVerbose opts) args source
makePDF program writer opts doc = withTempDir "tex2pdf." $ \tmpdir -> do