@@ -842,7 +842,7 @@ inlineToOpenXML opts (Image alt (src, tit)) = do
842842 let size = imageSize img
843843 let (xpt,ypt) = maybe (120,120) sizeInPoints size
844844 -- 12700 emu = 1 pt
845− let (xemu,yemu) = (xpt * 12700, ypt * 12700)
845+ let (xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700)
846846 let cNvPicPr = mknode "pic:cNvPicPr" [] $
847847 mknode "a:picLocks" [("noChangeArrowheads","1"),("noChangeAspect","1")] ()
848848 let nvPicPr = mknode "pic:nvPicPr" []
@@ -907,3 +907,11 @@ parseXml refArchive distArchive relpath =
907907 >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of
908908 Just d -> return d
909909 Nothing -> fail $ relpath ++ " corrupt or missing in reference docx"
910+
911+-- | Scales the image to fit the page
912+fitToPage :: (Integer, Integer) -> (Integer, Integer)
913+fitToPage (x, y)
914+ --5440680 is the emu width size of a letter page in portrait, minus the margins
915+ | x > 5440680 =
916+ (5440680, round $ (5440680 / ((fromIntegral :: Integer -> Double) x)) * (fromIntegral y))
917+ | otherwise = (x, y)