コード例 #1
0
        /// <summary>
        /// Zebra style.
        /// </summary>
        /// <param name="table">The table.</param>
        public virtual void ZebraStyle(MigraDoc.DocumentObjectModel.Tables.Table table)
        {
            // THead
            for (int r = 0; r < table.Rows[0].Cells.Count; r++)
            {
                table.Rows[0].Cells[r].Format.Font.Color = this.HeaderForeColor;
                table.Rows[0].Cells[r].Shading.Color     = this.HeaderBackColor;
            }

            // TBody, TFoot
            for (int r = 1; r < table.Rows.Count; r++)
            {
                for (int c = 0; c < table.Rows[r].Cells.Count; c++)
                {
                    if (table.Rows[r].Cells[c].IsTBody())
                    {
                        table.Rows[r].Cells[c].Borders.Bottom.Color = this.RowOddBackColor;
                        table.Rows[r].Cells[c].Borders.Bottom.Width = this.RowBorderWidth;

                        if ((r + 1) % 2 == 0)
                        {
                            if (this.RowOddForeColor.HasValue)
                            {
                                table.Rows[r].Cells[c].Format.Font.Color = this.RowOddForeColor.Value;
                            }
                            table.Rows[r].Cells[c].Shading.Color = this.RowOddBackColor;
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Only rows bordered style.
        /// </summary>
        /// <param name="table">The table.</param>
        public virtual void OnlyRowsBorderedStyle(MigraDoc.DocumentObjectModel.Tables.Table table)
        {
            // THead
            for (int r = 0; r < table.Rows[0].Cells.Count; r++)
            {
                table.Rows[0].Cells[r].Borders.Color        = this.BorderColor;
                table.Rows[0].Cells[r].Borders.Top.Width    = 0;
                table.Rows[0].Cells[r].Borders.Bottom.Width = this.HeaderBorderWidth;
                table.Rows[0].Cells[r].Borders.Left.Width   = 0;
                table.Rows[0].Cells[r].Borders.Right.Width  = 0;
            }

            // TBody, TFoot
            MigraDoc.DocumentObjectModel.Tables.Cell cell;
            for (int r = 1; r < table.Rows.Count; r++)
            {
                for (int c = 0; c < table.Rows[r].Cells.Count; c++)
                {
                    cell = table.Rows[r].Cells[c];

                    cell.Borders.Color        = this.BorderColor;
                    cell.Borders.Top.Width    = 0;
                    cell.Borders.Bottom.Width = this.RowBorderWidth;
                    cell.Borders.Left.Width   = 0;
                    cell.Borders.Right.Width  = 0;

                    // Respect colspan for last row otherwise there will be an | -> if only new PdfTableCell("...", 6);
                    if (c + 1 == table.Rows[r].Cells.Count && cell.MergeRight > 0)
                    {
                        table.Rows[r].Cells[c + cell.MergeRight].Borders.Left.Width  = 0;
                        table.Rows[r].Cells[c + cell.MergeRight].Borders.Right.Width = 0;
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Grid style.
        /// </summary>
        /// <param name="table">The table.</param>
        public virtual void GridStyle(MigraDoc.DocumentObjectModel.Tables.Table table)
        {
            // THead
            for (int r = 0; r < table.Rows[0].Cells.Count; r++)
            {
                table.Rows[0].Cells[r].Borders.Color        = this.BorderColor;
                table.Rows[0].Cells[r].Borders.Top.Width    = 0D;
                table.Rows[0].Cells[r].Borders.Bottom.Width = this.HeaderBorderWidth;
                table.Rows[0].Cells[r].Borders.Left.Width   = (r == 0) ? 0D : this.RowBorderWidth;
                table.Rows[0].Cells[r].Borders.Right.Width  = ((r + 1) == table.Rows[0].Cells.Count) ? 0D : this.RowBorderWidth;
            }

            // TBody, TFoot
            for (int r = 1; r < table.Rows.Count; r++)
            {
                for (int c = 0; c < table.Rows[r].Cells.Count; c++)
                {
                    table.Rows[r].Cells[c].Borders.Color        = this.BorderColor;
                    table.Rows[r].Cells[c].Borders.Top.Width    = this.RowBorderWidth;
                    table.Rows[r].Cells[c].Borders.Bottom.Width = ((r + 1) == table.Rows.Count) ? 0D : this.RowBorderWidth;
                    table.Rows[r].Cells[c].Borders.Left.Width   = (c == 0) ? 0D : this.RowBorderWidth;
                    table.Rows[r].Cells[c].Borders.Right.Width  = ((c + 1) == table.Rows[r].Cells.Count) ? 0D : this.RowBorderWidth;
                }
            }
        }
コード例 #4
0
 private static MigraDoc.DocumentObjectModel.Tables.Table convertirDGVaTabla(DataGridView DGV)
 {
     MigraDoc.DocumentObjectModel.Tables.Table tabla = new MigraDoc.DocumentObjectModel.Tables.Table();
     foreach (DataGridViewColumn columna in DGV.Columns)
     {
         if (columna.Name != "VolumenDmax") //para que no agregue la columna de volúmen de dosis máxima
         {
             tabla.AddColumn(columna.Width);
         }
     }
     var filaHeadertabla = tabla.AddRow();
     foreach (DataGridViewRow filaDGV in DGV.Rows)
     {
         var tableFila = tabla.AddRow();
         for (int i = 0; i < DGV.Columns.Count-1; i++) 
         {
             
                 string valor = "";
                 if (filaDGV.Cells[i].Value != null)
                 {
                     valor = filaDGV.Cells[i].Value.ToString();
                 }
                 tableFila.Cells[i].AddParagraph(valor);
                 tableFila.Cells[i].Shading.Color = colorDGVaTable(filaDGV.Cells[i].Style.BackColor);
         }
     }
     for (int i = 0; i < DGV.Columns.Count-1; i++)
     {
         tabla.Rows[0].Cells[i].AddParagraph(DGV.Columns[i].HeaderText);
     }
     Estilos.formatearTabla(tabla);
     return tabla;
 }
コード例 #5
0
 /// <summary>
 /// No borders style.
 /// </summary>
 /// <param name="table">The table.</param>
 public virtual void NoBordersStyle(MigraDoc.DocumentObjectModel.Tables.Table table)
 {
     // THead, TBody, TFoot
     for (int r = 0; r < table.Rows.Count; r++)
     {
         table.Rows[r].Borders.Visible = false;
     }
 }
コード例 #6
0
ファイル: Table.cs プロジェクト: JuanCruzReines/PDFBuilder
        /// <summary>
        /// Creates a MigraDoc table object from its components
        /// </summary>
        public void RenderComponents(MigraDoc.DocumentObjectModel.Tables.Table table)
        {
            this.columns.ForEach(columns => columns.RenderInto(table));

            this.rows.ForEach(row => row.RenderInto(table));

            table.Borders.Visible = this.showBorders;

            if (this.rowHeight.HasValue)
            {
                table.Rows.Height = Unit.FromMillimeter(this.rowHeight.Value);
            }
        }
コード例 #7
0
        /// <summary>
        /// Writes the specified table.
        /// </summary>
        /// <param name="table">The table.</param>
        void IReportWriter.WriteTable(Table table)
        {
            if (table.Rows == null)
            {
                return;
            }

            var pdfTable = new MigraDoc.DocumentObjectModel.Tables.Table
            {
                Borders = { Width = 0.25, Left = { Width = 0.5 }, Right = { Width = 0.5 } },
                Rows    = { LeftIndent = 0 }
            };

            //// pdfTable.Style = "Table";
            //// pdfTable.Borders.Color = TableBorder;

            int columns = table.Columns.Count;

            for (int j = 0; j < columns; j++)
            {
                var pdfColumn = pdfTable.AddColumn();

                // todo: the widths are not working
                //// pdfColumn.Width = Unit.FromMillimeter(table.Columns[j].ActualWidth);
                pdfColumn.Format.Alignment = ConvertToParagraphAlignment(table.Columns[j].Alignment);
            }

            foreach (var tr in table.Rows)
            {
                var pdfRow = pdfTable.AddRow();
                for (int j = 0; j < columns; j++)
                {
                    bool isHeader = tr.IsHeader || table.Columns[j].IsHeader;

                    var c       = tr.Cells[j];
                    var pdfCell = pdfRow.Cells[j];
                    pdfCell.AddParagraph(c.Content ?? string.Empty);
                    pdfCell.Style            = isHeader ? "TableHeader" : "TableText";
                    pdfCell.Format.Alignment = ConvertToParagraphAlignment(table.Columns[j].Alignment);
                }
            }

            // table.SetEdge(0, 0, t.Columns.Count, t.Items.Count(), Edge.Box, BorderStyle.Single, 1.5, Colors.Black);
            if (table.Caption != null)
            {
                var pa = this.CurrentSection.AddParagraph();
                pa.AddFormattedText(table.GetFullCaption(this.style), "TableCaption");
            }

            this.CurrentSection.Add(pdfTable);
        }
コード例 #8
0
        /// <summary>
        /// No spacing style.
        /// </summary>
        /// <param name="table">The table.</param>
        public virtual void NoSpacingStyle(MigraDoc.DocumentObjectModel.Tables.Table table)
        {
            table.TopPadding    = 0;
            table.BottomPadding = 0;

            // THead, TBody, TFoot
            for (int r = 0; r < table.Rows.Count; r++)
            {
                for (int c = 0; c < table.Rows[r].Cells.Count; c++)
                {
                    table.Rows[r].Cells[c].Format.SpaceBefore = 0;
                    table.Rows[r].Cells[c].Format.SpaceAfter  = -2;
                }
            }
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: europe1/scientific-app
        private void FillTable(MigraDoc.DocumentObjectModel.Tables.Table table, int start, int count)
        {
            foreach (double[] rowData in Values.GetRange(start, count))
            {
                MigraDoc.DocumentObjectModel.Tables.Row row = table.AddRow();
                row.Format.Alignment = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;

                int j = 0;
                foreach (double value in rowData)
                {
                    if (j > 5)
                    {
                        row.Cells[j++].AddParagraph(String.Format("{0:0.0000000}", value));
                    }
                    else
                    {
                        row.Cells[j++].AddParagraph(value.ToString());
                    }
                }
            }
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: europe1/scientific-app
        private void PrepareToExport()
        {
            bool firstPage = true;
            bool nextPage  = true;
            int  count     = Values.Count;
            int  start     = 0;

            while (nextPage)
            {
                MigraDoc.DocumentObjectModel.Section section;

                int pageElem = 52;
                if (firstPage)
                {
                    pageElem  = 47;
                    firstPage = false;
                    section   = FirstSection;
                }
                else
                {
                    section = Document.AddSection();
                }

                if (pageElem > count)
                {
                    pageElem = count;
                    nextPage = false;
                }
                else
                {
                    count -= pageElem;
                }

                MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
                CreateTable(table);
                FillTable(table, start, pageElem);

                start += pageElem;
            }
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: europe1/scientific-app
        private void CreateTable(MigraDoc.DocumentObjectModel.Tables.Table table)
        {
            table.Columns.Clear();
            table.Rows.Clear();

            table.Borders.Color = MigraDoc.DocumentObjectModel.Colors.Black;
            table.Borders.Width = 0.5;

            MigraDoc.DocumentObjectModel.Tables.Column column;
            column = table.AddColumn("1cm");

            for (int i = 0; i < 5; i++)
            {
                column = table.AddColumn("1.3cm");
                column.Format.Alignment = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;
            }

            for (int i = 0; i < 4; i++)
            {
                column = table.AddColumn("2.2cm");
                column.Format.Alignment = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;
            }

            MigraDoc.DocumentObjectModel.Tables.Row row = table.AddRow();
            row.Format.Font.Bold   = true;
            row.Format.SpaceBefore = "0.1cm";
            row.Format.SpaceAfter  = "0.1cm";
            row.Format.Alignment   = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;

            row.Cells[0].AddParagraph("№");
            row.Cells[1].AddParagraph("τ, мин.");
            row.Cells[2].AddParagraph("t1, °C");
            row.Cells[3].AddParagraph("φ1, %");
            row.Cells[4].AddParagraph("t2, °C");
            row.Cells[5].AddParagraph("φ2, %");
            row.Cells[6].AddParagraph("W");
            row.Cells[7].AddParagraph("u");
            row.Cells[8].AddParagraph("N");
            row.Cells[9].AddParagraph("βv");
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: europe1/scientific-app
        public void CreateHead(string T0, double u, string H, string ms, string mv, string V)
        {
            MigraDoc.DocumentObjectModel.Tables.Table head = FirstSection.AddTable();

            head.Columns.Clear();
            head.Rows.Clear();

            head.Borders.Color = MigraDoc.DocumentObjectModel.Colors.Black;
            head.Borders.Width = 0.5;

            head.AddColumn("2.5cm");
            head.AddColumn("2.5cm");
            head.AddColumn("11.3cm");

            MigraDoc.DocumentObjectModel.Tables.Row row = head.AddRow();
            row.Cells[0].AddParagraph(string.Format("{0}°C | u = {1:0.00} | H = {2}", T0, u, H));
            row.Cells[0].MergeRight = 2;
            row.Format.Alignment    = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;
            row.Format.Font.Bold    = true;

            row = head.AddRow();
            row.Cells[0].AddParagraph("m1, гр");
            row.Cells[1].AddParagraph(ms);
            row.Cells[2].AddParagraph("Масса сухого материала");

            row = head.AddRow();
            row.Cells[0].AddParagraph("m2, гр");
            row.Cells[1].AddParagraph(mv);
            row.Cells[2].AddParagraph("Масса влажного материала");

            row = head.AddRow();
            row.Cells[0].AddParagraph("H, мм");
            row.Cells[1].AddParagraph(H);
            row.Cells[2].AddParagraph("Высота слоя");

            row = head.AddRow();
            row.Cells[0].AddParagraph("Расход, м³/ч");
            row.Cells[1].AddParagraph(V);
            row.Cells[2].AddParagraph("Объёмный расход воздуха");
        }
コード例 #13
0
        private static void cargarEncabezado(Section seccion, string apellidoPaciente, string nombrePaciente, string equipo, string IDPaciente, string nombrePlantilla, string realizadoPor, string plan, string presc)
        {
            seccion.AddParagraph("Analisis de restricciones en plan de tratamiento", "Titulo");
            string paciente = "";
            string fecha    = "";

            if (apellidoPaciente != "" || nombrePaciente != "")
            {
                paciente = apellidoPaciente + ", " + nombrePaciente;
                fecha    = DateTime.Today.ToShortDateString();
            }

            MigraDoc.DocumentObjectModel.Tables.Table tabla = new MigraDoc.DocumentObjectModel.Tables.Table();
            tabla.AddColumn(270);
            tabla.AddColumn(230);
            tabla.Borders.Width = 0.5;
            for (int i = 0; i < 8; i++)
            {
                tabla.AddRow();
            }
            tabla.Rows[0].Cells[0].Add(Estilos.etiquetaYValor("Paciente", paciente));
            tabla.Rows[1].Cells[0].Add(Estilos.etiquetaYValor("HC", IDPaciente));
            tabla.Rows[2].Cells[0].Add(Estilos.etiquetaYValor("Equipo", equipo));
            tabla.Rows[3].Cells[0].Add(Estilos.etiquetaYValor("Plantilla", nombrePlantilla));
            tabla.Rows[4].Cells[0].Add(Estilos.etiquetaYValor("Realizado por", realizadoPor));
            tabla.Rows[5].Cells[0].Add(Estilos.etiquetaYValor("Fecha", fecha));
            tabla.Rows[6].Cells[0].Add(Estilos.etiquetaYValor("Nombre del Plan", plan));
            tabla.Rows[7].Cells[0].Add(Estilos.etiquetaYValor("Dosis de prescripción (Gy)", presc));

            tabla.Rows[0].Cells[1].MergeDown = 7;
            Paragraph parrafoImage = new Paragraph();

            parrafoImage.Format.Alignment = ParagraphAlignment.Right;
            parrafoImage.AddImage(Properties.Settings.Default.Path + @"\PlanExplorer\LogoMeva.png");
            tabla.Rows[0].Cells[1].Add(parrafoImage);
            seccion.Add(tabla);
            seccion.AddParagraph();
            seccion.AddParagraph();
        }
コード例 #14
0
        /// <summary>
        /// Striped rows style.
        /// </summary>
        /// <param name="table">The table.</param>
        public virtual void StripedRowsStyle(MigraDoc.DocumentObjectModel.Tables.Table table)
        {
            OnlyRowsBorderedStyle(table);

            // TBody, TFoot
            for (int r = 1; r < table.Rows.Count; r++)
            {
                for (int c = 0; c < table.Rows[r].Cells.Count; c++)
                {
                    if ((r + 1) % 2 == 0)
                    {
                        if (table.Rows[r].Cells[c].IsTBody())
                        {
                            if (this.RowOddForeColor.HasValue)
                            {
                                table.Rows[r].Cells[c].Format.Font.Color = this.RowOddForeColor.Value;
                            }
                            table.Rows[r].Cells[c].Shading.Color = this.RowOddBackColor;
                        }
                    }
                }
            }
        }
コード例 #15
0
        private static void MakeTable([JetBrains.Annotations.NotNull] string headline, [JetBrains.Annotations.NotNull] Section sec, [JetBrains.Annotations.NotNull] out ParagraphFormat format, [JetBrains.Annotations.NotNull] out Table table,
                                      TableColumnType tableColumnType)
        {
            var para = sec.AddParagraph();

            para.Format.Alignment   = ParagraphAlignment.Justify;
            para.Format.Font.Name   = "Times New Roman";
            para.Format.Font.Size   = 16;
            para.Format.Font.Bold   = true;
            para.Format.SpaceAfter  = "0.5cm";
            para.Format.SpaceBefore = "1cm";
            para.Format.Font.Color  = Colors.DarkGray;
            para.AddText(headline);

            format = new ParagraphFormat {
                Font = { Size = 12 }, SpaceBefore = "0.2cm", SpaceAfter = "0.2cm"
            };
            table = new Table {
                Borders = { Width = 0.75 }
            };
            int[]    measurements;
            bool[]   alignments;
            string[] headers;
            switch (tableColumnType)
            {
            case TableColumnType.Values:
                alignments   = new[] { false, true, false };
                measurements = new[] { 5, 5, 5 };
                headers      = new[] { "Load Type", "Value", "Unit" };
                break;

            case TableColumnType.SettlementValues:
                measurements = new[] { 4, 5, 3, 3 };
                alignments   = new[] { false, false, true, false };
                headers      = new[] { "Household", "Load Type", "Value", "Unit" };
                break;

            case TableColumnType.MinMax:
                measurements = new[] { 5, 3, 3, 3 };
                alignments   = new[] { false, true, true, false };
                headers      = new[] { "Household", "Minimum", "Maximum", "Unit" };
                break;

            default: throw new LPGException("Forgotten TableColumnType");
            }

            for (var i = 0; i < measurements.Length; i++)
            {
                var column0 = table.AddColumn(Unit.FromCentimeter(measurements[i]));
                if (alignments[i])
                {
                    column0.Format.Alignment = ParagraphAlignment.Right;
                }
                else
                {
                    column0.Format.Alignment = ParagraphAlignment.Left;
                }
            }

            var row = table.AddRow();

            row.Shading.Color = Colors.AliceBlue;
            for (var i = 0; i < headers.Length; i++)
            {
                var cell = row.Cells[i];
                cell.AddParagraph(headers[i]);
                cell.Format = format.Clone();
            }
        }
コード例 #16
0
        //Only creates tables with row-col headers.
        private static MigraDoc.DocumentObjectModel.Tables.Table CreatePDFTable(string[,] RowHeaders, string[,] ColumnHeaders, string[,] data, string strPDFfontsize)
        {
            int fsiz = 9;                           //default

            int.TryParse(strPDFfontsize, out fsiz); //user configured font size

            MigraDoc.DocumentObjectModel.Tables.Table table = new MigraDoc.DocumentObjectModel.Tables.Table();
            if (APAStyle)
            {
                table.Borders.Left.Clear();
                table.Borders.Right.Clear();
            }

            int rowsInColheader = ColumnHeaders.GetLength(0);
            int colsInColheader = ColumnHeaders.GetLength(1);

            int rowsInRowheader = RowHeaders.GetLength(0);
            int colsInRowheader = RowHeaders.GetLength(1);

            int    totalColsInWholeTable = colsInColheader + colsInRowheader; //col count of colheader and rowheaders
            int    totalRowsInWholeTable = rowsInColheader + rowsInRowheader; // row count of colheader and rowheader
            string celltext;

            MigraDoc.DocumentObjectModel.Tables.Column col;
            MigraDoc.DocumentObjectModel.Tables.Row    row;
            MigraDoc.DocumentObjectModel.Tables.Cell   cell;

            //def column
            for (int i = 0; i < totalColsInWholeTable; i++)
            {
                col = table.AddColumn();
                if (APAStyle)
                {
                    col.Format.Alignment = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;
                }
                else
                {
                    col.Format.Alignment = MigraDoc.DocumentObjectModel.ParagraphAlignment.Left;
                }
            }

            //creating left top corner and col headers of a row
            for (int i = 0; i < rowsInColheader; i++)
            {
                row = table.AddRow();
                row.Format.Font.Size = fsiz;
                row.HeadingFormat    = true;
                if (APAStyle)
                {
                    if (i == 0) //if first row then add a horiz line above
                    {
                        row.Borders.Top.Width = .5;
                    }
                    if (i == (rowsInColheader - 1))  //if last row header then add a horiz line below
                    {
                        row.Borders.Bottom.Width = .5;
                    }
                }
                //Empty Left top corner
                for (int a = 0; a < colsInRowheader; a++)
                {
                    cell = row.Cells[a];
                    cell.AddParagraph(" ");
                    cell.Shading.Color        = APAStyle? (new MigraDoc.DocumentObjectModel.Color(255, 255, 255)) : TableBlue;
                    cell.Borders.Bottom.Color = APAStyle ? (new MigraDoc.DocumentObjectModel.Color(255, 255, 255)) : TableBlue;;
                }


                //Col headers
                for (int b = 0; b < colsInColheader; b++)
                {
                    celltext = InsertSpace(ColumnHeaders[i, b], 10);//
                    cell     = row.Cells[b + colsInRowheader];

                    cell.AddParagraph(celltext);
                    cell.Format.Font.Bold = true;
                    cell.Shading.Color    = APAStyle ? (new MigraDoc.DocumentObjectModel.Color(255, 255, 255)) : TableBlue;
                }
            }


            //Creating rowheaders and Data cols of a row
            for (int i = 0; i < rowsInRowheader; i++)
            {
                row = table.AddRow();
                row.Format.Font.Size = fsiz;
                //rowheader cols of a row
                for (int a = 0; a < colsInRowheader; a++)
                {
                    celltext = InsertSpace(RowHeaders[i, a], 10);//
                    cell     = row.Cells[a];
                    cell.AddParagraph(celltext);
                    cell.Format.Font.Bold = true;
                    cell.Shading.Color    = APAStyle ? (new MigraDoc.DocumentObjectModel.Color(255, 255, 255)) : TableBlue;
                }

                MigraDoc.DocumentObjectModel.Paragraph paragraph;
                //data in current row
                for (int b = 0; b < colsInColheader; b++)
                {
                    celltext = InsertSpace(data[i, b], 10);//
                    cell     = row.Cells[b + colsInRowheader];

                    if (data[i, b].Contains("BSkySupScript")) //its superscript text
                    {
                        paragraph = cell.AddParagraph();
                        paragraph.AddFormattedText("- ");
                        celltext = data[i, b].Replace("BSkySupScript", "");
                        paragraph.AddFormattedText(celltext, MigraDoc.DocumentObjectModel.TextFormat.Italic).Font.Superscript = true;
                        cell.Format.Font.Size = fsiz;
                    }
                    else
                    {
                        cell.AddParagraph(celltext);
                    }
                }

                if (APAStyle)
                {
                    if (i == (rowsInRowheader - 1)) //if last row header then add a horiz line below
                    {
                        row.Borders.Bottom.Width = .5;
                    }
                }
            }
            return(table);
        }
コード例 #17
0
ファイル: Table.cs プロジェクト: JuanCruzReines/PDFBuilder
        /// <summary>
        /// Render table into header or footer
        /// </summary>
        public void RenderInto(HeaderFooter headerFooter)
        {
            MigraDoc.DocumentObjectModel.Tables.Table table = headerFooter.AddTable();

            this.RenderComponents(table);
        }
コード例 #18
0
ファイル: Table.cs プロジェクト: JuanCruzReines/PDFBuilder
        /// <summary>
        /// Render table into section
        /// </summary>
        public void RenderInto(MigraDoc.DocumentObjectModel.Section section)
        {
            MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();

            this.RenderComponents(table);
        }
コード例 #19
0
        protected void CreatePage(IList <Student> students)
        {
            Section section = this.document.AddSection();

            this.table                     = section.AddTable();
            this.table.Style               = "Table";
            this.table.Borders.Color       = Colors.Black;
            this.table.Borders.Width       = 0.25;
            this.table.Borders.Left.Width  = 0.5;
            this.table.Borders.Right.Width = 0.5;
            this.table.Rows.LeftIndent     = 0;

            MigraDoc.DocumentObjectModel.Tables.Column column = this.table.AddColumn("4cm"); //first name, father initial, last name
            column.Format.Alignment = ParagraphAlignment.Center;

            column = this.table.AddColumn("3cm");//specialization
            column.Format.Alignment = ParagraphAlignment.Left;

            column = this.table.AddColumn("2cm"); //final grade
            column.Format.Alignment = ParagraphAlignment.Left;

            column = this.table.AddColumn("2cm"); //addmision grade
            column.Format.Alignment = ParagraphAlignment.Left;

            column = this.table.AddColumn("2cm"); //baccalaureat average grade
            column.Format.Alignment = ParagraphAlignment.Left;

            column = this.table.AddColumn("2cm"); //baccalaureat maximum grade
            column.Format.Alignment = ParagraphAlignment.Left;

            column = this.table.AddColumn("3cm"); //status
            column.Format.Alignment = ParagraphAlignment.Left;

            MigraDoc.DocumentObjectModel.Tables.Row row = this.table.AddRow();
            row.HeadingFormat          = true;
            row.Format.Alignment       = ParagraphAlignment.Center;
            row.Format.Font.Bold       = true;
            row.Borders.Bottom.Visible = true;
            row.Borders.Bottom.Width   = 1;

            row.Cells[0].AddParagraph("Student");
            row.Cells[1].AddParagraph("Specialization");
            row.Cells[2].AddParagraph("Final Grade");
            row.Cells[3].AddParagraph("Admission");
            row.Cells[4].AddParagraph("Average");
            row.Cells[5].AddParagraph("Maximum");
            row.Cells[6].AddParagraph("Status");

            for (int j = 0; j < 7; j++)
            {
                row.Cells[j].Format.Font.Bold     = true;
                row.Cells[j].Format.Alignment     = ParagraphAlignment.Justify;
                row.Cells[j].Borders.Bottom.Width = 0.25;
            }

            for (int i = 0; i < students.Count; i++)
            {
                row = this.table.AddRow();
                Student current = students.ElementAt(i);
                row.Cells[0].AddParagraph(current.FirstName + " " + current.FatherInitial + " " + current.LastName);
                row.Cells[1].AddParagraph(current.Specialization);
                row.Cells[2].AddParagraph(current.FinalGrade.ToString());
                row.Cells[3].AddParagraph(current.AdmissionExamGrade.ToString());
                row.Cells[4].AddParagraph(current.BaccalaureatAverageGrade.ToString());
                row.Cells[5].AddParagraph(current.BaccalaureatMaximumGrade.ToString());
                row.Cells[6].AddParagraph(current.Status);


                row.Borders.Bottom.Visible = true;
                row.Borders.Bottom.Width   = 0.25;
            }
        }
コード例 #20
0
        /// <summary>
        /// Writes the specified table.
        /// </summary>
        /// <param name="table">The table.</param>
        void IReportWriter.WriteTable(Table table)
        {
            if (table.Rows == null)
            {
                return;
            }

            var pdfTable = new MigraDoc.DocumentObjectModel.Tables.Table
                {
                    Borders = { Width = 0.25, Left = { Width = 0.5 }, Right = { Width = 0.5 } },
                    Rows = { LeftIndent = 0 }
                };

            //// pdfTable.Style = "Table";
            //// pdfTable.Borders.Color = TableBorder;

            int columns = table.Columns.Count;

            for (int j = 0; j < columns; j++)
            {
                var pdfColumn = pdfTable.AddColumn();

                // todo: the widths are not working
                //// pdfColumn.Width = Unit.FromMillimeter(table.Columns[j].ActualWidth);
                pdfColumn.Format.Alignment = ConvertToParagraphAlignment(table.Columns[j].Alignment);
            }

            foreach (var tr in table.Rows)
            {
                var pdfRow = pdfTable.AddRow();
                for (int j = 0; j < columns; j++)
                {
                    bool isHeader = tr.IsHeader || table.Columns[j].IsHeader;

                    var c = tr.Cells[j];
                    var pdfCell = pdfRow.Cells[j];
                    pdfCell.AddParagraph(c.Content ?? string.Empty);
                    pdfCell.Style = isHeader ? "TableHeader" : "TableText";
                    pdfCell.Format.Alignment = ConvertToParagraphAlignment(table.Columns[j].Alignment);
                }
            }

            // table.SetEdge(0, 0, t.Columns.Count, t.Items.Count(), Edge.Box, BorderStyle.Single, 1.5, Colors.Black);
            if (table.Caption != null)
            {
                var pa = this.CurrentSection.AddParagraph();
                pa.AddFormattedText(table.GetFullCaption(this.style), "TableCaption");
            }

            this.CurrentSection.Add(pdfTable);
        }
コード例 #21
0
        public static MigraDoc.DocumentObjectModel.Tables.Table ExportToPDF(string[,] NotesData, string fontsize)
        {
            //Find dimentions of data area
            int rowcount = NotesData.GetLength(0);
            int colcount = NotesData.GetLength(1);

            //def table
            MigraDoc.DocumentObjectModel.Tables.Table table = new MigraDoc.DocumentObjectModel.Tables.Table();
            table.Borders.Width = 0.5;

            string celltext;

            MigraDoc.DocumentObjectModel.Tables.Column col;
            MigraDoc.DocumentObjectModel.Tables.Row    row;
            MigraDoc.DocumentObjectModel.Tables.Cell   cell;

            //def column
            for (int i = 0; i < colcount; i++)
            {
                col = table.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromCentimeter(5 * (1 + i)));
                col.Format.Alignment = MigraDoc.DocumentObjectModel.ParagraphAlignment.Left;
            }

            //creating left top corner and col headers of a row
            for (int i = 0; i < 1; i++)
            {
                row = table.AddRow();
                row.HeadingFormat = true;
                //Empty Left top corner
                for (int a = 0; a < 1; a++)
                {
                    cell = row.Cells[a];
                    cell.AddParagraph(" ");
                    cell.Shading.Color = TableBlue;
                }


                //Col headers
                for (int b = 0; b < colcount; b++)
                {
                    celltext = "";
                    cell     = row.Cells[b];
                    cell.AddParagraph(celltext);
                    cell.Format.Font.Bold  = true;
                    cell.Shading.Color     = TableBlue;
                    cell.Format.Alignment  = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;
                    cell.VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;
                }
            }


            //Creating rowheaders and Data cols of a row
            for (int i = 0; i < rowcount; i++)
            {
                row = table.AddRow();

                MigraDoc.DocumentObjectModel.Paragraph paragraph;
                //data in current row
                for (int b = 0; b < colcount; b++)
                {
                    celltext = NotesData[i, b];
                    cell     = row.Cells[b];

                    cell.AddParagraph(NotesData[i, b]);
                    cell.Format.Alignment  = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;
                    cell.VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;
                }
            }

            return(table);
        }
コード例 #22
0
        public static List <MigraDoc.DocumentObjectModel.Tables.Table> ExportMultiHeaderFlexgridToPDF(double PDFPageHeight, C1FlexGrid augrid, string strMaxTblCol, string strMaxTblRow, string strPDFfontsize)
        {
            //Will contain all the portions/parts of the tables those were generated by splitting 1 FlexGrid table.
            List <MigraDoc.DocumentObjectModel.Tables.Table> PartialPDFTables = new List <MigraDoc.DocumentObjectModel.Tables.Table>();

            //Find dimentions of col header area
            int colheaderRowCount = augrid.ColumnHeaders.Rows.Count;
            int colheaderColCount = augrid.ColumnHeaders.Columns.Count;

            //Find dimentions of row header area
            int rowheaderRowCount = augrid.RowHeaders.Rows.Count;
            int rowheaderColCount = augrid.RowHeaders.Columns.Count;

            //Find dimentions of data area
            int colcount = augrid.Columns.Count;
            int rowcount = augrid.Rows.Count;

            //top left corner dimentions
            int topleftrowCount = colheaderColCount;
            int topleftcolCount = rowheaderColCount;

            //Collect Flexgrid table Col/Row Headers and Data too
            string[,] FGColHdrs = new string[colheaderRowCount, colheaderColCount];
            string[,] FGRowHdrs = new string[rowheaderRowCount, rowheaderColCount];
            string[,] FGData    = new string[rowcount, colcount];


            //Collect the Column headers
            for (int i = 0; i < colheaderRowCount; i++)
            {
                //Col Headers of current row
                for (int j = 0; j < colheaderColCount; j++)
                {
                    if (augrid.ColumnHeaders[i, j] != null)
                    {
                        FGColHdrs[i, j] = augrid.ColumnHeaders[i, j].ToString();
                    }
                    else
                    {
                        FGColHdrs[i, j] = "";
                    }
                }
            }

            //Collect the Row headers
            string rowheaderstring = string.Empty;

            for (int i = 0; i < rowheaderRowCount; i++)// for all rows
            {
                //write row headers
                for (int j = 0; j < rowheaderColCount; j++)// Row Headers of current row
                {
                    if (augrid.RowHeaders[i, j] != null)
                    {
                        FGRowHdrs[i, j] = augrid.RowHeaders[i, j].ToString();
                    }
                    else
                    {
                        FGRowHdrs[i, j] = "";
                    }
                }
            }

            //Collect the Data
            for (int i = 0; i < rowcount; i++)// for all rows
            {
                //Write the data
                for (int c = 0; c < colcount; c++)  //data cells of current row
                {
                    try
                    {
                        if (augrid[i, c] != null)
                        {
                            FGData[i, c] = augrid[i, c].ToString();
                        }
                        else
                        {
                            if (augrid.Columns[c].Tag != null)
                            {
                                FGData[i, c] = "BSkySupScript" + (augrid.Columns[c].Tag as string[])[i]; //superscript text thats visible in FlexGrid table cell
                            }
                            else
                            {
                                FGData[i, c] = "";
                            }
                        }
                    }
                    catch { }
                }
            }

            bool tablewithRowheaders = false;

            if (rowheaderColCount < 8)
            {
                tablewithRowheaders = true;//each table will have row header and so will be meaningful.
            }



            //Creating a PDF doc to which we will add PDFTables
            MigraDoc.DocumentObjectModel.Tables.Table pdfTable;

            ////Start///// Generating Multi-paged PDF with Multi-row/col headers in each page /////////

            int MaxColperTable = MaxColPerSplitTable; // 8 was tested default
            int MaxRowperTable = MaxRowPerSplitTable; // 18 was tested default

            int MaxDataColPerPage = MaxColperTable - rowheaderColCount;
            int MaxDataRowPerPage = MaxRowperTable - colheaderRowCount;

            int    startcolidx = 0;
            int    endcolidx = -1;                                          // startcolidx + (MaxColPerPage - 1);//zero based index, so -1
            int    startrowidx = 0;
            int    endrowidx = -1;                                          // startrowidx + (MaxRowPerPage - 1);//zero based index, so -1
            int    TotalRowsInColHeaders = colheaderRowCount;               //same for each page ////zero based index, so -1
            int    TotalColsInRowHeaders = rowheaderColCount;               //same for each page ////zero based index, so -1
            int    remainingRows, remainingCols, colidx, rowidx;
            double currentTableHeight, remainingPageHeight = PDFPageHeight; // Doc.PageSize.Height;
            int    remainder, quotient, NoOfPagesRequired;

            string[,] partRowHeaders = null;
            string[,] partColHeaders = null;
            string[,] partData       = null;



            //For large FlexGrid : Creating page
            if (tablewithRowheaders)
            {
                for (int row = startrowidx; row < rowheaderRowCount; row = endrowidx + 1)
                {
                    remainingRows  = rowheaderRowCount - (endrowidx + 1);                                                 //calculating count so zero based index has to be converted to count
                    endrowidx      = row + ((MaxDataRowPerPage < remainingRows) ? MaxDataRowPerPage : remainingRows) - 1; //zero based index, so -1
                    colidx         = TotalColsInRowHeaders - 1;                                                           //changing count to zero based index
                    partRowHeaders = GetArraySubset(FGRowHdrs, row, 0, endrowidx, colidx);
                    endcolidx      = -1;
                    for (int col = startcolidx; col < colheaderColCount; col = endcolidx + 1)
                    {
                        remainingCols  = colheaderColCount - (endcolidx + 1);
                        endcolidx      = col + ((MaxDataColPerPage < remainingCols) ? MaxDataColPerPage : remainingCols) - 1;//zero based index, so -1
                        rowidx         = TotalRowsInColHeaders - 1;
                        partColHeaders = GetArraySubset(FGColHdrs, 0, col, rowidx, endcolidx);

                        partData = GetArraySubset(FGData, row, col, endrowidx, endcolidx);

                        pdfTable = CreatePDFTable(partRowHeaders, partColHeaders, partData, strPDFfontsize);

                        // Page and Table Height calculations
                        currentTableHeight = 50;// pdfTable.TotalHeight; // current table height
                        //For the first row there is no need to add new page. Its a fresh/blank document already.
                        if (row > 0 && remainingPageHeight < currentTableHeight)
                        {
                            PartialPDFTables.Add(null);// Here 'null' will refer to new page  //Doc.NewPage();
                        }
                        PartialPDFTables.Add(pdfTable);

                        //Find remaining space left after adding the current table. This will be used for the next table.
                        remainder = (int)((PDFPageHeight) % (currentTableHeight));
                        quotient  = (int)((PDFPageHeight) / (currentTableHeight));
                        if (remainder > 0)
                        {
                            quotient = quotient + 1;
                        }

                        NoOfPagesRequired = quotient;// quotient is total pages required to fit a very large(or small table)

                        // remaining height after adding current table.
                        remainingPageHeight = (PDFPageHeight * NoOfPagesRequired) % currentTableHeight;//This remaining space will be used for next iteration.
                    }
                }
                ////End///// Generating Multi-paged PDF with Multi-row/col headers in each page /////////
            }
            else //table broken in parts without managing row headers
            {
                int RHrowcount = rowheaderRowCount;
                int RHcolcount = rowheaderColCount;

                int CHrowcount = colheaderRowCount;
                int CHcolcount = colheaderColCount;

                int DTrowcount = rowcount;
                int DTcolcount = colcount;

                int TLrowcount = CHrowcount;
                int TLcolcount = RHcolcount;

                int TotalRows = CHrowcount + DTrowcount;
                int TotalCols = RHcolcount + DTcolcount;

                int SmallTableRowCount = MaxRowperTable;
                int SmallTableColCount = MaxColperTable;

                //these are helpful to put a partial tables unique id(row,col based)
                int tableRowIndex = 0, tableColIndex = 0;

                MigraDoc.DocumentObjectModel.Tables.Column col;
                MigraDoc.DocumentObjectModel.Tables.Row    row;
                MigraDoc.DocumentObjectModel.Tables.Cell   cell;
                MigraDoc.DocumentObjectModel.Paragraph     paragraph;

                int fsiz = 9;                           //default
                int.TryParse(strPDFfontsize, out fsiz); //user configured font size
                string text, celltext;
                for (int R = 0; R < TotalRows; R = R + SmallTableRowCount, tableRowIndex++)
                {
                    for (int C = 0; C < TotalCols; C = C + SmallTableColCount, tableColIndex++)
                    {
                        pdfTable = new MigraDoc.DocumentObjectModel.Tables.Table();
                        pdfTable.Borders.Width = 0.5;
                        pdfTable.Tag           = "Partial Table: (" + tableRowIndex + "," + tableColIndex + ")";


                        //resetting for next loop
                        SmallTableRowCount = MaxRowperTable;
                        SmallTableColCount = MaxColperTable;

                        //No of cols in a row
                        int colsInOneRow = SmallTableColCount;
                        if (TotalCols - C < SmallTableColCount)
                        {
                            SmallTableColCount = TotalCols - C;
                        }

                        //No of rows in a col
                        int rowsInOneCol = SmallTableRowCount;
                        if (TotalRows - R < SmallTableRowCount)
                        {
                            SmallTableRowCount = TotalRows - R;
                        }

                        //def column
                        for (int i = 0; i < SmallTableColCount; i++)
                        {
                            col = pdfTable.AddColumn();
                            col.Format.Alignment = MigraDoc.DocumentObjectModel.ParagraphAlignment.Left;
                        }

                        //small table row/col loop
                        for (int r = 0; r < SmallTableRowCount; r++)
                        {
                            row = pdfTable.AddRow();
                            row.Format.Font.Size = fsiz;
                            row.HeadingFormat    = true;
                            for (int c = 0; c < SmallTableColCount; c++)
                            {
                                //leftTop
                                if (R + r < TLrowcount && C + c < TLcolcount) //TopLeft region
                                {
                                    cell = row.Cells[c];
                                    cell.AddParagraph(" ");
                                    cell.Shading.Color = TableBlue;
                                }

                                //colheaders
                                if (C + c >= TLcolcount)
                                {
                                    if (R + r < CHrowcount && C + c - TLcolcount < CHcolcount)
                                    {
                                        text     = FGColHdrs[R + r, C + c - TLcolcount];
                                        celltext = InsertSpace(text, 10);
                                        cell     = row.Cells[c];
                                        cell.AddParagraph(celltext);
                                        cell.Format.Font.Bold = true;
                                        cell.Shading.Color    = TableBlue;
                                    }
                                }

                                //rowheaders
                                if (R + r >= TLrowcount)
                                {
                                    if (R + r - TLrowcount < RHrowcount && C + c < RHcolcount)
                                    {
                                        text     = FGRowHdrs[R + r - TLrowcount, C + c];
                                        celltext = InsertSpace(text, 10);
                                        cell     = row.Cells[c];
                                        cell.AddParagraph(celltext);
                                        cell.Format.Font.Bold = true;
                                        cell.Shading.Color    = TableBlue;
                                    }
                                }

                                //data
                                if ((R + r) >= TLrowcount && (C + c) >= TLcolcount)
                                {
                                    if (R + r - TLrowcount < DTrowcount && C + c - TLcolcount < DTcolcount)
                                    {
                                        text     = FGData[R + r - TLrowcount, C + c - TLcolcount];
                                        celltext = InsertSpace(text, 10);
                                        cell     = row.Cells[c];

                                        if (text.Contains("BSkySupScript")) //its superscript text
                                        {
                                            paragraph = cell.AddParagraph();
                                            paragraph.AddFormattedText("- ");
                                            celltext = text.Replace("BSkySupScript", "");
                                            paragraph.AddFormattedText(celltext, MigraDoc.DocumentObjectModel.TextFormat.Italic).Font.Superscript = true;
                                            cell.Format.Font.Size = fsiz;
                                        }
                                        else
                                        {
                                            cell.AddParagraph(celltext);
                                        }
                                    }
                                }
                            } //for c
                             //sbtable.AppendLine();
                        }     //for r
                        PartialPDFTables.Add(pdfTable);
                    }         //for C
                }             //for R
            }

            return(PartialPDFTables); // return all partial tables.
        }
コード例 #23
0
        public void MakeGiftCert(int itemID)
        {
            try
            {
                GiftCertificateInfo item;
                //load the item
                GiftCertificateController controller = new GiftCertificateController();
                item = controller.GetGiftCert(itemId);

                string CertAmountWords    = "";
                string MailToAddressField = "";
                string CertAmountNumber   = "";

                if (item != null)
                {
                    if (item.PaypalPaymentState.ToString().Length == 0)
                    {
                        Response.Redirect(Globals.NavigateURL("Access Denied"), true);
                    }

                    TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

                    CertAmountWords  = textInfo.ToTitleCase(NumberToWords(Int32.Parse(item.CertAmount.ToString())).ToString()).ToString() + " Dollars" + Environment.NewLine;
                    CertAmountNumber = "$" + String.Format("{0:f2}", item.CertAmount).ToString();

                    MailToAddressField = item.MailTo.ToString() + Environment.NewLine
                                         + item.MailToAddress.ToString() + Environment.NewLine
                                         + item.MailToCity.ToString() + ", " + item.MailToState.ToString() + " " + item.MailToZip.ToString();

                    _CertNotes = item.Notes.ToString();
                }


                string myPortalName = this.PortalSettings.PortalName.ToString();



                Document document = new Document();
                document.Info.Author   = "Joseph Aucoin";
                document.Info.Keywords = "Gift Certificate";
                document.Info.Title    = myPortalName.ToString() + " Gift Certificate";

                // Get the A4 page size
                MigraDoc.DocumentObjectModel.Unit width, height;
                PageSetup.GetPageSize(PageFormat.Letter, out width, out height);



                // Add a section to the document and configure it such that it will be in the centre
                // of the page
                Section section = document.AddSection();
                section.PageSetup.PageHeight  = height;
                section.PageSetup.PageWidth   = width;
                section.PageSetup.LeftMargin  = 20;
                section.PageSetup.RightMargin = 10;
                section.PageSetup.TopMargin   = 20; // height / 2;



                //++++++++++++++++++++++++++++++
                //++++++++++++++++++++++++++++++
                //++++++++++++++++++++++++++++++
                // ADD LOGO
                string myLogo = PortalSettings.HomeDirectoryMapPath + _CertLogo.ToString(); // "Images\\Chapins-Logo.png";
                MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(myLogo.ToString());

                image.LockAspectRatio    = true;
                image.RelativeVertical   = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Line;
                image.RelativeHorizontal = MigraDoc.DocumentObjectModel.Shapes.RelativeHorizontal.Margin;
                image.Top              = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Top;
                image.Left             = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Right;
                image.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through;

                MigraDoc.DocumentObjectModel.Tables.Table HeaderTable = new MigraDoc.DocumentObjectModel.Tables.Table();
                HeaderTable.Borders.Width         = 0; // Default to show borders 1 pixel wide Column
                HeaderTable.LeftPadding           = 10;
                HeaderTable.RightPadding          = 10;
                HeaderTable.Borders.Left.Visible  = false;
                HeaderTable.Borders.Right.Visible = false;


                // Add 1 columns
                float myColumnWidth = ((section.PageSetup.PageWidth - section.PageSetup.LeftMargin - section.PageSetup.RightMargin) / 2);   // ((width / 2) - 10);
                MigraDoc.DocumentObjectModel.Tables.Column column0 = HeaderTable.AddColumn(myColumnWidth);

                MigraDoc.DocumentObjectModel.Tables.Row row1 = HeaderTable.AddRow();
                row1.Cells[0].Elements.AddParagraph(_CertReturnAddress.ToString());
                row1.Cells[0].Format.Alignment = ParagraphAlignment.Left;


                section.Add(HeaderTable);

                /// SPACING
                MigraDoc.DocumentObjectModel.Paragraph paragraph = section.AddParagraph();
                paragraph.Format.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Exactly;
                paragraph.Format.LineSpacing     = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(30.0);

                //   section.Add(paragraph);

                //++++++++++++++++++++++++++++++
                // ADD ANOTHER TABLE FOR MAIL TO ADDRESS
                // Create a table so that we can draw the horizontal lines
                MigraDoc.DocumentObjectModel.Tables.Table tableMailToAddress = new MigraDoc.DocumentObjectModel.Tables.Table();
                tableMailToAddress.Borders.Width = 0; // Default to show borders 1 pixel wide Column
                tableMailToAddress.LeftPadding   = 20;
                tableMailToAddress.RightPadding  = 10;

                //  float myColumnWidth100percent = (width - 10);
                var column = tableMailToAddress.AddColumn((section.PageSetup.PageWidth - section.PageSetup.LeftMargin - section.PageSetup.RightMargin));

                double fontHeight = 20;
                Font   font       = new Font("Times New Roman", fontHeight);

                // Add a row with a single cell for the first line
                MigraDoc.DocumentObjectModel.Tables.Row  row  = tableMailToAddress.AddRow();
                MigraDoc.DocumentObjectModel.Tables.Cell cell = row.Cells[0];


                cell = row.Cells[0];

                cell.Format.Font.Color = Colors.Black;
                cell.Format.Alignment  = ParagraphAlignment.Left;
                cell.Format.Font.ApplyFont(font);

                cell.AddParagraph(MailToAddressField.ToString());

                section.Add(tableMailToAddress);

                // ADD SPACER+++++++++++++++++++++++++++++++++++++++
                MigraDoc.DocumentObjectModel.Paragraph paragraph1 = section.AddParagraph();
                paragraph1.Format.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Exactly;
                paragraph1.Format.LineSpacing     = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(20.0);



                // ADD ANOTHER TABLE FOR CERT
                // Create a table so that we can draw the horizontal lines
                MigraDoc.DocumentObjectModel.Tables.Table tableCert = new MigraDoc.DocumentObjectModel.Tables.Table();
                tableCert.Borders.Width         = 0; // Default to show borders 1 pixel wide Column
                tableCert.LeftPadding           = 10;
                tableCert.RightPadding          = 10;
                tableCert.Borders.Right.Visible = true;

                //  float myColumnWidth100percent = (width - 10);
                float sectionWidth = section.PageSetup.PageWidth - section.PageSetup.LeftMargin - section.PageSetup.RightMargin;
                float columnWidth  = sectionWidth;


                var columnCert = tableCert.AddColumn(columnWidth);
                columnCert.Format.Alignment = ParagraphAlignment.Center;

                double fontHeightCert = 30;
                Font   fontCert       = new Font("Times New Roman", fontHeightCert);

                // Add a row with a single cell for the first line
                MigraDoc.DocumentObjectModel.Tables.Row  rowCert  = tableCert.AddRow();
                MigraDoc.DocumentObjectModel.Tables.Cell cellCert = rowCert.Cells[0];

                cellCert.Format.Font.Color = Colors.Black;
                cellCert.Format.Font.ApplyFont(fontCert);
                cellCert.Borders.Left.Visible   = false;
                cellCert.Borders.Right.Visible  = false;
                cellCert.Borders.Bottom.Visible = false;

                cellCert.AddParagraph(_CertBannerText.ToString());

                // Add a row with a single cell for the second line
                rowCert  = tableCert.AddRow();
                cellCert = rowCert.Cells[0];

                cellCert.Format.Font.Color = Colors.Black;
                cellCert.Format.Alignment  = ParagraphAlignment.Center;
                cellCert.Format.Font.ApplyFont(fontCert);
                cellCert.Borders.Left.Visible  = false;
                cellCert.Borders.Right.Visible = false;
                cellCert.Borders.Top.Visible   = false;

                cellCert.AddParagraph(CertAmountWords.ToString());

                // 3RD LINE
                // Add a row with a single cell for the third line
                rowCert  = tableCert.AddRow();
                cellCert = rowCert.Cells[0];


                Font fontCertDetails = new Font("Times New Roman", 20);
                cellCert.Format.Font.Color = Colors.Black;

                cellCert.Format.Alignment = ParagraphAlignment.Left;
                cellCert.Format.Font.ApplyFont(fontCertDetails);
                cellCert.Borders.Left.Visible  = false;
                cellCert.Borders.Right.Visible = false;
                cellCert.Borders.Top.Visible   = false;

                cellCert.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(10.0);
                cellCert.Format.LeftIndent  = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(15.0);
                cellCert.AddParagraph("Date:" + item.CreatedDate.ToShortDateString() + Environment.NewLine + "Presented to: " + item.ToName.ToString() + Environment.NewLine +
                                      "From: " + item.FromName.ToString() + Environment.NewLine + "Amount: " + CertAmountNumber.ToString());


////////////////////////////////
                // 4th LINE
                // Add a row with a single cell for the forth line
                rowCert  = tableCert.AddRow();
                cellCert = rowCert.Cells[0];


                Font fontCertSignature = new Font("Arial", 12);
                cellCert.Format.Font.Color = Colors.Black;

                cellCert.Format.Alignment = ParagraphAlignment.Left;
                cellCert.Format.Font.ApplyFont(fontCertSignature);
                cellCert.Borders.Left.Visible  = false;
                cellCert.Borders.Right.Visible = false;
                cellCert.Borders.Top.Visible   = false;

                cellCert.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(10.0);
                cellCert.Format.LeftIndent  = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(15.0);
                cellCert.AddParagraph("Authorized Signature: __________________________________________________");

                ////////////////////////////////
                // 5th LINE
                // Add a row with a single cell for the fifth line
                rowCert  = tableCert.AddRow();
                cellCert = rowCert.Cells[0];


                Font fontCertInvoiceNumber = new Font("Arial", 10);
                cellCert.Format.Font.Color = Colors.Black;

                cellCert.Format.Alignment = ParagraphAlignment.Center;
                cellCert.Format.Font.ApplyFont(fontCertInvoiceNumber);
                cellCert.Borders.Left.Visible  = false;
                cellCert.Borders.Right.Visible = false;
                cellCert.Borders.Top.Visible   = false;
                //      cellCert.Format.AddTabStop("16cm", TabAlignment.Right);
                cellCert.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(3.0);
                //cellCert.Format.LeftIndent = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(15.0);
                cellCert.AddParagraph("Certificate Number 00" + item.ItemId.ToString());

                document.LastSection.Add(tableCert);


                if (item.Notes.ToString().Trim().Length > 0)
                {
                    //+++++++++ ADD PARAGRAPH FOR BUYER NOTES
                    MigraDoc.DocumentObjectModel.Paragraph paragraphFooter = section.AddParagraph();
                    paragraphFooter.Format.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Exactly;
                    paragraphFooter.Format.LineSpacing     = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(8.0);
                    paragraphFooter.Format.SpaceBefore     = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(10.0);
                    paragraphFooter.AddText("NOTES:" + Environment.NewLine + _CertNotes.ToString());
                }



                Paragraph footerText = new Paragraph();
                footerText.Format.Alignment = ParagraphAlignment.Center;
                footerText.AddText(_CertFooterText.ToString());

                section.Footers.Primary.Add(footerText);



                // Create a renderer
                PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer();

                // Associate the MigraDoc document with a renderer
                pdfRenderer.Document = document;

                // Layout and render document to PDF
                pdfRenderer.RenderDocument();


                string pdfFilename = PortalSettings.HomeDirectoryMapPath + _PdfFilesFolder.ToString() + "Cert" + itemId.ToString() + ".pdf";

                if (File.Exists(pdfFilename))
                {
                    File.Delete(pdfFilename);
                }

                pdfRenderer.PdfDocument.Save(pdfFilename);



                bool watermarkIsNeeded = false;
                if (_CertWatermark.ToString().Trim().Length > 1)
                {
                    watermarkIsNeeded = true;
                }

                if (watermarkIsNeeded)
                {
                    PdfDocument pdfIn  = PdfReader.Open(pdfFilename, PdfDocumentOpenMode.Import);
                    PdfDocument pdfOut = new PdfDocument();

                    for (int i = 0; i < pdfIn.PageCount; i++)
                    {
                        PdfPage pg = pdfIn.Pages[i];
                        pg = pdfOut.AddPage(pg);
                        // WATERMARK TEXT
                        string draftFlagStr = _CertWatermark.ToString();

                        // Get an XGraphics object for drawing beneath the existing content
                        XGraphics gfx = XGraphics.FromPdfPage(pg, XGraphicsPdfPageOptions.Prepend);

                        // Get the size (in point) of the text
                        XFont fontWM = new XFont("Verdana", 62, XFontStyle.Bold);
                        XSize size   = gfx.MeasureString(draftFlagStr, fontWM);

                        // Define a rotation transformation at the center of the page
                        gfx.TranslateTransform(pg.Width / 2, pg.Height / 2);
                        gfx.RotateTransform(-Math.Atan(pg.Height / pg.Width) * 180 / Math.PI);
                        gfx.TranslateTransform(-pg.Width / 2, -pg.Height / 2);

                        // Create a string format
                        XStringFormat format = new XStringFormat();
                        format.Alignment     = XStringAlignment.Near;
                        format.LineAlignment = XLineAlignment.Near;

                        // Create a dimmed red brush
                        XBrush brush = new XSolidBrush(XColor.FromArgb(32, 0, 0, 255));

                        // Draw the string
                        gfx.DrawString(draftFlagStr, fontWM, brush,
                                       new XPoint((pg.Width - size.Width) / 2, (pg.Height - size.Height) / 2),
                                       format);
                    }
                    pdfOut.Save(pdfFilename);
                }



                // Save and show the document
                //  pdfRenderer.PdfDocument.Save("TestDocument.pdf");
                Process.Start("explorer.exe", pdfFilename);


                HyperLinkPDF.Visible     = true;
                HyperLinkPDF.NavigateUrl = PortalSettings.HomeDirectory + _PdfFilesFolder.ToString() + "Cert" + itemId.ToString() + ".pdf";
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
コード例 #24
0
        private static void SetOneRow([JetBrains.Annotations.NotNull] ParagraphFormat format, [JetBrains.Annotations.NotNull] Table table, [ItemNotNull][JetBrains.Annotations.NotNull] string[] values)
        {
            var row = table.AddRow();

            for (var i = 0; i < values.Length; i++)
            {
                var cell = row.Cells[i];
                cell.AddParagraph(values[i]);
                cell.Format = format.Clone();
            }
        }
コード例 #25
0
ファイル: PdfRendererVisitor.cs プロジェクト: guz-guz/docgen
 public void VisitTable(Table table)
 {
     _pdfTable = _pdfCell == null
         ? _pdfSection.AddTable()
         : _pdfCell.Elements.AddTable();
 }
コード例 #26
0
        public Document CriaRelatorio()
        {
            Document relatorio = new Document();
            Section  section   = relatorio.AddSection();

            MigraDoc.DocumentObjectModel.Shapes.Image img = section.Headers.Primary.AddImage("gustavo2.png");
            img.Height             = "15cm";
            img.LockAspectRatio    = true;
            img.RelativeVertical   = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Page;
            img.RelativeHorizontal = MigraDoc.DocumentObjectModel.Shapes.RelativeHorizontal.Page;
            img.Top              = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center;
            img.Left             = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center;
            img.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through;

            section.PageSetup.TopMargin    = 25;
            section.PageSetup.LeftMargin   = 25;
            section.PageSetup.RightMargin  = 25;
            section.PageSetup.BottomMargin = 25;
            section.PageSetup.PageFormat   = PageFormat.A4;

            #region HeaderRelatorio
            Paragraph primeira_linha = section.AddParagraph("RELATÓRIO DE ENTRADA DÍZIMOS E OFERTAS - IGREJA BATISTA RENOVO");
            primeira_linha.Format.Alignment = ParagraphAlignment.Center;

            MigraDoc.DocumentObjectModel.Tables.Table tabela_header = new MigraDoc.DocumentObjectModel.Tables.Table();
            MigraDoc.DocumentObjectModel.Tables.Row   linha_header;
            tabela_header.Borders.Width = 0.5;

            MigraDoc.DocumentObjectModel.Tables.Column coluna_header = tabela_header.AddColumn("18cm");
            coluna_header.Format.Font.Name = "Calibri";
            coluna_header.Shading.Color    = Colors.WhiteSmoke;
            linha_header = tabela_header.AddRow();
            linha_header.Format.Alignment = ParagraphAlignment.Center;
            linha_header.Format.Font.Bold = true;
            linha_header.Cells[0].AddParagraph(System.DateTime.Now.ToString("dd/MM/yyyy") + " - " + Util.Funcoes.RetornaDia() + "(" + Util.Funcoes.RetornaPeriodo() + ")");
            tabela_header.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black);
            relatorio.LastSection.Add(tabela_header);
            #endregion
            Paragraph quebra_linha_headerReport = section.AddParagraph("");

            #region HeaderTabela
            MigraDoc.DocumentObjectModel.Tables.Table tabela_dizimistas;
            MigraDoc.DocumentObjectModel.Tables.Row   linha_dizimistas;

            tabela_dizimistas = new MigraDoc.DocumentObjectModel.Tables.Table();
            tabela_dizimistas.Borders.Width = 0.5;

            MigraDoc.DocumentObjectModel.Tables.Column coluna1 = tabela_dizimistas.AddColumn("14cm");
            coluna1.Format.Font.Name = "Calibri";

            MigraDoc.DocumentObjectModel.Tables.Column coluna2 = tabela_dizimistas.AddColumn("4cm");
            coluna2.Format.Font.Name = "Calibri";

            linha_dizimistas = tabela_dizimistas.AddRow();
            linha_dizimistas.Shading.Color     = Colors.Black;
            linha_dizimistas.Format.Font.Color = Colors.White;
            linha_dizimistas.Format.Font.Bold  = true;
            linha_dizimistas.Format.Alignment  = ParagraphAlignment.Center;
            linha_dizimistas.Cells[0].AddParagraph("DIZIMISTA");
            linha_dizimistas.Cells[1].AddParagraph("VALOR");
            #endregion

            #region ItensTabela
            decimal total_dizimos = 0;

            var listaDetalhes = _unitOfWork.CabecalhosEntradas.ListaDetalhes(Convert.ToInt32(Util.DataCript.Decriptar(HttpContext.Session.GetString("_hash"))));

            EntradaResponse total = new EntradaResponse
            {
                VlTotalDizimo  = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 1).Sum(s => s.Valor),
                VlTotalOferta  = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 2).Sum(s => s.Valor),
                VlTotalMissoes = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 3).Sum(s => s.Valor),
                VlTotalReforma = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 4).Sum(s => s.Valor),

                VlTotalNotas   = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 1).Sum(s => s.Valor),
                VlTotalMoedas  = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 2).Sum(s => s.Valor),
                VlTotalCheque  = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 3).Sum(s => s.Valor),
                VlTotalDebito  = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 4).Sum(s => s.Valor),
                VlTotalCredito = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 5).Sum(s => s.Valor),
                VlTotalTransf  = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 6).Sum(s => s.Valor),
            };
            total.VlTotalCategoria = total.VlTotalDizimo + total.VlTotalOferta + total.VlTotalMissoes + total.VlTotalReforma;
            total.VlTotalTipo      = total.VlTotalNotas + total.VlTotalMoedas + total.VlTotalCheque + total.VlTotalDebito + total.VlTotalCredito + total.VlTotalTransf;

            var lista = _unitOfWork.CabecalhosEntradas.ListarResponse(Convert.ToInt32(Util.DataCript.Decriptar(HttpContext.Session.GetString("_hash"))));

            RetornoResponse retorno = new RetornoResponse
            {
                retornoTotais = total,
                retornoLista  = lista
            };

            foreach (var linha in retorno.retornoLista.Where(w => w.Dizimo > 0))
            {
                linha_dizimistas = tabela_dizimistas.AddRow();
                linha_dizimistas.Format.Font.Size = 9;
                //linha_dizimistas.Cells[0].AddParagraph(Util.DataCript.Decriptar(linha.Pessoa.Nome).ToUpper());
                linha_dizimistas.Cells[0].AddParagraph(linha.Pessoa.Nome.ToUpper());
                linha_dizimistas.Cells[1].AddParagraph(linha.Dizimo.ToString());
                total_dizimos += linha.Dizimo;
            }

            tabela_dizimistas.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black);
            relatorio.LastSection.Add(tabela_dizimistas);
            #endregion

            Paragraph quebra_linha_totalizadores  = section.AddParagraph("");
            Paragraph quebra_linha_totalizadores2 = section.AddParagraph("");
            #region Totalizadores
            decimal total_ofertas  = 0;
            decimal total_missoes  = 0;
            decimal total_infantil = 0;
            decimal total_reforma  = 0;

            total_ofertas  = retorno.retornoTotais.VlTotalOferta;
            total_missoes  = retorno.retornoTotais.VlTotalMissoes;
            total_infantil = 0;
            total_reforma  = retorno.retornoTotais.VlTotalReforma;

            MigraDoc.DocumentObjectModel.Tables.Table tabela_total;
            MigraDoc.DocumentObjectModel.Tables.Row   linha_total;

            tabela_total = new MigraDoc.DocumentObjectModel.Tables.Table();
            tabela_total.Borders.Width = 0.5;
            MigraDoc.DocumentObjectModel.Tables.Column coluna_total1 = tabela_total.AddColumn("14cm");
            coluna_total1.Format.Font.Name = "Calibri";

            MigraDoc.DocumentObjectModel.Tables.Column coluna_total2 = tabela_total.AddColumn("4cm");
            coluna_total2.Format.Font.Name = "Calibri";

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.Gray;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL DIZIMOS");
            linha_total.Cells[1].AddParagraph(total_dizimos.ToString());

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.Gray;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL OFERTAS");
            linha_total.Cells[1].AddParagraph(total_ofertas.ToString());

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.Gray;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL MISSÕES");
            linha_total.Cells[1].AddParagraph(total_missoes.ToString());

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.Gray;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL REFORMA");
            linha_total.Cells[1].AddParagraph(total_reforma.ToString());

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.Gray;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL INFANTIL");
            linha_total.Cells[1].AddParagraph(total_infantil.ToString());

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.DarkGray;
            linha_total.Format.Font.Bold = true;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL");
            var totalCateg = total_dizimos + total_ofertas + total_missoes + total_reforma + total_infantil;
            linha_total.Cells[1].AddParagraph(totalCateg.ToString());

            tabela_total.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black);
            relatorio.LastSection.Add(tabela_total);
            #endregion

            Paragraph quebra_linha_tipo  = section.AddParagraph("");
            Paragraph quebra_linha_tipo2 = section.AddParagraph("");
            #region RelatorioTipo
            MigraDoc.DocumentObjectModel.Tables.Table tabela_tipo;
            MigraDoc.DocumentObjectModel.Tables.Row   linha_tipo;

            tabela_tipo = new MigraDoc.DocumentObjectModel.Tables.Table();
            tabela_tipo.Borders.Width = 0.5;
            MigraDoc.DocumentObjectModel.Tables.Column coluna_nota    = tabela_tipo.AddColumn("3cm");
            MigraDoc.DocumentObjectModel.Tables.Column coluna_moeda   = tabela_tipo.AddColumn("3cm");
            MigraDoc.DocumentObjectModel.Tables.Column coluna_cheque  = tabela_tipo.AddColumn("3cm");
            MigraDoc.DocumentObjectModel.Tables.Column coluna_debito  = tabela_tipo.AddColumn("3cm");
            MigraDoc.DocumentObjectModel.Tables.Column coluna_credito = tabela_tipo.AddColumn("3cm");
            MigraDoc.DocumentObjectModel.Tables.Column coluna_transf  = tabela_tipo.AddColumn("3cm");

            coluna_nota.Format.Font.Name    = "Calibri";
            coluna_moeda.Format.Font.Name   = "Calibri";
            coluna_cheque.Format.Font.Name  = "Calibri";
            coluna_debito.Format.Font.Name  = "Calibri";
            coluna_credito.Format.Font.Name = "Calibri";
            coluna_transf.Format.Font.Name  = "Calibri";

            linha_tipo = tabela_tipo.AddRow();
            linha_tipo.Shading.Color     = Colors.Black;
            linha_tipo.Format.Font.Color = Colors.White;
            linha_tipo.Format.Font.Bold  = true;
            linha_tipo.Cells[0].AddParagraph("Notas");
            linha_tipo.Cells[1].AddParagraph("Moedas");
            linha_tipo.Cells[2].AddParagraph("Cheques");
            linha_tipo.Cells[3].AddParagraph("C. Déb.");
            linha_tipo.Cells[4].AddParagraph("C. Créd.");
            linha_tipo.Cells[5].AddParagraph("Transf.");

            decimal total_notas   = 0;
            decimal total_moedas  = 0;
            decimal total_cheques = 0;
            decimal total_debito  = 0;
            decimal total_credito = 0;
            decimal total_transf  = 0;

            total_notas   = retorno.retornoTotais.VlTotalNotas;
            total_moedas  = retorno.retornoTotais.VlTotalMoedas;
            total_cheques = retorno.retornoTotais.VlTotalCheque;
            total_debito  = retorno.retornoTotais.VlTotalDebito;
            total_credito = retorno.retornoTotais.VlTotalCredito;
            total_transf  = retorno.retornoTotais.VlTotalTransf;

            linha_tipo = tabela_tipo.AddRow();
            linha_tipo.Cells[0].AddParagraph(total_notas.ToString());
            linha_tipo.Cells[1].AddParagraph(total_moedas.ToString());
            linha_tipo.Cells[2].AddParagraph(total_cheques.ToString());
            linha_tipo.Cells[3].AddParagraph(total_debito.ToString());
            linha_tipo.Cells[4].AddParagraph(total_credito.ToString());
            linha_tipo.Cells[5].AddParagraph(total_transf.ToString());
            Paragraph quebra_linha5 = section.AddParagraph("");

            tabela_tipo.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black);
            relatorio.LastSection.Add(tabela_tipo);

            #endregion

            Paragraph quebra_linha_conferidoPor  = section.AddParagraph("");
            Paragraph quebra_linha_conferidoPor2 = section.AddParagraph("");
            Paragraph quebra_linha_conferidoPor3 = section.AddParagraph("");
            #region ConferidoPor
            MigraDoc.DocumentObjectModel.Tables.Table tabela_conferidoPor;
            MigraDoc.DocumentObjectModel.Tables.Row   linha_conferidoPor;

            tabela_conferidoPor = new MigraDoc.DocumentObjectModel.Tables.Table();
            tabela_conferidoPor.Borders.Width = 0;
            MigraDoc.DocumentObjectModel.Tables.Column coluna_conferidoPor = tabela_conferidoPor.AddColumn("3cm");
            coluna_conferidoPor.Format.Font.Name = "Calibri";

            MigraDoc.DocumentObjectModel.Tables.Column coluna_conferidoPor1 = tabela_conferidoPor.AddColumn("7cm");
            coluna_conferidoPor1.Format.Font.Name = "Calibri";

            MigraDoc.DocumentObjectModel.Tables.Column coluna_conferidoPor2 = tabela_conferidoPor.AddColumn("7cm");
            coluna_conferidoPor2.Format.Font.Name = "Calibri";

            linha_conferidoPor = tabela_conferidoPor.AddRow();
            linha_conferidoPor.Format.Alignment = ParagraphAlignment.Center;
            linha_conferidoPor.Cells[0].AddParagraph("CONFERIDO POR:");
            linha_conferidoPor.Cells[1].AddParagraph(Util.DataCript.Decriptar(HttpContext.Session.GetString("_header1")));
            linha_conferidoPor.Cells[1].Format.Borders.Top.Width = 0.5;
            linha_conferidoPor.Cells[2].AddParagraph(Util.DataCript.Decriptar(HttpContext.Session.GetString("_header2")));
            linha_conferidoPor.Cells[2].Format.Borders.Top.Width = 0.5;

            tabela_conferidoPor.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black);
            relatorio.LastSection.Add(tabela_conferidoPor);
            #endregion

            return(relatorio);
        }
