예제 #1
0
        protected override HtmlItem renderingHtmlImg(HtmlItem it, ref Paragraph par, HtmlItem parent, DocumentObject renderparent)
        {
            HtmlImg imagen = it as HtmlImg;
            MigraDoc.DocumentObjectModel.Shapes.Image img = null;
            MigraDoc.DocumentObjectModel.Shapes.TextFrame tf = null;
            if (imagen != null)
            {
                string route = AppDomain.CurrentDomain.BaseDirectory;
                string directorytem = Settings1.Default.routetem;
                string filename = RandomString(16, false) + "." + imagen.ImageType.ToString();
                string routecompleted = route + directorytem + "\\" + filename;
                imagen.Image.Save(routecompleted);

                MigraDoc.DocumentObjectModel.Tables.Cell cellparent = renderparent as MigraDoc.DocumentObjectModel.Tables.Cell;
                if (cellparent != null)
                {
                    tf = cellparent.AddTextFrame();
                    tf.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through;
                }

                if (tf != null)
                    img = tf.AddImage(routecompleted);
                else
                    img = par.AddImage(routecompleted);

                RenderStyle.CreateRenderStyle(it, ref img).Render();
                listTempFiles.Add(routecompleted);
                imagen.SizeRenderItem = new RenderSizeItem() { Width = Convert.ToDecimal(img.Width), Height = Convert.ToDecimal(img.Height) };

            }

            return imagen;
        }
예제 #2
0
        /// <summary>
        /// The write image.
        /// </summary>
        /// <param name="i">
        /// The i.
        /// </param>
        public void WriteImage(Image i)
        {
            Paragraph p = this.WriteStartFigure(i);

            if (i.Source != null)
            {
                MigraDoc.DocumentObjectModel.Shapes.Image pi = p.AddImage(Path.GetFullPath(i.Source));
                pi.Width = Unit.FromCentimeter(15);
            }

            this.WriteEndFigure(i, p);
        }
예제 #3
0
        public void VisitBlip(Blip element)
        {
            var image = _documentContext.Images[element.Embed.Value];

            _pdfParagraph.AddImage($"base64:{Convert.ToBase64String(image)}");
        }