/// <summary> /// Custom template of the in use property, controls how and what should be rendered based on their column names in each cell of this column. /// It can be null. /// If you don't set it, new DisplayAsText() template will be used automatically. /// </summary> public void AddColumnItemsTemplate(string name, IColumnItemsTemplate template) { if (_builder.ColumnNamesItemsTemplates == null) _builder.ColumnNamesItemsTemplates = new Dictionary<string, IColumnItemsTemplate>(); _builder.ColumnNamesItemsTemplates.Add(name, template); }
/// <summary> /// Create a PdfPCell based on the PdfCell Attributes. /// </summary> /// <param name="pdfRptTableCellDefinition">PdfCell Attributes</param> /// <param name="defaultItemTemplate">Default ItemTemplate</param> /// <returns>A PdfPCell</returns> public static PdfPCell CreateSafePdfPCell(this CellAttributes pdfRptTableCellDefinition, IColumnItemsTemplate defaultItemTemplate) { mapBasicProperties(pdfRptTableCellDefinition); runConditionalFormatFormula(pdfRptTableCellDefinition); var pdfPCell = runOnItemsTemplate(pdfRptTableCellDefinition, defaultItemTemplate); pdfPCell.ApplyStyles(pdfRptTableCellDefinition); return pdfPCell; }
/// <summary> /// Displaying the current cell's data as a Wingdings symbol. /// </summary> /// <param name="onSelectSymbol">Choose a Wingdings symbol based on the passed value.</param> public void WingdingsSymbol(Func<IList<CellData>, Wingdings> onSelectSymbol) { _columnItemsTemplate = new WingdingsSymbolField { OnSelectSymbol = onSelectSymbol }; }
/// <summary> /// Displaying current cell's data as an annotation. /// </summary> /// <param name="onPrintAnnotation">Return an AnnotationFieldData based on the passed value, which is the actual row's fields values from TableDataSource and CalculatedFieldFormula. If you don't want to add the annotation, return null.</param> public void Annotation(Func<IList<CellData>, AnnotationFieldData> onPrintAnnotation) { _columnItemsTemplate = new AnnotationField { OnPrintAnnotation = onPrintAnnotation }; }
/// <summary> /// Displaying current cell's data as text plus a ProgressBar. /// </summary> /// <param name="progressBarColor">Progress bar's background color</param> /// <param name="showPercentText">Indicates whether the percentage text should be displayed or not</param> public void ProgressBar(System.Drawing.Color progressBarColor, bool showPercentText) { _columnItemsTemplate = new ProgressBarField { ProgressBarColor = progressBarColor, ShowPercentText = showPercentText }; }
/// <summary> /// Displaying the current cell's data as a Zapf Dingbats symbol. /// </summary> /// <param name="onSelectSymbol">Choose a Zapf Dingbats symbol based on the passed value.</param> public void Symbol(Func<IList<CellData>, AdobeZapfDingbats> onSelectSymbol) { _columnItemsTemplate = new SymbolField { OnSelectSymbol = onSelectSymbol }; }
/// <summary> /// Displaying the current cell's data as a Wingdings symbol. /// </summary> /// <param name="onSelectSymbol">Choose a Wingdings symbol based on the passed value.</param> public void WingdingsSymbol(Func <IList <CellData>, Wingdings> onSelectSymbol) { _columnItemsTemplate = new WingdingsSymbolField { OnSelectSymbol = onSelectSymbol }; }
/// <summary> /// Displaying current cell's data as a MonthCalendar. /// Calendar's cell data type should be CalendarData. Use DaysInfoToCalendarData.MapToCalendarDataList to map list of the DayInfo's to the list of CalendarData's. /// </summary> /// <param name="data">MonthCalendarField's data.</param> public void MonthCalendar(CalendarAttributes data) { _columnItemsTemplate = new MonthCalendarField { MonthCalendarFieldData = data }; }
/// <summary> /// Create a PdfPCell based on the PdfCell Attributes. /// </summary> /// <param name="pdfRptTableCellDefinition">PdfCell Attributes</param> /// <param name="defaultItemTemplate">Default ItemTemplate</param> /// <returns>A PdfPCell</returns> public static PdfPCell CreateSafePdfPCell(this CellAttributes pdfRptTableCellDefinition, IColumnItemsTemplate defaultItemTemplate) { mapBasicProperties(pdfRptTableCellDefinition); runConditionalFormatFormula(pdfRptTableCellDefinition); var pdfPCell = runOnItemsTemplate(pdfRptTableCellDefinition, defaultItemTemplate); pdfPCell.ApplyStyles(pdfRptTableCellDefinition); return(pdfPCell); }
/// <summary> /// Displaying the current cell's data as a Zapf Dingbats symbol. /// </summary> /// <param name="onSelectSymbol">Choose a Zapf Dingbats symbol based on the passed value.</param> public void Symbol(Func <IList <CellData>, AdobeZapfDingbats> onSelectSymbol) { _columnItemsTemplate = new SymbolField { OnSelectSymbol = onSelectSymbol }; }
/// <summary> /// Displaying current cell's data as a Barcode. /// </summary> /// <param name="value">An instance of iTextSharp.text.pdf.BarcodeXYZ</param> public void Barcode(Barcode value) { _columnItemsTemplate = new BarcodeField(value); }
/// <summary> /// Adds a SummaryRow to an existing PdfGrid /// </summary> /// <param name="table">An existing PdfGrid</param> /// <param name="pdfColumnsDefinitions">List of the PdfColumnAttributes</param> /// <param name="summaryProperty">Sets the location of summary cell's data</param> /// <param name="labelProperty">Sets the location of summary cell's label</param> /// <param name="summaryCell">SummaryCell's Attributes</param> /// <param name="labelCell">LabelCell's Attributes</param> /// <param name="emptyCell">The other not in use cell's Attributes</param> /// <param name="itemsTemplate">Default ItemsTemplate</param> public static void AddSummaryRow(this PdfGrid table, IList<ColumnAttributes> pdfColumnsDefinitions, string summaryProperty, string labelProperty, CellAttributes summaryCell, CellAttributes labelCell, CellAttributes emptyCell, IColumnItemsTemplate itemsTemplate) { foreach (var col in pdfColumnsDefinitions) { if (col.PropertyName == summaryProperty) { table.AddCell(summaryCell.CreateSafePdfPCell(itemsTemplate)); } else if (col.PropertyName == labelProperty) { table.AddCell(labelCell.CreateSafePdfPCell(itemsTemplate)); } else { table.AddCell(emptyCell.CreateSafePdfPCell(itemsTemplate)); } } }
/// <summary> /// Displaying current cell's data as an annotation. /// </summary> /// <param name="onPrintAnnotation">Return an AnnotationFieldData based on the passed value, which is the actual row's fields values from TableDataSource and CalculatedFieldFormula. If you don't want to add the annotation, return null.</param> public void Annotation(Func <IList <CellData>, AnnotationFieldData> onPrintAnnotation) { _columnItemsTemplate = new AnnotationField { OnPrintAnnotation = onPrintAnnotation }; }
/// <summary> /// Custom template of the in use property, /// controls how and what should be rendered in each cell of this column. /// It can be null. /// If you don't set it, new DisplayAsText() template will be used automatically. /// </summary> public void CustomTemplate(IColumnItemsTemplate columnItemsTemplate) { _columnItemsTemplate = columnItemsTemplate; }
/// <summary> /// Displaying current cell's data as text. /// </summary> public void TextBlock() { _columnItemsTemplate = new TextBlockField(); }
/// <summary> /// Displaying current cell's data as an Image. /// </summary> /// <param name="defaultImageFilePath">Default image will be used in case of null images</param> /// <param name="fitImages">Set fitImages to true to fit the image to the cell</param> /// <param name="cacheImages">If true, the image bytes will be added to the PDF only once, not per each new instance. Therefore the result won't be a bloated PDF file. Choose this option if there are many similar images in your data source.</param> public void ByteArrayImage(string defaultImageFilePath, bool fitImages, bool cacheImages = true) { _columnItemsTemplate = new ByteArrayImageField(defaultImageFilePath, fitImages, cacheImages); }
/// <summary> /// Custom template of the in use property, controls how and what should be rendered in each cell of this column. /// It can be null. /// If you don't set it, new DisplayAsText() template will be used automatically. /// ColumnNamesItemsTemplates has higher priority. /// </summary> public void AddTypeColumnItemsTemplate(Type type, IColumnItemsTemplate template) { if (_builder.TypesColumnItemsTemplates == null) _builder.TypesColumnItemsTemplates = new Dictionary<Type, IColumnItemsTemplate>(); _builder.TypesColumnItemsTemplates.Add(type, template); }
private void setDisplayFormatFormula(string columnName, Type type, IColumnItemsTemplate template) { if (setColumnsDisplayFormatFormula(columnName, template)) return; if (_conventions == null || _conventions.TypesDisplayFormatFormulas == null || type == null) return; var displayFormatFormula = _conventions.TypesDisplayFormatFormulas.FirstOrDefault(x => x.Key == type); template.BasicProperties.DisplayFormatFormula = displayFormatFormula.Value; }
/// <summary> /// Displaying current cell's data as a hyperlink /// </summary> /// <param name="foreColor"></param> /// <param name="fontUnderline"></param> /// <param name="textPropertyName">If you don't set TextPropertyName, current cell's text will be used as hyperlink's text.</param> /// <param name="navigationUrlPropertyName">If you don't set NavigationUrlPropertyName, current cell's text will be used as hyperlink's target url.</param> public void Hyperlink(System.Drawing.Color foreColor, bool fontUnderline, string textPropertyName = "", string navigationUrlPropertyName = "") { _columnItemsTemplate = new HyperlinkField(new BaseColor(foreColor.ToArgb()), fontUnderline) { NavigationUrlPropertyName = navigationUrlPropertyName, TextPropertyName = textPropertyName }; }
private static PdfPCell runOnItemsTemplate(CellAttributes pdfRptTableCellDefinition, IColumnItemsTemplate defaultItemTemplate) { return (pdfRptTableCellDefinition.ItemTemplate == null? defaultItemTemplate.RenderingCell(pdfRptTableCellDefinition) : pdfRptTableCellDefinition.ItemTemplate.RenderingCell(pdfRptTableCellDefinition)); }
/// <summary> /// Using iTextSharp's limited HTML to PDF capabilities. /// </summary> /// <param name="styleSheet">Defines styles for HTMLWorker.</param> public void Html(StyleSheet styleSheet = null) { _columnItemsTemplate = new HtmlField { StyleSheet = styleSheet }; }
public void Html(StyleSheet styleSheet = null) { _columnItemsTemplate = new HtmlField { StyleSheet = styleSheet }; }
/// <summary> /// Defines how to display the current cell's data. /// </summary> /// <param name="inlineFieldBuilder">Defines how to display the current cell's data.</param> public void InlineField(Action<InlineFieldBuilder> inlineFieldBuilder) { var builder = new InlineFieldBuilder(); inlineFieldBuilder(builder); _columnItemsTemplate = builder.InlineField; }
private static PdfPCell runOnItemsTemplate(CellAttributes pdfRptTableCellDefinition, IColumnItemsTemplate defaultItemTemplate) { return pdfRptTableCellDefinition.ItemTemplate == null ? defaultItemTemplate.RenderingCell(pdfRptTableCellDefinition) : pdfRptTableCellDefinition.ItemTemplate.RenderingCell(pdfRptTableCellDefinition); }
/// <summary> /// Using an AcroForm or a simple pdf template file as the Cells template. /// </summary> /// <param name="pdfTemplatePath">An AcroForm or a simple pdf template file's path. Only first page of the passed AcroForm makes sense here as a cell's template!</param> /// <param name="onFillAcroForm">Gives you the Row's data and AcroForm to set form.SetField method. It can be null.</param> public void PdfTemplate(string pdfTemplatePath, Action<IList<CellData>, AcroFields, PdfStamper> onFillAcroForm) { _columnItemsTemplate = new PdfTemplateField { PdfTemplatePath = pdfTemplatePath, OnFillAcroForm = onFillAcroForm }; }
/// <summary> /// This item template is useful for displaying Boolean data (true/false) as checkMarks /// </summary> /// <param name="checkmarkFillColor">Checkmark's fill color.</param> /// <param name="crossSignFillColor">Fill color of the cross sign.</param> public void Checkmark(System.Drawing.Color?checkmarkFillColor = null, System.Drawing.Color?crossSignFillColor = null) { _columnItemsTemplate = new CheckmarkField { CheckmarkFillColor = checkmarkFillColor, CrossSignFillColor = crossSignFillColor }; }
/// <summary> /// Displaying current cell's data as text plus a ProgressBar. /// </summary> /// <param name="progressBarColorFormula">Progress bar's background color based on the current row's values.</param> /// <param name="showPercentText">Indicates whether the percentage text should be displayed or not.</param> public void ProgressBar(Func<IList<CellData>, System.Drawing.Color> progressBarColorFormula, bool showPercentText) { _columnItemsTemplate = new ProgressBarField { ProgressBarColorFormula = progressBarColorFormula, ShowPercentText = showPercentText }; }
/// <summary> /// Displaying current cell's data as an Image. It's assumed that this data point to the physical image's path on the disk. /// </summary> /// <param name="defaultImageFilePath">Default image will be used in case of missing images</param> /// <param name="fitImages">Set fitImages to true to fit the image to the cell</param> /// <param name="cacheImages">If true, the image bytes will be added to the PDF only once, not per each new instance. Therefore the result won't be a bloated PDF file. Choose this option if there are many similar images in your data source.</param> public void ImageFilePath(string defaultImageFilePath, bool fitImages, bool cacheImages = true) { _columnItemsTemplate = new ImageFilePathField(defaultImageFilePath, fitImages, cacheImages); }
/// <summary> /// Using an AcroForm or a simple pdf template file as the Cells template. /// </summary> /// <param name="pdfTemplatePath">An AcroForm or a simple pdf template file's path. Only first page of the passed AcroForm makes sense here as a cell's template!</param> /// <param name="onFillAcroForm">Gives you the Row's data and AcroForm to set form.SetField method. It can be null.</param> public void PdfTemplate(string pdfTemplatePath, Action <IList <CellData>, AcroFields, PdfStamper> onFillAcroForm) { _columnItemsTemplate = new PdfTemplateField { PdfTemplatePath = pdfTemplatePath, OnFillAcroForm = onFillAcroForm }; }
/// <summary> /// Using iTextSharp's HTML to PDF capabilities. /// This method uses the XmlWorker class of iTextSharp. /// </summary> /// <param name="cssFilesPath">Optional external CSS files.</param> /// <param name="inlineCss">Optional inline CSS content.</param> /// <param name="imagesRootPath">Optional images directory path.</param> public void XHtml(IList<string> cssFilesPath = null, string inlineCss = "", string imagesRootPath = "") { _columnItemsTemplate = new XHtmlField { CssFilesPath = cssFilesPath, ImagesPath = imagesRootPath, InlineCss = inlineCss }; }
/// <summary> /// Displaying current cell's data as text plus a ProgressBar. /// </summary> /// <param name="progressBarColorFormula">Progress bar's background color based on the current row's values.</param> /// <param name="showPercentText">Indicates whether the percentage text should be displayed or not.</param> public void ProgressBar(Func <IList <CellData>, System.Drawing.Color> progressBarColorFormula, bool showPercentText) { _columnItemsTemplate = new ProgressBarField { ProgressBarColorFormula = progressBarColorFormula, ShowPercentText = showPercentText }; }
/// <summary> /// This item template is useful for displaying Boolean data (true/false) as checkMarks /// </summary> /// <param name="checkmarkFillColor">Checkmark's fill color.</param> /// <param name="crossSignFillColor">Fill color of the cross sign.</param> public void Checkmark(System.Drawing.Color? checkmarkFillColor = null, System.Drawing.Color? crossSignFillColor = null) { _columnItemsTemplate = new CheckmarkField { CheckmarkFillColor = checkmarkFillColor, CrossSignFillColor = crossSignFillColor }; }
private bool setColumnsDisplayFormatFormula(string columnName, IColumnItemsTemplate template) { if (_conventions == null || _conventions.ColumnNamesDisplayFormatFormulas == null) return false; var displayFormatFormula = _conventions.ColumnNamesDisplayFormatFormulas.FirstOrDefault(x => x.Key == columnName); if (displayFormatFormula.Value == null) return false; template.BasicProperties.DisplayFormatFormula = displayFormatFormula.Value; return true; }