aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-09-10 21:17:51 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-09-10 21:17:51 -0700
commita64b3ab61ff34dca25f04f4f97b283dc5159ac87 (patch)
tree47cc8e2d56b5a50cdf9f219ac2d5230f81df2dc5 /src/Text/Pandoc
parent4778d034734e4848688c1fb5fa196b8bda8f08f2 (diff)
downloadpandoc-a64b3ab61ff34dca25f04f4f97b283dc5159ac87.tar.gz
Pass value of --dpi to rsvg-convert...
when converting SVG to PDF in the process of creating a PDF. Closes #5721.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/PDF.hs26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index ee2208fd1..a9114e8d5 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -108,7 +108,7 @@ makePDF program pdfargs writer opts doc =
#endif
runIOorExplode $ do
putCommonState commonState
- doc' <- handleImages tmpdir doc
+ doc' <- handleImages opts tmpdir doc
source <- writer opts doc'
res <- case baseProg of
"context" -> context2pdf verbosity program pdfargs tmpdir source
@@ -156,17 +156,18 @@ makeWithWkhtmltopdf program pdfargs writer opts doc@(Pandoc meta _) = do
verbosity <- getVerbosity
liftIO $ html2pdf verbosity program args source
-handleImages :: FilePath -- ^ temp dir to store images
+handleImages :: WriterOptions
+ -> FilePath -- ^ temp dir to store images
-> Pandoc -- ^ document
-> PandocIO Pandoc
-handleImages tmpdir doc =
+handleImages opts tmpdir doc =
fillMediaBag doc >>=
extractMedia tmpdir >>=
- walkM (convertImages tmpdir)
+ walkM (convertImages opts tmpdir)
-convertImages :: FilePath -> Inline -> PandocIO Inline
-convertImages tmpdir (Image attr ils (src, tit)) = do
- img <- liftIO $ convertImage tmpdir src
+convertImages :: WriterOptions -> FilePath -> Inline -> PandocIO Inline
+convertImages opts tmpdir (Image attr ils (src, tit)) = do
+ img <- liftIO $ convertImage opts tmpdir src
newPath <-
case img of
Left e -> do
@@ -174,11 +175,13 @@ convertImages tmpdir (Image attr ils (src, tit)) = do
return src
Right fp -> return fp
return (Image attr ils (newPath, tit))
-convertImages _ x = return x
+convertImages _ _ x = return x
-- Convert formats which do not work well in pdf to png
-convertImage :: FilePath -> FilePath -> IO (Either String FilePath)
-convertImage tmpdir fname =
+convertImage :: WriterOptions -> FilePath -> FilePath
+ -> IO (Either String FilePath)
+convertImage opts tmpdir fname = do
+ let dpi = show $ writerDpi opts
case mime of
Just "image/png" -> doNothing
Just "image/jpeg" -> doNothing
@@ -187,7 +190,8 @@ convertImage tmpdir fname =
Just "application/eps" -> doNothing
Just "image/svg+xml" -> E.catch (do
(exit, _) <- pipeProcess Nothing "rsvg-convert"
- ["-f","pdf","-a","-o",pdfOut,fname] BL.empty
+ ["-f","pdf","-a","--dpi-x",dpi,"--dpi-y",dpi,
+ "-o",pdfOut,fname] BL.empty
if exit == ExitSuccess
then return $ Right pdfOut
else return $ Left "conversion from SVG failed")