diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-07-30 14:49:57 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-07-30 14:49:57 -0700 |
commit | 23d806644f07e1df35b946bfac63d877005df443 (patch) | |
tree | d6436757355a209620adfc6bdc4645aced6bca84 /src/Text/Pandoc/Writers | |
parent | e365af9c23c71271f0fad877446a73840df81d9d (diff) | |
download | pandoc-23d806644f07e1df35b946bfac63d877005df443.tar.gz |
RTF writer: Improved image embedding.
Use calculated sizes.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/RTF.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index 2994385dc..43405ce3c 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -40,6 +40,7 @@ import Data.Char ( ord, chr, isDigit ) import qualified Data.ByteString as B import qualified Data.Map as M import Text.Printf ( printf ) +import Text.Pandoc.ImageSize -- | Convert Image inlines into a raw RTF embedded image, read from a file, -- or a MediaBag, or the internet. @@ -55,7 +56,17 @@ rtfEmbedImage opts x@(Image _ (src,_)) = do "image/jpeg" -> "\\jpegblip" "image/png" -> "\\pngblip" _ -> error "Unknown file type" - let raw = "{\\pict" ++ filetype ++ " " ++ concat bytes ++ "}" + let sizeSpec = case imageSize imgdata of + Nothing -> "" + Just sz -> "\\picw" ++ show xpx ++ + "\\pich" ++ show ypx ++ + "\\picwgoal" ++ show (xpt * 20) + ++ "\\pichgoal" ++ show (ypt * 20) + -- twip = 1/1440in = 1/20pt + where (xpx, ypx) = sizeInPixels sz + (xpt, ypt) = sizeInPoints sz + let raw = "{\\pict" ++ filetype ++ sizeSpec ++ " " ++ + concat bytes ++ "}" return $ if B.null imgdata then x else RawInline (Format "rtf") raw |