From 87f4247d9e95ee545c0654fc06e6e295da360221 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 27 Oct 2022 10:01:26 -0700 Subject: T.P.PDF: fix papersize on PDF generation via ms. We need to set an option in pdfroff in addition to including a macro in the ms file. With this fix, `-Vpapersize=a4` should be sufficient to produce A4 PDF via ms. Closes #8403. --- src/Text/Pandoc/PDF.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index bdcdbeddd..419798f7e 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -61,6 +61,7 @@ import Text.Pandoc.Class (fillMediaBag, getVerbosity, readFileLazy, readFileStrict, fileExists, report, extractMedia, PandocMonad) import Text.Pandoc.Logging +import Text.DocTemplates ( FromContext(lookupContext) ) #ifdef _WINDOWS changePathSeparators :: FilePath -> FilePath @@ -89,8 +90,16 @@ makePDF program pdfargs writer opts doc = liftIO $ html2pdf verbosity program pdfargs source "pdfroff" -> do source <- writer opts doc + let paperargs = + case lookupContext "papersize" (writerVariables opts) of + Just s + | T.takeEnd 1 s == "l" -> ["-P-p" <> + T.unpack (T.dropEnd 1 s), "-P-l"] + | otherwise -> ["-P-p" <> T.unpack s] + Nothing -> [] let args = ["-ms", "-mpdfmark", "-mspdf", - "-e", "-t", "-k", "-KUTF-8", "-i"] ++ pdfargs + "-e", "-t", "-k", "-KUTF-8", "-i"] ++ + paperargs ++ pdfargs generic2pdf program args source baseProg -> do withTempDir "tex2pdf." $ \tmpdir' -> do -- cgit v1.2.3