private IEnumerable <OXmlElement> Image(HtmlDocNodeTagImg imgTag)
        {
            // 300 px ->  7.94 cm
            // 450 px -> 11.91 cm
            // largeur 18.5 cm = 694 px
            // largeur 16 cm   = 600 px
            // example :
            // leftalign width300 - nonealign width300
            // leftalign width300 - nonealign width300
            // example :
            // leftalign width300 - nonealign width300
            // nonealign width450
            // example :
            // nonealign width450
            // nonealign width450


            HtmlImage htmlImage = GetHtmlImage(imgTag);

            int horizontalPosition;
            int verticalPosition;

            if (_imageHorizontalPosition > 0 && _imageHorizontalPosition + htmlImage.Width > _maxImageHorizontalPosition)
            {
                horizontalPosition       = 0;
                _imageVerticalPosition  += _imageHeight + _imageMarge;
                verticalPosition         = _imageVerticalPosition;
                _imageHorizontalPosition = (int)htmlImage.Width + _imageMarge;
                _imageHeight             = (int)htmlImage.Height;
            }
            else
            {
                horizontalPosition        = _imageHorizontalPosition;
                _imageHorizontalPosition += (int)htmlImage.Width + _imageMarge;
                verticalPosition          = _imageVerticalPosition;
                _imageHeight              = Math.Max(_imageHeight, (int)htmlImage.Height);
            }
            yield return(new OXmlPictureElement {
                File = htmlImage.File, Width = htmlImage.Width, Height = htmlImage.Height, PictureDrawing = new OXmlAnchorPictureDrawing
                {
                    // SquareSize = 21800
                    //Wrap = new OXmlAnchorWrapTight { WrapPolygon = OXmlDoc.CreateWrapPolygon(21800) },
                    Wrap = new OXmlAnchorWrapTight {
                        WrapPolygon = new OXmlSquare {
                            HorizontalSize = 21800
                        }
                    },
                    HorizontalPosition = new OXmlHorizontalPosition {
                        RelativeFrom = DW.HorizontalRelativePositionValues.Margin, PositionOffset = horizontalPosition
                    },
                    VerticalPosition = new OXmlVerticalPosition {
                        RelativeFrom = DW.VerticalRelativePositionValues.Paragraph, PositionOffset = verticalPosition
                    }
                }
            });
        }
        private HtmlImage GetHtmlImage(HtmlDocNodeTagImg imgTag)
        {
            HtmlImage htmlImage = new HtmlImage();
            //Uri uri;
            string url;

            if (_useLinkImage && _currentTagA != null)
            {
                url = _currentTagA.Link;
            }
            else
            {
                //uri = new Uri(imgTag.Link);
                url = imgTag.Link;
            }
            //string file = uri.Segments[uri.Segments.Length - 1];
            //if (_imageDirectory != null)
            //    file = zPath.Combine(_imageDirectory, file);
            //htmlImage.File = file;
            url            = zurl.GetUrl(_sourceUrl, url);
            htmlImage.File = GetImageFile(url);
            htmlImage.Url  = url;

            //if (_trace)
            //    Trace.WriteLine($"GetHtmlImage()  : add image \"{htmlImage.File}\"");

            if (imgTag.ClassList != null)
            {
                foreach (string className in imgTag.ClassList)
                {
                    SetHtmlImageValues(htmlImage, className);
                }
            }
            if (imgTag.Width != null)
            {
                htmlImage.Width = imgTag.Width;
            }
            if (_forcedMaxImageWidth != null && (htmlImage.Width > _forcedMaxImageWidth || htmlImage.Width == null))
            {
                pb.Trace.WriteLine($"force image width to {_forcedMaxImageWidth} original width {htmlImage.Width} image \"{htmlImage.File}\"");
                htmlImage.Width = _forcedMaxImageWidth;
            }
            PatchImage(htmlImage);
            SetPictureWidthHeight(htmlImage);
            return(htmlImage);
        }
        private HtmlImage GetHtmlImage(HtmlDocNodeTagImg imgTag)
        {
            HtmlImage htmlImage = new HtmlImage();
            Uri       uri       = new Uri(imgTag.Link);

            htmlImage.File = _pictureDir + uri.Segments[uri.Segments.Length - 1];
            foreach (string className in imgTag.ClassList)
            {
                SetPictureClassParam(htmlImage, className);
            }
            if (_forcedImageWidth != null)
            {
                htmlImage.Width = _forcedImageWidth;
            }
            SetPictureWidthHeight(htmlImage);
            return(htmlImage);
        }
        //private IEnumerable<OXmlElement> Image(HtmlDocNodeTagImg imgTag)
        private void Image(HtmlDocNodeTagImg imgTag)
        {
            HtmlImage htmlImage = GetHtmlImage(imgTag);

            if (htmlImage.File == null)
            {
                pb.Trace.WriteLine("can't add picture without file");
                return;
            }

            if (_trace)
            {
                pb.Trace.WriteLine($"Image()         : add picture                 \"{zPath.GetFileName(htmlImage.File)}\" width {htmlImage.Width} height {htmlImage.Height} {(htmlImage.NoneAlign ? "noneAlign " : "" )}{(htmlImage.LeftAlign ? "leftAlign " : "")}{(htmlImage.RightAlign ? "rightAlign" : "")}");
            }
            if (_paragraph != null)
            {
                if (_trace)
                {
                    pb.Trace.WriteLine("Image()         : remove stored paragraph");
                }
                _paragraph = null;
            }
            if (_line != null)
            {
                if (_trace)
                {
                    pb.Trace.WriteLine("Image()         : remove stored new line");
                }
                _line = null;
            }
            _htmlImages.Add(htmlImage);

            //int horizontalPosition;
            //int verticalPosition;
            //if (_imageHorizontalPosition > 0 && _imageHorizontalPosition + htmlImage.Width > _maxImageHorizontalPosition)
            //{
            //    horizontalPosition = 0;
            //    _imageVerticalPosition += _imageHeight + _imageMarge;
            //    verticalPosition = _imageVerticalPosition;
            //    _imageHorizontalPosition = (int)htmlImage.Width + _imageMarge;
            //    _imageHeight = (int)htmlImage.Height;
            //}
            //else
            //{
            //    horizontalPosition = _imageHorizontalPosition;
            //    _imageHorizontalPosition += (int)htmlImage.Width + _imageMarge;
            //    verticalPosition = _imageVerticalPosition;
            //    _imageHeight = Math.Max(_imageHeight, (int)htmlImage.Height);
            //}
            //yield return new OXmlPictureElement
            //{
            //    File = htmlImage.File,
            //    Width = htmlImage.Width,
            //    Height = htmlImage.Height,
            //    PictureDrawing = new OXmlAnchorPictureDrawing
            //    {
            //        // SquareSize = 21800
            //        //Wrap = new OXmlAnchorWrapTight { WrapPolygon = OXmlDoc.CreateWrapPolygon(21800) },
            //        Wrap = new OXmlAnchorWrapTight { WrapPolygon = new OXmlSquare { HorizontalSize = 21800 } },
            //        HorizontalRelativeFrom = DW.HorizontalRelativePositionValues.Margin,
            //        HorizontalPositionOffset = horizontalPosition,
            //        VerticalRelativeFrom = DW.VerticalRelativePositionValues.Paragraph,
            //        VerticalPositionOffset = verticalPosition
            //    }
            //};
        }