Example #1
0
        private PdfGrid createTable(string html)
        {
            var table = new PdfGrid(1)
            {
                RunDirection    = (int)FooterProperties.RunDirection,
                WidthPercentage = FooterProperties.TableWidthPercentage
            };
            var htmlCell = new HtmlWorkerHelper
            {
                PdfFont             = FooterProperties.PdfFont,
                HorizontalAlignment = FooterProperties.HorizontalAlignment,
                Html         = html,
                RunDirection = FooterProperties.RunDirection,
                StyleSheet   = FooterProperties.StyleSheet,
                PdfElement   = _totalPageCountImage
            }.RenderHtml();

            htmlCell.HorizontalAlignment = (int)FooterProperties.HorizontalAlignment;
            htmlCell.Border = 0;
            table.AddCell(htmlCell);

            if (FooterProperties.ShowBorder)
            {
                return(table.AddBorderToTable(FooterProperties.BorderColor, FooterProperties.SpacingBeforeTable));
            }
            table.SpacingBefore = this.FooterProperties.SpacingBeforeTable;

            return(table);
        }
        public PdfGrid RenderingReportHeader(Document pdfDoc, PdfWriter pdfWriter, IList <SummaryCellData> summaryData)
        {
            var table = new PdfGrid(numColumns: 1)
            {
                WidthPercentage = 100
            };

            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                //electroweb/Images/wwwroot/01.png does not exists & defaultImageFilePath was not found.'

                /*  string url ="http://54.86.105.4/";
                 * cellData.CellTemplate = new ImageFilePathField();
                 *
                 * cellData.Value = TestUtils.GetHtmlPage(url+"Fotos/fb9c27b1-98f7-4388-b13c-664d22cac022.jpg");
                 * cellProperties.HorizontalAlignment = HorizontalAlignment.Center;*/
                cellData.CellTemplate = new ImageFilePathField();
                cellData.Value        = TestUtils.GetImagePath("logo.png");
                cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
            });
            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Reporte inventario";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
            });
            return(table.AddBorderToTable());
        }
Example #3
0
        private PdfGrid createTable(string html, XHeaderBasicProperties basicProperties)
        {
            var table = new PdfGrid(1)
            {
                RunDirection    = (int)basicProperties.RunDirection,
                WidthPercentage = basicProperties.TableWidthPercentage
            };
            var htmlCell = new XmlWorkerHelper
            {
                Html         = html,
                RunDirection = basicProperties.RunDirection,
                CssFilesPath = basicProperties.CssFilesPath,
                ImagesPath   = basicProperties.ImagesPath,
                InlineCss    = basicProperties.InlineCss,
                DefaultFont  = basicProperties.PdfFont.Fonts[0]
            }.RenderHtml();

            htmlCell.Border = 0;
            table.AddCell(htmlCell);

            if (basicProperties.ShowBorder)
            {
                return(table.AddBorderToTable(basicProperties.BorderColor, basicProperties.SpacingBeforeTable));
            }
            table.SpacingBefore = basicProperties.SpacingBeforeTable;

            return(table);
        }
        private PdfGrid createTable(string html)
        {
            var table = new PdfGrid(1)
            {
                RunDirection    = (int)FooterProperties.RunDirection,
                WidthPercentage = FooterProperties.TableWidthPercentage
            };
            var htmlCell = new XmlWorkerHelper
            {
                Html         = html,
                RunDirection = FooterProperties.RunDirection,
                InlineCss    = FooterProperties.InlineCss,
                ImagesPath   = FooterProperties.ImagesPath,
                CssFilesPath = FooterProperties.CssFilesPath,
                PdfElement   = _totalPageCountImage
            }.RenderHtml();

            htmlCell.Border = 0;
            table.AddCell(htmlCell);

            if (FooterProperties.ShowBorder)
            {
                return(table.AddBorderToTable(FooterProperties.BorderColor, FooterProperties.SpacingBeforeTable));
            }
            table.SpacingBefore = this.FooterProperties.SpacingBeforeTable;

            return(table);
        }
Example #5
0
        public PdfGrid RenderingGroupHeader(Document pdfDoc, PdfWriter pdfWriter, IList <CellData> newGroupInfo, IList <SummaryCellData> summaryData)
        {
            var groupName = newGroupInfo.GetSafeStringValueOf <vm.ShipmentItem>(x => x.ShipmentId);

            var table = new PdfGrid(relativeWidths: new[] { 1f, 5f })
            {
                WidthPercentage = 100
            };

            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Shipment:".Localize();
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            },
                (cellData, cellProperties) =>
            {
                cellData.Value                     = groupName;
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            });

            return(table.AddBorderToTable(borderColor: BaseColor.LIGHT_GRAY, spacingBefore: 10f));
        }
        private PdfGrid createTable(string html, HeaderBasicProperties basicProperties)
        {
            var table = new PdfGrid(1)
            {
                RunDirection    = (int)basicProperties.RunDirection,
                WidthPercentage = basicProperties.TableWidthPercentage
            };
            var htmlCell = new HtmlWorkerHelper
            {
                PdfFont             = basicProperties.PdfFont,
                HorizontalAlignment = basicProperties.HorizontalAlignment,
                Html         = html,
                RunDirection = basicProperties.RunDirection,
                StyleSheet   = basicProperties.StyleSheet
            }.RenderHtml();

            htmlCell.HorizontalAlignment = (int)basicProperties.HorizontalAlignment;
            htmlCell.Border = 0;
            table.AddCell(htmlCell);

            if (basicProperties.ShowBorder)
            {
                return(table.AddBorderToTable(basicProperties.BorderColor, basicProperties.SpacingBeforeTable));
            }
            table.SpacingBefore = basicProperties.SpacingBeforeTable;

            return(table);
        }
    public PdfGrid RenderingGroupHeader(Document pdfDoc, PdfWriter pdfWriter, IList <CellData> newGroupInfo, IList <SummaryCellData> summaryData)
    {
        var fechacreacion = "sdfdsf";
        var codigoapoyo   = "sdfdsf";
        var altura        = 4;

        var table = new PdfGrid(relativeWidths: new[] { 1f, 5f })
        {
            WidthPercentage = 100
        };

        table.AddSimpleRow(
            (cellData, cellProperties) =>
        {
            cellData.Value                     = "Codigo apoyo:";
            cellProperties.PdfFont             = PdfRptFont;
            cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
            cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
        },
            (cellData, cellProperties) =>
        {
            cellData.Value                     = codigoapoyo;
            cellProperties.PdfFont             = PdfRptFont;
            cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
        });
        table.AddSimpleRow(
            (cellData, cellProperties) =>
        {
            cellData.Value                     = "Fecha Creacion";
            cellProperties.PdfFont             = PdfRptFont;
            cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
            cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
        },
            (cellData, cellProperties) =>
        {
            cellData.Value                     = fechacreacion;
            cellProperties.PdfFont             = PdfRptFont;
            cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
        });
        table.AddSimpleRow(
            (cellData, cellProperties) =>
        {
            cellData.Value                     = "Altura Disp:";
            cellProperties.PdfFont             = PdfRptFont;
            cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
            cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
        },
            (cellData, cellProperties) =>
        {
            cellData.Value                     = altura;
            cellProperties.PdfFont             = PdfRptFont;
            cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
        });
        return(table.AddBorderToTable(borderColor: BaseColor.LightGray, spacingBefore: 5f));
    }
        public PdfGrid RenderingGroupHeader(Document pdfDoc, PdfWriter pdfWriter, IList <CellData> newGroupInfo, IList <SummaryCellData> summaryData)
        {
            var codigoapoyo    = newGroupInfo.GetSafeStringValueOf <Usuario>(x => x.Nombre);
            var parentLastName = newGroupInfo.GetSafeStringValueOf <Usuario>(x => x.Empresa_Id);
            var IdElement      = newGroupInfo.GetSafeStringValueOf <Usuario>(x => x.Id);

            var table = new PdfGrid(relativeWidths: new[] { 1f, 5f })
            {
                WidthPercentage = 100
            };

            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Codigo apoyo:";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            },
                (cellData, cellProperties) =>
            {
                cellData.Value                     = codigoapoyo;
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            });
            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Empresa Id:";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            },
                (cellData, cellProperties) =>
            {
                cellData.Value                     = parentLastName;
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            });
            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Id:";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            },
                (cellData, cellProperties) =>
            {
                cellData.Value                     = IdElement;
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            });
            return(table.AddBorderToTable(borderColor: BaseColor.LightGray, spacingBefore: 5f));
        }
