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.
This commit is contained in:
John MacFarlane
2022-10-27 10:01:26 -07:00
parent 246e14e75a
commit 87f4247d9e
+10 -1
View File
@@ -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