From 2dec0ff52d2e57048920a7e520a7d8bf7a1e8f8a Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 21 Nov 2022 15:50:00 +0100 Subject: 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. --- src/Text/Pandoc/Writers/Docx.hs | 6 ++++-- 1 file 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")] () -- cgit v1.2.3