Example #9
0
        public PdfGrid RenderingGroupHeader(Document pdfDoc, PdfWriter pdfWriter, IList <CellData> newGroupInfo, IList <SummaryCellData> summaryData)
        {
            var parentName      = newGroupInfo.GetSafeStringValueOf("ParentName");
            var parentLastName  = newGroupInfo.GetSafeStringValueOf("ParentLastName");
            var parentBirthDate = newGroupInfo.GetSafeStringValueOf("ParentBirthDate");

            var table = new PdfGrid(relativeWidths: new[] { 1f, 5f })
            {
                WidthPercentage = 100
            };

            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Name:";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            },
                (cellData, cellProperties) =>
            {
                cellData.Value                     = parentName;
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            });
            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Last Name:";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            },
                (cellData, cellProperties) =>
            {
                cellData.Value                     = parentLastName;
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            });
            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Birth Date:";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            },
                (cellData, cellProperties) =>
            {
                cellData.Value                     = parentBirthDate;
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            });
            return(table.AddBorderToTable(borderColor: BaseColor.LightGray, spacingBefore: 5f));
        }
Example #10
0
            public PdfGrid RenderingReportHeader(Document pdfDoc, PdfWriter pdfWriter, IList <SummaryCellData> summaryData)
            {
                var table = new PdfGrid(numColumns: 1)
                {
                    WidthPercentage = 100
                };

                table.AddSimpleRow(
                    (cellData, cellProperties) =>
                {
                    cellData.Value                     = naslov;
                    cellProperties.PdfFont             = PdfRptFont;
                    cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                });
                return(table.AddBorderToTable());
            }
Example #11
0
        public PdfGrid RenderingGroupHeader(Document pdfDoc, PdfWriter pdfWriter, IList <CellData> newGroupInfo, IList <SummaryCellData> summaryData)
        {
            var groupName = newGroupInfo.GetSafeStringValueOf <Employee>(x => x.Department);
            var age       = newGroupInfo.GetSafeStringValueOf <Employee>(x => x.Age);

            var table = new PdfGrid(relativeWidths: new[] { 1f, 5f })
            {
                WidthPercentage = 100
            };

            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Department:";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            },
                (cellData, cellProperties) =>
            {
                cellData.Value                     = groupName;
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            });
            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Age:";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            },
                (cellData, cellProperties) =>
            {
                cellData.Value                     = age;
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
            });
            return(table.AddBorderToTable(borderColor: BaseColor.LightGray, spacingBefore: 10f));
        }
Example #12
0
        public PdfGrid RenderingReportHeader(Document pdfDoc, PdfWriter pdfWriter, IList <SummaryCellData> summaryData)
        {
            var table = new PdfGrid(numColumns: 1)
            {
                WidthPercentage = 100
            };

            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.CellTemplate = new ImageFilePathField();
                cellData.Value        = TestUtils.GetImagePath("01.png");
                cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
            });
            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Grouping employees by department and age";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
            });
            return(table.AddBorderToTable());
        }
