git.iko.soy/typeable/pandoc
on master help sign in
Improved treatment of margins in wkhtmltopdf.
commit46e38d0a0a8d4e0cd4054dff19c4dd383ac7ae1c authorJohn MacFarlane <jgm@berkeley.edu> dateMon 21 Dec 2015, 23:47 (11 years ago) parent8b8bdca
1 file changed+13−9
src/Text/Pandoc/PDF.hs+13−9
src/Text/Pandoc/PDF.hs+13−9
@@ -79,16 +79,20 @@ makePDF "wkhtmltopdf" writer opts doc@(Pandoc meta _) = do
7979 "--window-status", "mathjax_loaded"]
8080 _ -> []
8181 meta' <- metaToJSON opts (return . stringify) (return . stringify) meta
82− let toArgs (f, d) = maybe (maybe [] (\x -> ['-':'-':f, x]) d)
83− (\x -> ['-':'-':f, x]) $ getField f meta'
82+ let toArgs (f, mbd) = maybe [] (\d -> ['-':'-':f, d]) mbd
8483 let args = mathArgs ++
85− concatMap toArgs [("page-size", Just "letter")
86− ,("title", Nothing)
87− ,("margin-bottom", Just "1in")
88− ,("margin-top", Just "1in")
89− ,("margin-left", Just "1in")
90− ,("margin-right", Just "1in")
91− ]
84+ concatMap toArgs
85+ [("page-size", getField "papersize" meta')
86+ ,("title", getField "title" meta')
87+ ,("margin-bottom", fromMaybe (Just "1.2in")
88+ (getField "margin-bottom" meta'))
89+ ,("margin-top", fromMaybe (Just "1.25in")
90+ (getField "margin-top" meta'))
91+ ,("margin-right", fromMaybe (Just "1.25in")
92+ (getField "margin-right" meta'))
93+ ,("margin-left", fromMaybe (Just "1.25in")
94+ (getField "margin-left" meta'))
95+ ]
9296 let source = writer opts doc
9397 html2pdf (writerVerbose opts) args source
9498makePDF program writer opts doc = withTempDir "tex2pdf." $ \tmpdir -> do