aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-11-21 15:50:00 +0100
committerAlbert Krewinkel <[email protected]>2022-11-21 16:32:41 +0100
commit2dec0ff52d2e57048920a7e520a7d8bf7a1e8f8a (patch)
tree96073e72bc2b3c07cf62db67f10dc5261a414b94
parent4b4771f062a227153109d0ba2f9d125c82f411a8 (diff)
Docx writer: support relative image widths.
Image widths given in percent are interpreted to be relative to the text width. This is similar to the way percent widths are handled in other writers, e.g. HTML and LaTeX. Previously, percent widths were taken relative to the image's native size.
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index 3da9a000f..f000bd158 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -1345,8 +1345,10 @@ inlineToOpenXML' opts (Image attr@(imgident, _, _) alt (src, title)) = do
(xpt,ypt) = desiredSizeInPoints opts attr
(either (const def) id (imageSize opts img))
-- 12700 emu = 1 pt
- (xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700)
- (pageWidth * 12700)
+ pageWidthPt = case dimension Width attr of
+ Just (Percent a) -> pageWidth * (floor $ a * 127)
+ _ -> pageWidth * 12700
+ (xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700) pageWidthPt
cNvPicPr = mknode "pic:cNvPicPr" [] $
mknode "a:picLocks" [("noChangeArrowheads","1")
,("noChangeAspect","1")] ()