Example #13
0
        public PdfGrid RenderingReportHeader(Document pdfDoc, PdfWriter pdfWriter, IList <SummaryCellData> summaryData)
        {
            var table = new PdfGrid(numColumns: 1)
            {
                WidthPercentage = 100
            };

            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.CellTemplate = new ImageFilePathField();
                cellData.Value        = System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\01.png");
                cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
            });
            table.AddSimpleRow(
                (cellData, cellProperties) =>
            {
                cellData.Value                     = "Family rpt";
                cellProperties.PdfFont             = PdfRptFont;
                cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
            });
            return(table.AddBorderToTable());
        }
        public static IPdfReportData CreatePdfReport(CompetitonReportModel reportModel, string headerMessage)
        {
            var appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (HttpContext.Current != null)
            {
                appPath = HttpContext.Current.Server.MapPath("~/App_Data");
            }

            return(new PdfReport().DocumentPreferences(doc =>
            {
                doc.RunDirection(PdfRunDirection.RightToLeft);
                doc.Orientation(PageOrientation.Portrait);
                doc.PageSize(PdfPageSize.A4);
                doc.DocumentMetadata(new DocumentMetadata
                {
                    Author = "Vahid",
                    Application = "PdfRpt",
                    Keywords = "IList Rpt.",
                    Subject = "Test Rpt",
                    Title = "Test"
                });
                doc.Compression(new CompressionSettings
                {
                    EnableCompression = true,
                    EnableFullCompression = true
                });
            })
                   .DefaultFonts(fonts =>
            {
                //fonts.Path(
                //    System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\arial.ttf"),
                //    System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\verdana.ttf"));
                fonts.Path(HttpContext.Current.Server.MapPath("~/Content/Fonts/irsans.ttf"),
                           System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\Tahoma.ttf"));
                fonts.Size(9);
                fonts.Color(System.Drawing.Color.Black);
            })
                   .PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToPersianDateTime());
                //var date = DateTime.Now.ToString("MM/dd/yyyy");
                //footer.InlineFooter(inlineFooter =>
                //{
                //    inlineFooter.FooterProperties(new FooterBasicProperties
                //    {
                //        PdfFont = footer.PdfFont,
                //        HorizontalAlignment = HorizontalAlignment.Center,
                //        RunDirection = PdfRunDirection.LeftToRight,
                //        SpacingBeforeTable = 30,
                //        TotalPagesCountTemplateHeight = 9,
                //        TotalPagesCountTemplateWidth = 50
                //    });

                //    //return inlineFooter;
                //});
            })
                   .PagesHeader(header =>
            {
                header.CacheHeader(cache: true);     // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.RightToLeft);
                    //defaultHeader.ImagePath(System.IO.Path.Combine(appPath, "Images\\01.png"));
                    defaultHeader.Message(headerMessage);
                });
            })
                   .MainTableTemplate(template =>
            {
                //template.BasicTemplate(BasicTemplate.BlackAndBlue1Template);
                template.CustomTemplate(new MyTemplate());
            })
                   .MainTablePreferences(table =>
            {
                table.ColumnsWidthsType(TableColumnWidthType.Relative);
                table.SpacingBefore(10);
                table.SplitLate(true);
            })
                   .MainTableDataSource(dataSource =>
            {
                dataSource.StronglyTypedList(reportModel.Competitors);
            })
                   .MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName("rowNo");
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <CompetitorsReportModel>(x => x.Image);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(3);
                    column.HeaderCell("تصویر");
                    column.FixedHeight(70);
                    column.ColumnItemsTemplate(t => t.ImageFilePath(defaultImageFilePath: string.Empty,
                                                                    fitImages: true));
                });


                columns.AddColumn(column =>
                {
                    column.PropertyName <CompetitorsReportModel>(x => x.FullName);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(3.5f);
                    column.HeaderCell("نام و نام خانوادگی");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <CompetitorsReportModel>(x => x.FatherName);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(2);
                    column.HeaderCell("نام پدر");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <CompetitorsReportModel>(x => x.BirthDate);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2.5f);
                    column.HeaderCell("تاریخ تولد");
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                ? string.Empty
                                : ((DateTime)obj).ToPersianDateTime(includeHourMinute: false));
                    });
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <CompetitorsReportModel>(x => x.NationalCode);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(3);
                    column.HeaderCell("کد ملی");
                });



                columns.AddColumn(column =>
                {
                    column.PropertyName <CompetitorsReportModel>(x => x.StudyField);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2);
                    column.HeaderCell("رشته");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <CompetitorsReportModel>(x => x.StudentNumber);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(3);
                    column.HeaderCell("شماره دانشجویی");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <CompetitorsReportModel>(x => x.InsuranceNumber);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(3);
                    column.HeaderCell("شماره کارت بیمه ورزشی");
                });
            })
                   .MainTableEvents(events =>
            {
                events.DataSourceIsEmpty(message: "There is no data available to display.");

                events.DocumentClosing(e =>
                {
                    // close the document without closing the underlying stream
                    e.PdfWriter.CloseStream = false;
                    e.PdfDoc.Close();

                    e.PdfStreamOutput.Position = 0;
                });


                events.MainTableAdded(args =>
                {
                    var infoTable = new PdfGrid(numColumns: 2)
                    {
                        WidthPercentage = 100,
                        SpacingAfter = 50,
                        SpacingBefore = 50,
                        RunDirection = PdfWriter.RUN_DIRECTION_RTL,
                        SplitLate = true,
                        SplitRows = true
                    };

                    infoTable.AddSimpleRow(

                        (cellData, properties) =>
                    {
                        cellData.Value =
                            "مراتب فوق مورد تایید است.\n \n \n \n \n مهر و امضاء مسئول تربیت بدنی واحد";
                        properties.ShowBorder = true;
                        properties.BorderWidth = 0;
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.RightToLeft;

                        properties.FixedHeight = 80;
                        //properties.PaddingTop = 0;
                        //properties.PaddingRight = 25;
                        //properties.PaddingLeft = 25;
                        //properties.PaddingBottom = 0;

                        properties.HorizontalAlignment = HorizontalAlignment.Left;
                        //properties.PdfFontStyle = DocumentFontStyle.Bold;
                    },
                        (cellData, properties) =>
                    {
                        cellData.Value = "مراتب فوق مورد تایید است.\n \n \n \n \n مهر و امضاء رئیس واحد";
                        properties.ShowBorder = true;
                        properties.BorderWidth = 0;
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.RightToLeft;

                        properties.FixedHeight = 80;
                        //properties.PaddingTop = 0;
                        //properties.PaddingRight = 25;
                        //properties.PaddingLeft = 25;
                        //properties.PaddingBottom = 0;

                        properties.HorizontalAlignment = HorizontalAlignment.Left;
                        //properties.PdfFontStyle= DocumentFontStyle.Bold;
                    }
                        );


                    //args.Table.ad


                    var techTitleTable = new PdfGrid(numColumns: 2)
                    {
                        WidthPercentage = 100,
                        SpacingAfter = 20,
                        SpacingBefore = 20,
                        RunDirection = PdfWriter.RUN_DIRECTION_RTL,
                    };

                    techTitleTable.AddSimpleRow(

                        (cellData, properties) =>
                    {
                        cellData.Value =
                            "فهرست اعضای کادر فنی";
                        properties.ShowBorder = true;
                        properties.BorderWidth = 0;
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.RightToLeft;

                        properties.FixedHeight = 20;
                        //properties.PaddingTop = 0;
                        //properties.PaddingRight = 25;
                        //properties.PaddingLeft = 25;
                        //properties.PaddingBottom = 0;

                        properties.HorizontalAlignment = HorizontalAlignment.Left;
                        //properties.PdfFontStyle = DocumentFontStyle.Bold;
                    },
                        (cellData, properties) =>
                    {
                        cellData.Value = "";
                        properties.ShowBorder = true;
                        properties.BorderWidth = 0;
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.RightToLeft;

                        properties.FixedHeight = 20;
                        //properties.PaddingTop = 0;
                        //properties.PaddingRight = 25;
                        //properties.PaddingLeft = 25;
                        //properties.PaddingBottom = 0;

                        properties.HorizontalAlignment = HorizontalAlignment.Left;
                        //properties.PdfFontStyle= DocumentFontStyle.Bold;
                    }
                        );



                    var table = new PdfGrid(6)
                    {
                        WidthPercentage = 100,
                        SpacingAfter = 50,
                        SpacingBefore = 50,
                        RunDirection = PdfWriter.RUN_DIRECTION_RTL,
                        ExtendLastRow = false,
                        HeaderRows = 1,
                        SplitLate = true,
                        SplitRows = true,
                    };


                    var borderColor = new BaseColor(ColorTranslator.FromHtml("#999999").ToArgb());

                    var oddRowColor = new BaseColor(ColorTranslator.FromHtml("#CCCCCC").ToArgb());

                    //table.SetExtendLastRow(false, false);

                    table.AddSimpleRow(
                        (cellData, cellProperties) =>
                    {
                        cellProperties.CellPadding = 3;
                        cellData.Value = "#";
                        //cellProperties.PdfFont = PdfRptFont;
                        cellProperties.PdfFontStyle = DocumentFontStyle.Bold;
                        cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                        cellProperties.ShowBorder = true;
                        cellProperties.BorderWidth = 0;
                        cellProperties.PdfFont = events.PdfFont;
                        cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                        cellProperties.BorderColor = borderColor;
                    },
                        (cellData, cellProperties) =>
                    {
                        cellData.Value = "تصویر";
                        //cellProperties.PdfFont = PdfRptFont;
                        cellProperties.PdfFontStyle = DocumentFontStyle.Bold;
                        cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                        cellProperties.ShowBorder = true;
                        cellProperties.BorderWidth = 0;
                        cellProperties.PdfFont = events.PdfFont;
                        cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                        cellProperties.BorderColor = borderColor;
                    },
                        (cellData, cellProperties) =>
                    {
                        cellData.Value = "نام و نام خانوادگی";
                        //cellProperties.PdfFont = PdfRptFont;
                        cellProperties.PdfFontStyle = DocumentFontStyle.Bold;
                        cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                        cellProperties.ShowBorder = true;
                        cellProperties.BorderWidth = 0;
                        cellProperties.PdfFont = events.PdfFont;
                        cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                        cellProperties.BorderColor = borderColor;
                    },
                        (cellData, cellProperties) =>
                    {
                        cellData.Value = "نام پدر";
                        //cellProperties.PdfFont = PdfRptFont;
                        cellProperties.PdfFontStyle = DocumentFontStyle.Bold;
                        cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                        cellProperties.ShowBorder = true;
                        cellProperties.BorderWidth = 0;
                        cellProperties.PdfFont = events.PdfFont;
                        cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                        cellProperties.BorderColor = borderColor;
                    },
                        (cellData, cellProperties) =>
                    {
                        cellData.Value = "کد ملی";
                        //cellProperties.PdfFont = PdfRptFont;
                        cellProperties.PdfFontStyle = DocumentFontStyle.Bold;
                        cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                        cellProperties.ShowBorder = true;
                        cellProperties.BorderWidth = 0;
                        cellProperties.PdfFont = events.PdfFont;
                        cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                        cellProperties.BorderColor = borderColor;
                    },
                        (cellData, cellProperties) =>
                    {
                        cellData.Value = "سمت";
                        cellProperties.PdfFontStyle = DocumentFontStyle.Bold;
                        cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                        cellProperties.ShowBorder = true;
                        cellProperties.BorderWidth = 0;
                        cellProperties.PdfFont = events.PdfFont;
                        cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                        cellProperties.BorderColor = borderColor;
                    }
                        );

                    var index = 1;

                    foreach (var technicalStaff in reportModel.TechnicalStaves)
                    {
                        var staff = technicalStaff;
                        var staff1 = technicalStaff;
                        var technicalStaff1 = technicalStaff;
                        bool isOdd = (index % 2 != 0);

                        var staff2 = technicalStaff;
                        table.AddSimpleRow(
                            (cellData, cellProperties) =>
                        {
                            cellData.Value = index.ToString();
                            index++;
                            //cellProperties.PdfFont = PdfRptFont;
                            cellProperties.PdfFontStyle = DocumentFontStyle.Normal;
                            cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                            cellProperties.ShowBorder = true;
                            cellProperties.BorderWidth = 0;
                            cellProperties.PdfFont = events.PdfFont;
                            cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                            cellProperties.BorderColor = borderColor;
                            if (isOdd)
                            {
                                cellProperties.BackgroundColor = oddRowColor;
                            }
                        },
                            (cellData, cellProperties) =>
                        {
                            cellData.CellTemplate = new ImageFilePathField(defaultImageFilePath: string.Empty,
                                                                           fitImages: true);
                            cellData.Value = staff2.Image;
                            cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                            cellProperties.PdfFontStyle = DocumentFontStyle.None;
                            cellProperties.ShowBorder = true;
                            cellProperties.BorderWidth = 0;
                            cellProperties.PdfFont = events.PdfFont;
                            cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                            cellProperties.FixedHeight = 70;
                            cellProperties.CellPadding = 0;
                            cellProperties.BorderColor = borderColor;
                            if (isOdd)
                            {
                                cellProperties.BackgroundColor = oddRowColor;
                            }
                        },
                            (cellData, cellProperties) =>
                        {
                            cellData.Value = staff1.FullName;
                            //cellProperties.PdfFont = PdfRptFont;
                            cellProperties.PdfFontStyle = DocumentFontStyle.Normal;
                            cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                            cellProperties.ShowBorder = true;
                            cellProperties.BorderWidth = 0;
                            cellProperties.PdfFont = events.PdfFont;
                            cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                            cellProperties.BorderColor = borderColor;
                            if (isOdd)
                            {
                                cellProperties.BackgroundColor = oddRowColor;
                            }
                        },
                            (cellData, cellProperties) =>
                        {
                            cellData.Value = technicalStaff1.FatherName;
                            //cellProperties.PdfFont = PdfRptFont;
                            cellProperties.PdfFontStyle = DocumentFontStyle.Normal;
                            cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                            cellProperties.ShowBorder = true;
                            cellProperties.BorderWidth = 0;
                            cellProperties.PdfFont = events.PdfFont;
                            cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                            cellProperties.BorderColor = borderColor;
                            if (isOdd)
                            {
                                cellProperties.BackgroundColor = oddRowColor;
                            }
                        },
                            (cellData, cellProperties) =>
                        {
                            cellData.Value = staff.NationalCode;
                            //cellProperties.PdfFont = PdfRptFont;
                            cellProperties.PdfFontStyle = DocumentFontStyle.Normal;
                            cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                            cellProperties.ShowBorder = true;
                            cellProperties.BorderWidth = 0;
                            cellProperties.PdfFont = events.PdfFont;
                            cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                            cellProperties.BorderColor = borderColor;
                            if (isOdd)
                            {
                                cellProperties.BackgroundColor = oddRowColor;
                            }
                        },
                            (cellData, cellProperties) =>
                        {
                            cellData.Value = staff.Role;
                            //cellProperties.PdfFont = PdfRptFont;
                            cellProperties.PdfFontStyle = DocumentFontStyle.Normal;
                            cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
                            cellProperties.ShowBorder = true;
                            cellProperties.BorderWidth = 0;
                            cellProperties.PdfFont = events.PdfFont;
                            cellProperties.RunDirection = PdfRunDirection.RightToLeft;
                            cellProperties.BorderColor = borderColor;
                            if (isOdd)
                            {
                                cellProperties.BackgroundColor = oddRowColor;
                            }
                        }
                            );
                    }


                    techTitleTable.AddBorderToTable(borderColor: new BaseColor(ColorTranslator.FromHtml("#999999").ToArgb()), spacingBefore: 5f);


                    table.AddBorderToTable(borderColor: new BaseColor(ColorTranslator.FromHtml("#999999").ToArgb()), spacingBefore: 5f);

                    table.SetExtendLastRow(false, false);

                    int[] firstTablecellwidth = { 13, 15, 12, 20, 12, 5 };

                    table.SetWidths(firstTablecellwidth);

                    infoTable.SetExtendLastRow(false, false);


                    args.PdfDoc.Add(table);
                    //args.PdfDoc.Add(techTitleTable);
                    args.PdfDoc.Add(infoTable);
                });
            })
                   .Export(export =>
            {
                //export.ToExcel();
            })
                   .Generate(
                       data => data.AsPdfStream(new MemoryStream())
                       //data.AsPdfFile(string.Format("{0}\\Pdf\\EFSample-{1}.pdf", appPath, Guid.NewGuid().ToString("N")))
                       ));
            // data.AsPdfFile(string.Format("{0}\\Pdf\\EFSample-{1}.pdf", appPath, Guid.NewGuid().ToString("N"))));
        }
