/// <summary> /// Renderizza un elemento immagine in una cella iTextSharp.text. /// </summary> /// <param name="ImgElement"> /// Elemento immagine. NOTA: il percorso dev'essere ASSOLUTO, ad esempio C:\img\img.gif /// </param> /// <returns> /// iTextSharp.text.Cell con i contenuti opportuni /// </returns> private static iTextSharp.text.Cell RenderElement(DocTemplateVers.Domain.DTO.ServiceExport.DTO_ElementImage ImgElement, float MaxWidth) { iTextSharp.text.Cell cell = new iTextSharp.text.Cell(); cell.Border = 0; RtfHelper.SetAlignment(ref cell, ImgElement.Alignment); //cell.Width = MaxWidth; iTextSharp.text.Image img; try { img = iTextSharp.text.Image.GetInstance(ImgElement.Path); if (ImgElement.Width > 0 && ImgElement.Height > 0) { img.ScaleAbsolute(ImgElement.Width, ImgElement.Height); } else if (ImgElement.Width > 0) { img.ScaleAbsoluteWidth(ImgElement.Width); } else if (ImgElement.Height > 0) { img.ScaleAbsoluteHeight(ImgElement.Height); } if (img.Width > MaxWidth) { img.ScaleAbsoluteWidth(MaxWidth); } cell.AddElement(img); } catch (Exception ex) { //cell = null; } return(cell); //return new iTextSharp.text.Cell(new iTextSharp.text.Paragraph("NOT IMPLEMENT!")); }
/// <summary> /// Renderizza un elemento testuale in una cella iTextSharp.text. /// </summary> /// <param name="TxtElement"> /// Elemento testuale /// </param> /// <returns> /// iTextSharp.text.Cell con i contenuti opportuni /// </returns> private static iTextSharp.text.Cell RenderElement(DocTemplateVers.Domain.DTO.ServiceExport.DTO_ElementText TxtElement, float MaxWidth) { iTextSharp.text.Cell cell; // = new iTextSharp5.text.Cell(); if (TxtElement.IsHTML) { cell = HtmlToCell(TxtElement.Text); //HtmlCheck(TxtElement.Text); // cell = new iTextSharp.text.Cell(); // System.Collections.ArrayList AL_Content = //iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList( //new System.IO.StringReader(RtfHelper.HtmlCheckRtf(TxtElement.Text)), //RtfHelper.GetStyles()); // for (int j = 0; j < AL_Content.Count; j++) // { // cell.AddElement(CheckconvertedElement((iTextSharp.text.IElement)AL_Content[j])); // } } else { cell = new iTextSharp.text.Cell( new iTextSharp.text.Paragraph(TxtElement.Text) ); //switch (TxtElement.Alignment) //{ // case Helpers.Export.ElementAlignment.BottomCenter: // cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER; // = iTextSharp5.text.Cell.ALIGN_CENTER; // cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM; // break; // case Helpers.Export.ElementAlignment.BottomLeft: // cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT; // cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM; // break; // case Helpers.Export.ElementAlignment.BottomRight: // cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT; // cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM; // break; // case Helpers.Export.ElementAlignment.MiddleCenter: // cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER; // cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE; // break; // case Helpers.Export.ElementAlignment.MiddleLeft: // cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT; // cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE; // break; // case Helpers.Export.ElementAlignment.MiddleRight: // cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT; // cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE; // break; // case Helpers.Export.ElementAlignment.TopCenter: // cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER; // cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_TOP; // break; // case Helpers.Export.ElementAlignment.TopLeft: // cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT; // cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_TOP; // break; // case Helpers.Export.ElementAlignment.TopRight: // cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT; // cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_TOP; // break; // default: // cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT; // cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_TOP; // break; //} } if (cell != null) { RtfHelper.SetAlignment(ref cell, TxtElement.Alignment); cell.Border = 0; } return(cell); }