@@ -825,7 +825,7 @@ inlineToOpenXML opts (Image alt (src, tit)) = do
825825 let size = imageSize img
826826 let (xpt,ypt) = maybe (120,120) sizeInPoints size
827827 -- 12700 emu = 1 pt
828− let (xemu,yemu) = (xpt * 12700, ypt * 12700)
828+ let (xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700)
829829 let cNvPicPr = mknode "pic:cNvPicPr" [] $
830830 mknode "a:picLocks" [("noChangeArrowheads","1"),("noChangeAspect","1")] ()
831831 let nvPicPr = mknode "pic:nvPicPr" []
@@ -890,3 +890,11 @@ parseXml refArchive distArchive relpath =
890890 >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of
891891 Just d -> return d
892892 Nothing -> fail $ relpath ++ " corrupt or missing in reference docx"
893+
894+-- | Scales the image to fit the page
895+fitToPage :: (Integer, Integer) -> (Integer, Integer)
896+fitToPage (x, y)
897+ --5440680 is the emu width size of a letter page in portrait, minus the margins
898+ | x > 5440680 =
899+ (5440680, round $ (5440680 / ((fromIntegral :: Integer -> Double) x)) * (fromIntegral y))
900+ | otherwise = (x, y)