Example #15
0
        public IPdfReportData CreatePdfReport()
        {
            return(new PdfReport().DocumentPreferences(doc =>
            {
                doc.RunDirection(PdfRunDirection.LeftToRight);
                doc.Orientation(PageOrientation.Portrait);
                doc.PageSize(PdfPageSize.A4);
                doc.DocumentMetadata(new DocumentMetadata {
                    Author = "Vahid", Application = "PdfRpt", Keywords = "IList Rpt.", Subject = "Test Rpt", Title = "Test"
                });
                doc.Compression(new CompressionSettings
                {
                    EnableCompression = true,
                    EnableFullCompression = true
                });
            })
                   .DefaultFonts(fonts =>
            {
                fonts.Path(System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\arial.ttf"),
                           System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\verdana.ttf"));
                fonts.Size(9);
                fonts.Color(System.Drawing.Color.Black);
            })
                   .PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("MM/dd/yyyy"));
            })
                   .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.ImagePath(System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\01.png"));
                    defaultHeader.Message("Our new rpt.");
                });
            })
                   .MainTableTemplate(template =>
            {
                template.BasicTemplate(BasicTemplate.ClassicTemplate);
            })
                   .MainTablePreferences(table =>
            {
                table.ColumnsWidthsType(TableColumnWidthType.Relative);
                //table.NumberOfDataRowsPerPage(50); // don't set this line and let the PdfRpt calculate it automatically.
                //for long texts larger than a page
                table.SplitLate(false);
                table.SplitRows(true);
            })
                   .MainTableDataSource(dataSource =>
            {
                var longText = string.Join("", Enumerable.Repeat("a", 1500).ToArray());
                var report = new ApprovalReport
                {
                    DocumentTitle = "test",
                    StartDate = DateTime.Now,
                    EndDate = DateTime.Now,
                    InstanceId = Guid.Empty,
                    WorkflowInitiator = "test",
                    WorkflowInitiatorUrl = "test",
                    Approvals = new List <ApprovalReport.Approval>
                    {
                        new ApprovalReport.Approval {
                            Number = "1", ApprovalDate = DateTime.Now, Approver = "test1",
                            ApproverUrl = "test", Department = "test", Position = "test", Result = "test", Url = "test", Commentary = "test"
                        },

                        new ApprovalReport.Approval {
                            Number = "2", ApprovalDate = DateTime.Now, Approver = "test2",
                            ApproverUrl = "test", Department = "test", Position = "test", Result = "test", Url = "test",
                            Commentary = longText
                        },

                        new ApprovalReport.Approval {
                            Number = "3", ApprovalDate = DateTime.Now, Approver = "test3",
                            ApproverUrl = "test", Department = "test", Position = "test", Result = "test", Url = "test", Commentary = "test"
                        },
                    }
                };

                dataSource.StronglyTypedList(report.Approvals);
            })
                   .MainTableSummarySettings(summarySettings =>
            {
                summarySettings.OverallSummarySettings("Summary");
                summarySettings.PreviousPageSummarySettings("Previous Page Summary");
                summarySettings.PageSummarySettings("Page Summary");
            })
                   .MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName <ApprovalReport.Approval>(x => x.Number);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(1);
                    column.HeaderCell("№ П/П");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <ApprovalReport.Approval>(x => x.Approver);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Ф.И.О. согласующего");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <ApprovalReport.Approval>(x => x.Department);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(3);
                    column.HeaderCell("Подразделение");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <ApprovalReport.Approval>(x => x.Position);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(3);
                    column.HeaderCell("Должность");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <ApprovalReport.Approval>(x => x.ApprovalDate);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(5);
                    column.Width(2);
                    column.HeaderCell("Дата согласования");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <ApprovalReport.Approval>(x => x.Result);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(6);
                    column.Width(2);
                    column.HeaderCell("Результат");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <ApprovalReport.Approval>(x => x.Commentary);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(7);
                    column.Width(4);
                    column.HeaderCell("Замечания/комментарии");
                });
            })
                   .MainTableEvents(events =>
            {
                events.DataSourceIsEmpty(message: "Нет данных для отображения.");

                events.MainTableCreated(args =>
                {
                    var infoTable = new PdfGrid(numColumns: 1)
                    {
                        WidthPercentage = 100
                    };
                    infoTable.AddSimpleRow((cellData, properties) =>
                    {
                        properties.HorizontalAlignment = HorizontalAlignment.Left;
                        cellData.Value = string.Format("Название документа:   {0}", "DocumentTitle");
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.LeftToRight;
                    });
                    infoTable.AddSimpleRow((cellData, properties) =>
                    {
                        properties.HorizontalAlignment = HorizontalAlignment.Left;
                        cellData.Value = string.Format("Инициатор согласования:   {0}", "WorkflowInitiator");
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.LeftToRight;
                    });
                    infoTable.AddSimpleRow((cellData, properties) =>
                    {
                        properties.HorizontalAlignment = HorizontalAlignment.Left;
                        cellData.Value = string.Format("Дата начала согласования:   {0}", "StartDate");
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.LeftToRight;
                    });
                    infoTable.AddSimpleRow((cellData, properties) =>
                    {
                        properties.HorizontalAlignment = HorizontalAlignment.Left;
                        cellData.Value = string.Format("Дата окончания согласования:   {0}", "EndDate");
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.LeftToRight;
                    });

                    var table = infoTable.AddBorderToTable(borderColor: BaseColor.LIGHT_GRAY, spacingBefore: 10f);
                    table.SpacingAfter = 10f;
                    args.PdfDoc.Add(table);
                });
            })
                   .Export(export =>
            {
                export.ToExcel();
                export.ToCsv();
                export.ToXml();
            })
                   .Generate(data => data.AsPdfFile(string.Format("{0}\\Pdf\\RptLongTextInCellSample-{1}.pdf", AppPath.ApplicationPath, Guid.NewGuid().ToString("N")))));
        }
        public IPdfReportData CreateEventsPdfReport()
        {
            return(new PdfReport().DocumentPreferences(doc =>
            {
                doc.RunDirection(PdfRunDirection.LeftToRight);
                doc.Orientation(PageOrientation.Portrait);
                doc.PageSize(PdfPageSize.A4);
                doc.DocumentMetadata(new DocumentMetadata {
                    Author = "Vahid", Application = "PdfRpt", Keywords = "IList Rpt.", Subject = "Test Rpt", Title = "Test"
                });
                doc.Compression(new CompressionSettings
                {
                    EnableCompression = true,
                    EnableFullCompression = true
                });
            })
                   .DefaultFonts(fonts =>
            {
                fonts.Path(TestUtils.GetVerdanaFontPath(),
                           TestUtils.GetTahomaFontPath());
                fonts.Size(9);
                fonts.Color(System.Drawing.Color.Black);
            })
                   .PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("MM/dd/yyyy"));
            })
                   .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.ImagePath(TestUtils.GetImagePath("01.png"));
                    defaultHeader.Message("Our new rpt.");
                });
            })
                   .MainTableTemplate(template =>
            {
                template.BasicTemplate(BasicTemplate.SilverTemplate);
            })
                   .MainTablePreferences(table =>
            {
                table.ColumnsWidthsType(TableColumnWidthType.Relative);
            })
                   .MainTableDataSource(dataSource =>
            {
                var listOfRows = new List <Order>();
                for (int i = 0; i < 60; i++)
                {
                    listOfRows.Add(new Order
                    {
                        Id = i,
                        Description = "Description Description ... " + i,
                        Price = 1000 + i
                    });
                }
                dataSource.StronglyTypedList(listOfRows);
            })
                   .MainTableSummarySettings(summarySettings =>
            {
                summarySettings.OverallSummarySettings("Summary");
                summarySettings.PreviousPageSummarySettings("Previous Page Summary");
                summarySettings.PageSummarySettings("Page Summary");
            })
                   .MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName("rowNo");
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Order>(x => x.Description);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(3);
                    column.HeaderCell("Description");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Order>(x => x.Id);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(1);
                    column.HeaderCell("Id");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Order>(x => x.Price);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(2);
                    column.HeaderCell("Price");
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                            ? string.Empty : string.Format("{0:n0}", obj));
                    });
                    column.AggregateFunction(aggregateFunction =>
                    {
                        aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                        aggregateFunction.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                            ? string.Empty : string.Format("{0:n0}", obj));
                    });
                });
            })
                   .MainTableEvents(events =>
            {
                events.DataSourceIsEmpty(message: "There is no data available to display.");

                events.CellCreated(args =>
                {
                    if (args.CellType == CellType.PreviousPageSummaryCell ||
                        args.CellType == CellType.PageSummaryCell ||
                        args.CellType == CellType.SummaryRowCell)
                    {
                        if (!string.IsNullOrEmpty(args.Cell.RowData.FormattedValue) &&
                            args.Cell.RowData.PropertyName == "Price")
                        {
                            args.Cell.RowData.FormattedValue += " $";
                        }
                    }
                });

                events.MainTableCreated(args =>
                {
                    var infoTable = new PdfGrid(numColumns: 1)
                    {
                        WidthPercentage = 100
                    };
                    infoTable.AddSimpleRow(
                        (cellData, properties) =>
                    {
                        cellData.Value = "Show data before the main table ...";
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.LeftToRight;
                    });
                    var table = infoTable.AddBorderToTable(borderColor: BaseColor.LightGray, spacingBefore: 10f);
                    table.SpacingAfter = 10f;
                    args.PdfDoc.Add(table);
                });

                events.ShouldSkipRow(args =>
                {
                    var rowData = args.TableRowData;
                    //var previousTableRowData = args.PreviousTableRowData;

                    var description = rowData.FirstOrDefault(x => x.PropertyName == "Description");
                    if (description != null &&
                        description.PropertyValue.ToSafeString() == "Description Description ... 1")
                    {
                        return true; // don't render this row.
                    }

                    return false;
                });

                var pageNumber = 0;
                events.ShouldSkipHeader(args =>
                {
                    pageNumber++;
                    if (pageNumber == 2)
                    {
                        return true; // don't render this header row.
                    }

                    return false;
                });

                events.ShouldSkipFooter(args =>
                {
                    if (pageNumber == 2)
                    {
                        return true; // don't render this footer row.
                    }

                    return false;
                });

                events.MainTableAdded(args =>
                {
                    /*var objData = args.ColumnCellsSummaryData.Where(x => x.CellData.PropertyName.Equals("Price"))
                     *  .OrderByDescending(x => x.OverallRowNumber)
                     *  .First()
                     *  .OverallAggregateValue;*/

                    var data = args.LastOverallAggregateValueOf <Order>(y => y.Price);
                    var msg = "Total: " + data + ", " + long.Parse(data, NumberStyles.AllowThousands, CultureInfo.InvariantCulture).NumberToText(Language.English);
                    var infoTable = new PdfGrid(numColumns: 1)
                    {
                        WidthPercentage = 100
                    };
                    infoTable.AddSimpleRow(
                        (cellData, properties) =>
                    {
                        cellData.Value = "Show data after the main table ...";
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.LeftToRight;
                    });
                    infoTable.AddSimpleRow(
                        (cellData, properties) =>
                    {
                        cellData.Value = msg;
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.LeftToRight;
                    });
                    args.PdfDoc.Add(infoTable.AddBorderToTable(borderColor: BaseColor.LightGray, spacingBefore: 10f));
                });
            })
                   .Export(export =>
            {
                export.ToExcel();
            })
                   .Generate(data => data.AsPdfFile(TestUtils.GetOutputFileName())));
        }
