/// <summary> /// 根据插入点所在的容器来修正图片元素的大小 /// </summary> /// <param name="document">文档对象</param> /// <param name="element">图片元素</param> public static void CheckImageSizeWhenInsertImage(DomDocument document, DomImageElement element) { if (document.Options.EditOptions.FixWidthWhenInsertImage) { DomContainerElement container = null; int elementIndex = 0; document.Content.GetCurrentPositionInfo(out container, out elementIndex); container = container.ContentElement; SizeF size = new SizeF(element.Width, element.Height); size = MathCommon.FixSize( new SizeF(container.ClientWidth - document.PixelToDocumentUnit(2), 100000), size, element.KeepWidthHeightRate); element.Width = size.Width; element.Height = size.Height; } }