コード例 #27
0
        private static void ExportOutputPDF(CommandOutput output, MigraDoc.DocumentObjectModel.Document Doc, bool extratags, List <string> filelist, bool issessionout = false)//csv of excel
        {
            if (output.NameOfAnalysis == null)
            {
                output.NameOfAnalysis = string.Empty;
            }

            foreach (DependencyObject obj in output)
            {
                FrameworkElement element = obj as FrameworkElement;
                //31Aug2012 AUXGrid xgrid = element as AUXGrid;
                if ((element as AUParagraph) != null)
                {
                    AUParagraph aup = element as AUParagraph;

                    if (!aup.IsVisible)
                    {
                        continue;
                    }

                    if (aup.Text != null)                                                                                                                                                              ///// <aup> means AUParagraph
                    {
                        MigraDoc.DocumentObjectModel.Paragraph PDFpara = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(aup.Text, aup.FontWeight, aup.FontSize, aup.textcolor, aup.FontStyle); //aup.ExportPDFParagraph();
                        PDFpara.AddLineBreak();
                        Doc.LastSection.Add(PDFpara.Clone());
                    }
                }
                else if ((element as AUXGrid) != null)
                {
                    AUXGrid xgrid = element as AUXGrid; //31Aug2012


                    if (!xgrid.IsVisible)
                    {
                        continue;
                    }
                    ////////// Printing Header //////////  <fgheader> means flexgrid header
                    string      header  = xgrid.Header.Text;
                    AUParagraph FGTitle = new AUParagraph();
                    FGTitle.Text       = header;
                    FGTitle.FontWeight = FontWeights.SemiBold;
                    if (APAStyle)
                    {
                        FGTitle.FontStyle = FontStyles.Italic;
                    }
                    //FGTitle.textcolor =
                    MigraDoc.DocumentObjectModel.Paragraph PDFpara = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(FGTitle.Text, FGTitle.FontWeight, FGTitle.FontSize, FGTitle.textcolor, FGTitle.FontStyle); //FGTitle.ExportPDFParagraph();
                    PDFpara.AddLineBreak();
                    Doc.LastSection.Add(PDFpara.Clone());

                    //////////////// Printing Errors ///////////
                    if (xgrid.Metadata != null)//// <errhd> means error heading
                    {
                        // Error/Warning Title
                        AUParagraph ErrWarnTitle = new AUParagraph();
                        ErrWarnTitle.Text       = "Errors/Warnings: ";;
                        ErrWarnTitle.FontWeight = FontWeights.SemiBold;
                        //ErrWarnTitle.FontStyle = FontStyles.Normal;
                        //ErrWarnTitle.textcolor =
                        MigraDoc.DocumentObjectModel.Paragraph PDFparaErrWarnTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(ErrWarnTitle.Text, ErrWarnTitle.FontWeight, ErrWarnTitle.FontSize, ErrWarnTitle.textcolor, ErrWarnTitle.FontStyle); //ErrWarnTitle.ExportPDFParagraph();
                        PDFparaErrWarnTitle.AddLineBreak();
                        Doc.LastSection.Add(PDFparaErrWarnTitle.Clone());

                        // Error/Warning Messages
                        AUParagraph ErrWarnMsgPara = null;
                        foreach (KeyValuePair <char, string> keyval in xgrid.Metadata)
                        {
                            ErrWarnMsgPara      = new AUParagraph();
                            ErrWarnMsgPara.Text = keyval.Key.ToString() + ":" + keyval.Value;

                            MigraDoc.DocumentObjectModel.Paragraph PDFparaErrWarnMsg = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(ErrWarnMsgPara.Text, ErrWarnMsgPara.FontWeight, ErrWarnMsgPara.FontSize, ErrWarnMsgPara.textcolor, ErrWarnMsgPara.FontStyle); //ErrWarnMsgPara.ExportPDFParagraph();
                            PDFparaErrWarnMsg.AddLineBreak();
                            Doc.LastSection.Add(PDFparaErrWarnMsg.Clone());
                        }
                    }

                    //////// Printing  Grid ////////////
                    AUGrid grid = xgrid.Grid;
                    float  remainingpagesize = 0.0f;//remaining page height
                    float  currentTblHt      = 0.0f;
                    float  PDFpageHeight     = Doc.DefaultPageSetup.PageHeight;

                    BSky.ExportToPDF.ExportAUXGrid.APAStyle = APAStyle;
                    List <MigraDoc.DocumentObjectModel.Tables.Table> TablePortions = BSky.ExportToPDF.ExportAUXGrid.ExportMultiHeaderFlexgridToPDF(PDFpageHeight, grid, strMaxTblCol, strMaxTblRow, strPDFfontsize);  //xgrid.ExportMultiHeaderFlexgridToPDF(PDFpageHeight);

                    foreach (MigraDoc.DocumentObjectModel.Tables.Table ptbl in TablePortions)
                    {
                        if (ptbl == null)
                        {
                            continue;
                        }

                        //Add Partial Table ID (so that printouts can be arranged in proper order)
                        if (ptbl.Tag != null)
                        {
                            Doc.LastSection.AddParagraph(ptbl.Tag.ToString());
                        }

                        //add table part to doc
                        Doc.LastSection.Add(ptbl);

                        Doc.LastSection.AddParagraph().AddLineBreak();
                    }

                    /////////////////Printing Footer  ///////////////
                    string starfootnotes   = string.Empty;
                    bool   templatedDialog = false;
                    if (templatedDialog)
                    {
                        //I think this works for templated dialogs
                        if (xgrid.FootNotes != null)
                        {
                            // Printing Foonotes Title
                            if (xgrid.FootNotes.Count > 0)
                            {
                                AUParagraph FooterTitle = new AUParagraph();
                                FooterTitle.Text       = "Footnotes: ";                                                                                                                                                                                           //Footnote Title
                                FooterTitle.FontWeight = FontWeights.SemiBold;
                                MigraDoc.DocumentObjectModel.Paragraph PDFparaFooterTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(FooterTitle.Text, FooterTitle.FontWeight, FooterTitle.FontSize, FooterTitle.textcolor, FooterTitle.FontStyle); //FooterTitle.ExportPDFParagraph();
                                PDFparaFooterTitle.AddLineBreak();
                                Doc.LastSection.Add(PDFparaFooterTitle.Clone());
                            }
                            AUParagraph footnote = null;
                            foreach (KeyValuePair <char, string> keyval in xgrid.FootNotes)
                            {
                                footnote      = new AUParagraph();
                                footnote.Text = keyval.Key.ToString() + ":" + keyval.Value;

                                MigraDoc.DocumentObjectModel.Paragraph PDFparaFootnotesMsg = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(footnote.Text, footnote.FontWeight, footnote.FontSize, footnote.textcolor, footnote.FontStyle); //footnote.ExportPDFParagraph();
                                PDFparaFootnotesMsg.AddLineBreak();
                                Doc.LastSection.Add(PDFparaFootnotesMsg.Clone());
                            }
                        }
                    }
                    else //This works for non-templated dialogs
                    {
                        AUParagraph starfootnote = new AUParagraph();
                        starfootnote.Text     = xgrid.StarFootNotes;
                        starfootnote.FontSize = 9;                                                                                                                                                                                                                //table cell text(& R syntax) looks size 12. So I want it to be smaller than other text.

                        MigraDoc.DocumentObjectModel.Paragraph PDFparaStarFooterText = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(starfootnote.Text, starfootnote.FontWeight, starfootnote.FontSize, starfootnote.textcolor, starfootnote.FontStyle); //FooterTitle.ExportPDFParagraph();
                        PDFparaStarFooterText.AddLineBreak();
                        Doc.LastSection.Add(PDFparaStarFooterText.Clone());
                    }
                }
                else if ((element as BSkyGraphicControl) != null)//Graphics 31Aug2012
                {
                    BSkyGraphicControl bsgc = element as BSkyGraphicControl;

                    //To only Export Graphics those are visible (checked in the left navigation tree, in output window)
                    if (!bsgc.IsVisible)
                    {
                        continue;
                    }
                    //Create image filename
                    string imgfilename = "PDF" + bsgc.ImageName + ".png";

                    string synedtimg = Path.Combine(tempDir, imgfilename);

                    //Saving Image separately
                    BSkyGraphicControlToImageFile(bsgc, synedtimg);                                                          //not imgfilename

                    MigraDoc.DocumentObjectModel.Paragraph imgPara = BSky.ExportToPDF.ExportGraphics.ExportToPDF(synedtimg); //bsgc.ExportToPDF(synedtimg);// not imgfilename

                    //finally add image to the PDF doc.
                    Doc.LastSection.Add(imgPara);
                }
                else if ((element as BSkyNotes) != null) // Notes Control 05Nov2012.
                {
                    BSkyNotes bsn = element as BSkyNotes;
                    //To only Export Notes those are visible (checked in the left navigation tree, in output window)
                    if (!bsn.IsVisible)
                    {
                        continue;
                    }

                    //Put a title
                    AUParagraph NotesTitle = new AUParagraph();
                    NotesTitle.Text       = "Notes"; //Footnote Title
                    NotesTitle.FontWeight = FontWeights.SemiBold;

                    MigraDoc.DocumentObjectModel.Paragraph PDFparaNotesTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(NotesTitle.Text, NotesTitle.FontWeight, NotesTitle.FontSize, NotesTitle.textcolor, NotesTitle.FontStyle); //NotesTitle.ExportPDFParagraph();
                    PDFparaNotesTitle.AddLineBreak();
                    Doc.LastSection.Add(PDFparaNotesTitle.Clone());

                    //Now Notes data in PdfPTable
                    MigraDoc.DocumentObjectModel.Tables.Table notestable = BSky.ExportToPDF.ExportNotes.ExportToPDF(bsn.NotesData, strPDFfontsize);// bsn.ExportToPDF();
                    Doc.LastSection.Add(notestable);
                    Doc.LastSection.AddParagraph().AddLineBreak();
                }
            }

            ////for export to excel////E
        }