Example #17
0
        public byte[] CreateInvoiceRtlPdfReport()
        {
            return(new PdfReport().DocumentPreferences(doc =>
            {
                doc.RunDirection(PdfRunDirection.RightToLeft);
                doc.Orientation(PageOrientation.Portrait);
                doc.PageSize(PdfPageSize.A5);
                doc.DocumentMetadata(new DocumentMetadata {
                    Author = "Vahid", Application = "PdfRpt", Keywords = "IList Rpt.", Subject = "Test Rpt", Title = "Test"
                });
                doc.Compression(new CompressionSettings
                {
                    EnableCompression = true,
                    EnableFullCompression = true
                });
                doc.PrintingPreferences(new PrintingPreferences
                {
                    ShowPrintDialogAutomatically = false
                });
            })
                   .DefaultFonts(fonts =>
            {
                fonts.Path(System.IO.Path.Combine(TestUtils.GetBaseDir(), "fonts", "irsans.ttf"),
                           TestUtils.GetVerdanaFontPath());
                fonts.Size(9);
                fonts.Color(System.Drawing.Color.Black);
            })
                   .PagesFooter(footer =>
            {
                footer.DefaultFooter("تاريخ: " + PersianDate.ToPersianDateTime(DateTime.Now, "/", true).FixWeakCharacters(),
                                     PdfRunDirection.RightToLeft);
            })
                   .PagesHeader(header =>
            {
                header.CacheHeader(cache: true);
                header.InlineHeader(inlineHeader =>
                {
                    inlineHeader.AddPageHeader(data => createHeader(header));
                });
            })
                   .MainTableTemplate(template =>
            {
                template.CustomTemplate(new TransparentTemplate());
            })
                   .MainTablePreferences(table =>
            {
                table.ColumnsWidthsType(TableColumnWidthType.Relative);
                table.SpacingAfter(0);
            })
                   .MainTableDataSource(dataSource =>
            {
                dataSource.StronglyTypedList(getDataSourceList());
            })
                   .MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName("rowNo");
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.FixedHeight(30);
                    column.HeaderCell("#");
                    column.AddHeadingCell("فاکتور پرداخت", mergeHeaderCell: true);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <InvoicePdfViewModel>(x => x.Status);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(6);
                    column.MinimumHeight(30);
                    column.HeaderCell("اطلاعات");
                    column.AddHeadingCell(string.Empty, mergeHeaderCell: true);
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <InvoicePdfViewModel>(x => x.Details);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(5);
                    column.HeaderCell("جزئیات");
                    column.AddHeadingCell(string.Empty, mergeHeaderCell: true);
                });
            })
                   .MainTableEvents(events =>
            {
                events.DataSourceIsEmpty(message: "رکوردی یافت نشد.");

                events.MainTableAdded(args =>
                {
                    var infoTable = new PdfGrid(numColumns: 1)
                    {
                        WidthPercentage = 100
                    };

                    infoTable.AddSimpleRow(
                        (cellData, properties) =>
                    {
                        cellData.Value = $"این فاکتور به منزله پرداخت شما به اشکان است.";
                        properties.PdfFont = events.PdfFont;
                        properties.FontColor = BaseColor.Gray;
                        properties.RunDirection = PdfRunDirection.RightToLeft;
                    });
                    infoTable.AddSimpleRow(
                        (cellData, properties) =>
                    {
                        cellData.Value = "هر گونه سوال در مورد خدمات یا محصول را با فروشنده در میان گذارید";
                        properties.PdfFont = events.PdfFont;
                        properties.FontColor = BaseColor.Gray;
                        properties.RunDirection = PdfRunDirection.RightToLeft;
                    });
                    args.PdfDoc.Add(infoTable.AddBorderToTable(borderColor: BaseColor.LightGray, spacingBefore: 1f));
                });
            })
                   .Export(export =>
            {
                export.ToExcel();
            })
                   .GenerateAsByteArray());
        }
