diff options
| author | John MacFarlane <[email protected]> | 2022-10-27 10:01:26 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-10-27 10:01:26 -0700 |
| commit | 87f4247d9e95ee545c0654fc06e6e295da360221 (patch) | |
| tree | bf24025809bdd149a08d705512fa1ad5c05998dc | |
| parent | 246e14e75a342ce8e1db8f4085cbb49b9fd2a990 (diff) | |
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.
| -rw-r--r-- | src/Text/Pandoc/PDF.hs | 11 |
1 files changed, 10 insertions, 1 deletions
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 |
