@@ -176,7 +176,10 @@ runTeXProgram program runsLeft tmpDir source = do
176176 let pdfFile = replaceDirectory (replaceExtension file ".pdf") tmpDir
177177 pdfExists <- doesFileExist pdfFile
178178 pdf <- if pdfExists
179− then Just `fmap` B.readFile pdfFile
179+ -- We read PDF as a strict bytestring to make sure that the
180+ -- temp directory is removed on Windows.
181+ -- See https://github.com/jgm/pandoc/issues/1192.
182+ then (Just . B.fromChunks . (:[])) `fmap` BS.readFile pdfFile
180183 else return Nothing
181184 return (exit, out <> err, pdf)
182185