Example #18
0
            public PdfGrid RenderingGroupHeader(Document pdfDoc, PdfWriter pdfWriter, IList <CellData> newGroupInfo, IList <SummaryCellData> summaryData)
            {
                var idDokumenta    = newGroupInfo.GetSafeStringValueOf(nameof(StavkaDenorm.IdDokumenta));
                var urlDokumenta   = newGroupInfo.GetSafeStringValueOf(nameof(StavkaDenorm.UrlDokumenta));
                var nazPartnera    = newGroupInfo.GetSafeStringValueOf(nameof(StavkaDenorm.NazPartnera));
                var datDokumenta   = (DateTime)newGroupInfo.GetValueOf(nameof(StavkaDenorm.DatDokumenta));
                var iznosDokumenta = (decimal)newGroupInfo.GetValueOf(nameof(StavkaDenorm.IznosDokumenta));

                var table = new PdfGrid(relativeWidths: new[] { 2f, 5f, 2f, 3f })
                {
                    WidthPercentage = 100
                };

                table.AddSimpleRow(
                    (cellData, cellProperties) =>
                {
                    cellData.Value                     = "Id dokumenta:";
                    cellProperties.PdfFont             = PdfRptFont;
                    cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                },
                    (cellData, cellProperties) =>
                {
                    cellData.TableRowData = newGroupInfo; //postavi podatke retka za ćeliju
                    var cellTemplate      = new HyperlinkField(BaseColor.Black, false)
                    {
                        TextPropertyName          = nameof(StavkaDenorm.IdDokumenta),
                        NavigationUrlPropertyName = nameof(StavkaDenorm.UrlDokumenta),
                        BasicProperties           = new CellBasicProperties
                        {
                            HorizontalAlignment = HorizontalAlignment.Left,
                            PdfFontStyle        = DocumentFontStyle.Bold,
                            PdfFont             = PdfRptFont
                        }
                    };

                    cellData.CellTemplate              = cellTemplate;
                    cellProperties.PdfFont             = PdfRptFont;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                },
                    (cellData, cellProperties) =>
                {
                    cellData.Value                     = "Datum dokumenta:";
                    cellProperties.PdfFont             = PdfRptFont;
                    cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                },
                    (cellData, cellProperties) =>
                {
                    cellData.Value                      = datDokumenta;
                    cellProperties.PdfFont              = PdfRptFont;
                    cellProperties.HorizontalAlignment  = HorizontalAlignment.Left;
                    cellProperties.DisplayFormatFormula = obj => ((DateTime)obj).ToString("dd.MM.yyyy");
                });

                table.AddSimpleRow(
                    (cellData, cellProperties) =>
                {
                    cellData.Value                     = "Partner:";
                    cellProperties.PdfFont             = PdfRptFont;
                    cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                },
                    (cellData, cellProperties) =>
                {
                    cellData.Value                     = nazPartnera;
                    cellProperties.PdfFont             = PdfRptFont;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                },
                    (cellData, cellProperties) =>
                {
                    cellData.Value                     = "Iznos dokumenta:";
                    cellProperties.PdfFont             = PdfRptFont;
                    cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                },
                    (cellData, cellProperties) =>
                {
                    cellData.Value = iznosDokumenta;
                    cellProperties.DisplayFormatFormula = obj => ((decimal)obj).ToString("C2");
                    cellProperties.PdfFont             = PdfRptFont;
                    cellProperties.HorizontalAlignment = HorizontalAlignment.Left;
                });
                return(table.AddBorderToTable(borderColor: BaseColor.LightGray, spacingBefore: 5f));
            }
Example #19
0
        public IPdfReportData CreatePdfReport()
        {
            return(new PdfReport().DocumentPreferences(doc =>
            {
                doc.RunDirection(PdfRunDirection.LeftToRight);
                doc.Orientation(PageOrientation.Portrait);
                doc.PageSize(PdfPageSize.A4);
                doc.DocumentMetadata(new DocumentMetadata {
                    Author = "Vahid", Application = "PdfRpt", Keywords = "IList Rpt.", Subject = "Test Rpt", Title = "Test"
                });
                doc.Compression(new CompressionSettings
                {
                    EnableCompression = true,
                    EnableFullCompression = true
                });
            })
                   .DefaultFonts(fonts =>
            {
                fonts.Path(System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\arial.ttf"),
                           System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\verdana.ttf"));
                fonts.Size(9);
                fonts.Color(System.Drawing.Color.Black);
            })
                   .PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("MM/dd/yyyy"));
            })
                   .PagesHeader(header =>
            {
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.ImagePath(System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\01.png"));
                    defaultHeader.Message("Our new rpt.");
                });
            })
                   .MainTableTemplate(template =>
            {
                template.BasicTemplate(BasicTemplate.SilverTemplate);
            })
                   .MainTablePreferences(table =>
            {
                table.ColumnsWidthsType(TableColumnWidthType.Relative);
            })
                   .MainTableDataSource(dataSource =>
            {
                var listOfRows = new List <Order>();
                for (int i = 0; i < 60; i++)
                {
                    listOfRows.Add(new Order
                    {
                        Id = i,
                        Description = "Description Description ... " + i,
                        Price = 1000 + i
                    });
                }
                dataSource.StronglyTypedList(listOfRows);
            })
                   .MainTableSummarySettings(summarySettings =>
            {
                summarySettings.OverallSummarySettings("Summary");
                summarySettings.PreviousPageSummarySettings("Previous Page Summary");
                summarySettings.PageSummarySettings("Page Summary");
            })
                   .MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName("rowNo");
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Order>(x => x.Description);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(3);
                    column.HeaderCell("Description");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Order>(x => x.Id);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(1);
                    column.HeaderCell("Id");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <Order>(x => x.Price);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(2);
                    column.HeaderCell("Price");
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null ? string.Empty : string.Format("{0:n0}", obj));
                    });
                    column.AggregateFunction(aggregateFunction =>
                    {
                        aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                        aggregateFunction.DisplayFormatFormula(obj => obj == null ? string.Empty : string.Format("{0:n0}", obj));
                    });
                });
            })
                   .MainTableEvents(events =>
            {
                events.DataSourceIsEmpty(message: "There is no data available to display.");

                events.MainTableCreated(args =>
                {
                    var infoTable = new PdfGrid(numColumns: 1)
                    {
                        WidthPercentage = 100
                    };
                    infoTable.AddSimpleRow(
                        (cellData, properties) =>
                    {
                        cellData.Value = "Show data before the main table ...";
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.LeftToRight;
                    });
                    var table = infoTable.AddBorderToTable(borderColor: BaseColor.LIGHT_GRAY, spacingBefore: 10f);
                    table.SpacingAfter = 10f;
                    args.PdfDoc.Add(table);
                });

                events.MainTableAdded(args =>
                {
                    var data = args.LastOverallAggregateValueOf <Order>(y => y.Price);
                    var msg = "Total: " + data + ", " + long.Parse(data, NumberStyles.AllowThousands, CultureInfo.InvariantCulture).NumberToText(Language.English);
                    var infoTable = new PdfGrid(numColumns: 1)
                    {
                        WidthPercentage = 100
                    };
                    infoTable.AddSimpleRow(
                        (cellData, properties) =>
                    {
                        cellData.Value = "Show data after the main table ...";
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.LeftToRight;
                    });
                    infoTable.AddSimpleRow(
                        (cellData, properties) =>
                    {
                        cellData.Value = msg;
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.LeftToRight;
                    });
                    args.PdfDoc.Add(infoTable.AddBorderToTable(borderColor: BaseColor.LIGHT_GRAY, spacingBefore: 10f));
                });
            })
                   .Export(export =>
            {
                export.ToExcel();
            })
                   .Generate(data => data.AsPdfFile(string.Format("{0}\\Pdf\\EventsPdfReport-{1}.pdf", AppPath.ApplicationPath, Guid.NewGuid().ToString("N")))));
        }
Example #20
0
        public IPdfReportData CreatePdfReport()
        {
            return(new PdfReport().DocumentPreferences(doc =>
            {
                doc.RunDirection(PdfRunDirection.RightToLeft);
                doc.Orientation(PageOrientation.Portrait);
                doc.PageSize(PdfPageSize.A4);
                doc.DocumentMetadata(new DocumentMetadata {
                    Author = "Vahid", Application = "PdfRpt", Keywords = "Test", Subject = "Test Rpt", Title = "Test"
                });
                doc.Compression(new CompressionSettings
                {
                    EnableCompression = true,
                    EnableFullCompression = true
                });
            })
                   .DefaultFonts(fonts =>
            {
                fonts.Path(System.IO.Path.Combine(AppPath.ApplicationPath, "fonts\\irsans.ttf"),
                           System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\verdana.ttf"));
                fonts.Size(9);
                fonts.Color(System.Drawing.Color.Black);
            })
                   .PagesFooter(footer =>
            {
                footer.DefaultFooter("تاريخ: " + PersianDate.ToPersianDateTime(DateTime.Now, "/", true).FixWeakCharacters(),
                                     PdfRunDirection.RightToLeft);
            })
                   .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.Message("گزارش جديد ما");
                    defaultHeader.ImagePath(System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\01.png"));
                });
            })
                   .MainTableTemplate(template =>
            {
                template.BasicTemplate(BasicTemplate.ClassicTemplate);
            })
                   .MainTablePreferences(table =>
            {
                table.ColumnsWidthsType(TableColumnWidthType.Relative);
            })
                   .MainTableDataSource(dataSource =>
            {
                var listOfRows = new List <User>();
                for (int i = 0; i < 320; i++)
                {
                    listOfRows.Add(new User
                    {
                        Id = i + 1,
                        LastName = "نام خانوادگي " + i,
                        Name = "نام " + i,
                        Balance = i + 1000,
                        RegisterDate = DateTime.Now.AddDays(-i)
                    });
                }
                dataSource.StronglyTypedList(listOfRows);
            })
                   .MainTableSummarySettings(summarySettings =>
            {
                summarySettings.PreviousPageSummarySettings("منقول از صفحه قبل");
                summarySettings.PageSummarySettings("جمع صفحه");
                summarySettings.OverallSummarySettings("جمع");
            })
                   .MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName("rowNo");
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("رديف");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <User>(x => x.Id);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(2);
                    column.HeaderCell("شماره");
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                            ? string.Empty : long.Parse(obj.ToString()).NumberToText(Language.Persian));
                    });
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <User>(x => x.Name);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(2);
                    column.HeaderCell("نام");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <User>(x => x.LastName);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(3);
                    column.Width(2.5f);
                    column.HeaderCell("نام خانوادگي");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <User>(x => x.Balance);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Left);
                    column.IsVisible(true);
                    column.Order(4);
                    column.Width(2);
                    column.HeaderCell("موجودي");
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                            ? string.Empty : string.Format("{0:n0}", obj));
                    });
                    column.AggregateFunction(aggregateFunction =>
                    {
                        aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                        aggregateFunction.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                            ? string.Empty : string.Format("{0:n0}", obj));
                    });
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName <User>(x => x.RegisterDate);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(5);
                    column.Width(3);
                    column.HeaderCell("ثبت نام");
                    column.ColumnItemsTemplate(template =>
                    {
                        template.TextBlock();
                        template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                            ? string.Empty : PersianDate.ToPersianDateTime((DateTime)obj));
                    });
                });
            })
                   .MainTableEvents(events =>
            {
                events.DataSourceIsEmpty(message: "There is no data available to display.");
                events.MainTableAdded(args =>
                {
                    var data = args.LastOverallAggregateValueOf <User>(y => y.Balance);
                    var msg = "جمع نهايي گزارش : " + data + "، معادل: " + long.Parse(data, NumberStyles.AllowThousands, CultureInfo.InvariantCulture).NumberToText(Language.Persian);
                    var infoTable = new PdfGrid(numColumns: 1)
                    {
                        WidthPercentage = 100
                    };
                    infoTable.AddSimpleRow(
                        (cellData, properties) =>
                    {
                        cellData.Value = msg;
                        properties.PdfFont = events.PdfFont;
                        properties.RunDirection = PdfRunDirection.RightToLeft;
                    });
                    args.PdfDoc.Add(infoTable.AddBorderToTable());
                });
            })
                   .Export(export =>
            {
                export.ToExcel();
            })
                   .Generate(data => data.AsPdfFile(string.Format("{0}\\Pdf\\PersianRtlSample-{1}.pdf", AppPath.ApplicationPath, Guid.NewGuid().ToString("N")))));
        }
    public PdfGrid RenderingReportHeader(Document pdfDoc, PdfWriter pdfWriter, IList <SummaryCellData> summaryData)
    {
        var table = new PdfGrid(numColumns: 1)
        {
            WidthPercentage = 100
        };


        table.AddSimpleRow(
            (cellData, cellProperties) =>
        {
            //electroweb/Images/wwwroot/01.png does not exists & defaultImageFilePath was not found.'

            /*  string url ="http://54.86.105.4/";
             * cellData.CellTemplate = new ImageFilePathField();
             * cellData.Value = TestUtils.GetHtmlPage(url+"Fotos/fb9c27b1-98f7-4388-b13c-664d22cac022.jpg");
             * cellProperties.HorizontalAlignment = HorizontalAlignment.Center;*/


            cellData.CellTemplate = new ImageFilePathField();

            string url = "http://54.86.105.4/Fotos/d978a65c-5071-4d21-9aac-8a3b81032ba7.jpg";
            iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(new Uri(url));


            byte[] imageArray = System.IO.File.ReadAllBytes(@url);
            string base64ImageRepresentation = Convert.ToBase64String(imageArray);

            /*using (System.Drawing.Image image = jpg)
             * {
             *  using (MemoryStream m = new MemoryStream())
             *  {
             *      image.Save(m, image.RawFormat);
             *      byte[] imageBytes = m.ToArray();
             *      cellProperties.HorizontalAlignment = HorizontalAlignment.Justified;
             *     cellData.Value = TestUtils.GetHtmlPage("http://54.86.105.4/Fotos/d978a65c-5071-4d21-9aac-8a3b81032ba7.jpg");
             *
             *      // Convert byte[] to Base64 String
             *    //  string base64String = Convert.ToBase64String(imageBytes);
             *
             *  }
             * }*/



            /// iTextSharp.text.Image jpg =  iTextSharp.text.Image.GetInstance(new Uri(url));

            //cellData.Value = jpg.Url.LocalPath;

            //doc.Add(new Paragraph("JPG"));

            ///string url = "http://54.86.105.4/Fotos/d978a65c-5071-4d21-9aac-8a3b81032ba7.jpg";

            /// iTextSharp.text.Image jpg =  iTextSharp.text.Image.GetInstance(new Uri(url));



            ///cellData.Value=jpg.Width;
        });
        table.AddSimpleRow(
            (cellData, cellProperties) =>
        {
            cellData.Value                     = "Reporte inventario";
            cellProperties.PdfFont             = PdfRptFont;
            cellProperties.PdfFontStyle        = DocumentFontStyle.Bold;
            cellProperties.HorizontalAlignment = HorizontalAlignment.Center;
        });

        /* table.AddSimpleRow(
         * (cellData, cellProperties) =>
         * {
         *  //electroweb/Images/wwwroot/01.png does not exists & defaultImageFilePath was not found.'
         *
         *  cellData.CellTemplate = new ImageFilePathField();
         *
         *  cellData.CellTemplate = new ImageFilePathField();
         *  cellData.Value = TestUtils.GetImagePath("reporte_superior.png");
         *  cellProperties.HorizontalAlignment = HorizontalAlignment.Justified;
         * });*/
        return(table.AddBorderToTable());
    }