Пример #1
1
        public static Table CreateMergedDownTable(string[] strArrayHeader, string[] strArrayHeaderSize, string[][] strMatrixContent, int[][] matrixMergeDown, string fontName, Color fontColor, Color shadeColor, Unit fontSize, double borderSize, double edgeSize, bool isHeaderBold, string imageWidth)
        {
            Table table = new Table();
            table.Borders.Width = borderSize;

            for (int i = 0; i < strArrayHeader.GetLength(0); i++)
            {
                table.AddColumn(strArrayHeaderSize[i]);
            }

            Row row = table.AddRow();
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = isHeaderBold;
            row.Format.Font.Name = fontName;
            row.Format.Font.Color = fontColor;
            row.Format.Font.Size = fontSize;
            row.Shading.Color = shadeColor;
            row.VerticalAlignment = VerticalAlignment.Center;

            Cell cell;

            for (int i = 0; i < strArrayHeader.GetLength(0); i++)
            {
                cell = row.Cells[i];
                cell.AddParagraph(strArrayHeader[i]);
            }

            for (int i = 0; i < strMatrixContent.GetLength(0); i++)
            {
                row = table.AddRow();
                row.Format.Alignment = ParagraphAlignment.Left;
                row.Format.Font.Bold = false;
                row.Format.Font.Name = fontName;
                row.Format.Font.Color = fontColor;
                row.Format.Font.Size = fontSize;

                string[] strArrayContent = strMatrixContent[i];

                for (int j = 0; j < strArrayContent.GetLength(0); j++)
                {
                    cell = row.Cells[j];
                    cell.MergeDown = matrixMergeDown[i][j];
                    if (strArrayContent[j].Contains(".jpg") || strArrayContent[j].Contains(".png"))
                    {
                        Image image = new Image(strArrayContent[j]);
                        image.Width = imageWidth;
                        cell.Add(image);
                    }
                    else
                    {
                        cell.AddParagraph(strArrayContent[j]);
                    }
                }
            }

            table.SetEdge(0, 0, strArrayHeader.GetLength(0), strMatrixContent.GetLength(0) + 1, Edge.Box, BorderStyle.Single, edgeSize, Colors.Black);
            return table;
        }
Пример #2
0
        private void Table(IPdfStyling pdfStyling, MigraDoc.DocumentObjectModel.Tables.Table table, IDictionary <string, string> rows)
        {
            Row       row;
            Font      font;
            Paragraph paragraph;

            foreach (KeyValuePair <string, string> item in rows)
            {
                row = table.AddRow();

                row.Cells[0].Format.LeftIndent = Unit.FromCentimeter(1);

                paragraph = row.Cells[0].AddParagraph();
                paragraph.Format.Font.Size  = 10;
                paragraph.Format.Font.Color = pdfStyling.ParagraphSmallColor;

                font       = paragraph.Format.Font.Clone();
                font.Color = pdfStyling.FontColor;

                paragraph.Format.AddTabStop("3.5cm", TabAlignment.Left, TabLeader.Dots);

                paragraph.AddFormattedText(item.Value, font);
                paragraph.AddTab();

                paragraph = row.Cells[1].AddParagraph();
                paragraph.AddFormattedText(item.Key, font);
            }
        }
Пример #3
0
        public Table generate(MannschaftskampfViewModel mannschaftskampfViewModel, double randLinksRechts, bool useColor)
        {
            Color colorRed  = Colors.Black;
            Color colorBlue = Colors.Black;

            if (useColor)
            {
                colorRed  = CustomStyles.ROT;
                colorBlue = CustomStyles.BLAU;
            }

            Table table = SetUpKampftabelle(randLinksRechts);

            Row zeileMannschaften = table.AddRow();

            MannschaftenUeberschrift(zeileMannschaften, mannschaftskampfViewModel);

            var kopfzeile = table.AddRow();

            Kopfzeilen(kopfzeile, colorRed, colorBlue);

            Kampfzeilen(table, mannschaftskampfViewModel.Children, colorRed, colorBlue);

            Row zeile = table.AddRow();

            GesamtErgebnis(zeile, Convert.ToInt32(mannschaftskampfViewModel.HeimPunkte), Convert.ToInt32(mannschaftskampfViewModel.GastPunkte), colorRed, colorBlue);

            return(table);
        }
Пример #4
0
        public TableOfContents(MigraDoc.DocumentObjectModel.Tables.Table table)
            : base(table)
        {
            var labelColumn = table.AddColumn("18cm");

            labelColumn.Format.Alignment = ParagraphAlignment.Left;
        }
Пример #5
0
        public Table1Column(MigraDoc.DocumentObjectModel.Tables.Table table)
            : base(table)
        {
            var column = table.AddColumn("18cm");

            column.Format.Alignment = ParagraphAlignment.Left;
        }
Пример #6
0
        private Table SetUpKampftabelle()
        {
            Table table = new Table();

            table.Style                  = CustomStyles.TABLEKLEIN;
            table.Borders.Color          = Colors.Black;
            table.Borders.Width          = 0.25;
            table.Borders.Left.Width     = 0.25;
            table.Borders.Right.Width    = 0.25;
            table.Rows.LeftIndent        = 0;
            table.Rows.VerticalAlignment = VerticalAlignment.Center;

            double breite_KampfNr        = 1.2;
            double breite_Gewichtsklasse = 1;
            double breite_Name           = 3;

            Column column = table.AddColumn($"{breite_KampfNr}cm");

            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_Gewichtsklasse}cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_Name}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn($"{breite_Name}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            return(table);
        }
Пример #7
0
    public static void DemonstrateSimpleTable(Document document)
    {
      document.LastSection.AddParagraph("Simple Tables", "Heading2");

      Table table = new Table();
      table.Borders.Width = 0.75;

      Column column = table.AddColumn(Unit.FromCentimeter(2));
      column.Format.Alignment = ParagraphAlignment.Center;

      table.AddColumn(Unit.FromCentimeter(5));

      Row row = table.AddRow();
      row.Shading.Color = Colors.PaleGoldenrod;
      Cell cell = row.Cells[0];
      cell.AddParagraph("Itemus");
      cell = row.Cells[1];
      cell.AddParagraph("Descriptum");

      row = table.AddRow();
      cell = row.Cells[0];
      cell.AddParagraph("1");
      cell = row.Cells[1];
      cell.AddParagraph(FillerText.ShortText);

      row = table.AddRow();
      cell = row.Cells[0];
      cell.AddParagraph("2");
      cell = row.Cells[1];
      cell.AddParagraph(FillerText.Text);

      table.SetEdge(0, 0, 2, 3, Edge.Box, BorderStyle.Single, 1.5, Colors.Black);

      document.LastSection.Add(table);
    }
Пример #8
0
 public Table(MigraDoc.DocumentObjectModel.Tables.Table table)
 {
     ThisTable                   = table;
     ThisTable.Style             = "Table";
     ThisTable.Format.LeftIndent = ".2cm";
     ThisTable.Borders.Visible   = true;
 }
Пример #9
0
        public Table generate(MannschaftskampfViewModel mannschaftskampfViewModel, double randLinksRechts)
        {
            Table table     = SetUpKampftabelle(randLinksRechts);
            Row   kopfzeile = table.AddRow();

            Kopfzeilen(kopfzeile);
            Kampfzeilen(table, mannschaftskampfViewModel.Children);

            return(table);
        }
Пример #10
0
        private Table Kampftabelle(MannschaftskampfViewModel mannschaftskampfViewModel)
        {
            Table table     = SetUpKampftabelle();
            Row   kopfzeile = table.AddRow();

            Kopfzeilen(kopfzeile);
            Kampfzeilen(table, mannschaftskampfViewModel.Children);

            return(table);
        }
Пример #11
0
 private void Kampfzeilen(Table table, List <EinzelkampfViewModel> kaempfe)
 {
     foreach (var kampf in kaempfe.OrderBy(li => li.KampfNr))
     {
         Row zeile = table.AddRow();
         InhaltKampfzeile(zeile, kampf);
         _kampfSpaltenCounter       = 0;
         zeile.Borders.Bottom.Width = "0.15cm";
     }
 }
        private void Columns(Table table)
        {
            // Before you can add a row, you must define the columns
            var column = table.AddColumn("5.5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            for (var i = 0; i < 4; i++)
            {
                table.AddColumn("2cm").Format.Alignment = ParagraphAlignment.Right;
            }
        }
Пример #13
0
        private Table SetUpKampftabelle(double randLinksRechts)
        {
            Table table = new Table();

            table.Style                  = CustomStyles.TABLEKLEIN;
            table.Borders.Color          = Colors.Black;
            table.Borders.Width          = 0.25;
            table.Borders.Left.Width     = 0.25;
            table.Borders.Right.Width    = 0.25;
            table.Rows.LeftIndent        = 0;
            table.Rows.VerticalAlignment = VerticalAlignment.Center;

            // Before you can add a row, you must define the columns
            double a4LandscapeBreite = (29.7 - 2 * randLinksRechts);

            double breite_KampfNr        = 1.2;
            double breite_Gewichtsklasse = 1;
            double breite_Name           = 3;

            double breite_Sieger = 2;


            double breite_Unterschrift = a4LandscapeBreite - breite_KampfNr - breite_Gewichtsklasse - 2 * breite_Name - _breite_Wertungen - breite_Sieger - _breite_Siegart;

            Column column = table.AddColumn($"{breite_KampfNr}cm");

            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_Gewichtsklasse}cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_Name}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn($"{breite_Name}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn($"{_breite_Wertungen}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn($"{breite_Sieger}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn($"{_breite_Siegart}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn($"{breite_Unterschrift}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            return(table);
        }
Пример #14
0
        /// <summary>
        /// Render row into the table
        /// </summary>
        public void RenderInto(MigraDoc.DocumentObjectModel.Tables.Table table)
        {
            MigraDoc.DocumentObjectModel.Tables.Row row = table.AddRow();

            for (int i = 0; i < this.values.Length; i++)
            {
                Cell cell = row.Cells[i];
                cell.VerticalAlignment = VerticalAlignment.Center;

                this.values[i].RenderInto(cell);
            }

            if (this.color != null)
            {
                row.Shading.Color = this.color.GetColor();
            }
        }
Пример #15
0
        private void Kampfzeilen(Table table, List <EinzelkampfViewModel> kaempfe, Color colorRed, Color colorBlue)
        {
            int cnt = 0;

            foreach (var kampf in kaempfe)
            {
                Row zeile = table.AddRow();
                InhaltKampfzeile(zeile, kampf, colorRed, colorBlue);

                if (cnt % 2 != 0)
                {
                    zeile.Shading.Color = Colors.LightGray;
                }
                cnt++;
                _kampfSpaltenCounter = 0;
            }
        }
        private void CreatePage(DateTime date)
        {
            var section = this.document.AddSection();

            var paragraph = section.AddParagraph();
            paragraph.Style = "Table";
            paragraph.Format.SpaceAfter = "0,5cm";
            paragraph.AddFormattedText("Йожени 95 ЕООД", TextFormat.Bold);
            paragraph.AddTab();
            paragraph.AddFormattedText("Стокова разписка", TextFormat.Bold);
            paragraph.AddTab();
            paragraph.AddFormattedText(date.ToShortDateString(), TextFormat.Bold);

            this.table = section.AddTable();
            this.table.Style = "Table";
            this.table.Borders.Visible = true;

            // Before you can add a row, you must define the columns
            var column = this.table.AddColumn("1,5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column = this.table.AddColumn("11cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            column = this.table.AddColumn("2cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column = this.table.AddColumn("2cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            // Create the header of the table
            var row = this.table.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;

            row.Cells[0].AddParagraph("№");
            row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[1].AddParagraph("Име");
            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[2].AddParagraph("К-во");
            row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[3].AddParagraph("Цена");
            row.Cells[3].Format.Alignment = ParagraphAlignment.Left;
        }
Пример #17
0
        /// <summary>
        /// Adds variable counts of rows and columns to the top, right, bottom and of left of the table.
        /// </summary>
        /// <param name="table"></param>
        /// <param name="newRowsTop"></param>
        /// <param name="newColsRight"></param>
        /// <param name="newRowsBottom"></param>
        /// <param name="newColsLeft"></param>
        public static void ExpandTable(Table table, int newRowsTop, int newColsRight, int newRowsBottom, int newColsLeft)
        {
            for (int i = 0; i < newRowsTop; i++)
                table.Rows.InsertObject(0, new Row());

            for (int i = 0; i < newColsLeft; i++)
            {
                table.Columns.InsertObject(0, new Column());
                foreach (Row row in table.Rows)
                    row.Cells.InsertObject(0, new Cell());
            }

            for (int i = 0; i < newRowsBottom; i++)
                table.Rows.Add(new Row());
            
            for (int i = 0; i < newColsRight; i++)
                table.Columns.Add(new Column());
        }
Пример #18
0
        private Table BuildIncidencyMatrix()
        {
            var numberOfVertices = _graph.NumberOfVertices;
            var table            = new Table
            {
                Columns = new Columns(
                    Enumerable
                    .Repeat(0, numberOfVertices + 1)
                    .Select(_ => new Unit(20.0, UnitType.Point))
                    .ToArray()
                    ),
                Rows = new Rows
                {
                    Height = new Unit(20, UnitType.Point)
                }
            };

            var headerRow = table.AddRow();

            for (int i = 0; i <= numberOfVertices; ++i)
            {
                var p = headerRow.Cells[i];
                p.Style = "TableHeader";
                p.AddParagraph(i == 0 ? string.Empty : i.ToString());
            }

            for (int i = 0; i < numberOfVertices; ++i)
            {
                var row = table.AddRow();
                row.Cells[0].AddParagraph((i + 1).ToString()).Style = "TableHeader";

                for (int j = 0; j < numberOfVertices; ++j)
                {
                    var content = i == j
                        ? "-"
                        : (_graph[i, j] ? "1" : "0");

                    row.Cells[j + 1].AddParagraph(content).Format.Alignment = ParagraphAlignment.Center;
                }
            }

            return(table);
        }
Пример #19
0
        private Table KampfInfos(MannschaftskampfViewModel mannschaftskampfViewModel, CompetitionInfosViewModel zusatzInfos)
        {
            var table = new Table();

            table.Style = CustomStyles.TABLEINFO;

            double a4LandscapeBreite = (29.7 - 2 * _randLinksRechts) / 3.0;

            Column column = table.AddColumn($"{a4LandscapeBreite - 2}cm");

            column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn($"{a4LandscapeBreite + 4}cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column = table.AddColumn($"{a4LandscapeBreite - 2}cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            Row zeile = table.AddRow();

            var spalte = zeile.Cells[0].AddParagraph();
            var ft     = spalte.AddFormattedText($"{mannschaftskampfViewModel.LigaId} {mannschaftskampfViewModel.TableId}", TextFormat.Bold);

            ft.Font.Size = CustomStyles.fontSizeNormal;
            ft.Font.Name = CustomStyles.fontUeberschriften;

            spalte       = zeile.Cells[1].AddParagraph();
            ft           = spalte.AddFormattedText($"{zusatzInfos.Kampfart} {mannschaftskampfViewModel.HeimMannschaft} vs. {mannschaftskampfViewModel.GastMannschaft}", TextFormat.Bold);
            ft.Font.Size = CustomStyles.fontSizeNormal;
            ft.Font.Name = CustomStyles.fontUeberschriften;

            spalte       = zeile.Cells[2].AddParagraph();
            ft           = spalte.AddFormattedText($"{mannschaftskampfViewModel.Kampfdatum.ToShortDateString()}", TextFormat.Bold);
            ft.Font.Size = CustomStyles.fontSizeNormal;
            ft.Font.Name = CustomStyles.fontUeberschriften;

            return(table);
        }
Пример #20
0
        /// <summary>
        /// Renders the element.
        /// </summary>
        /// <param name="pdfStyling">The PDF styling.</param>
        /// <param name="section">The section.</param>
        public void Render(IPdfStyling pdfStyling, Section section)
        {
            MigraDoc.DocumentObjectModel.Tables.Table table = AddTable(
                pdfStyling: pdfStyling,
                section: section);

            switch (_style)
            {
            case TableStyle.Bordered:
                pdfStyling.TableStyling.BorderedStyle(table);
                break;

            case TableStyle.Grid:
                pdfStyling.TableStyling.GridStyle(table);
                break;

            case TableStyle.OnlyRowsBordered:
                pdfStyling.TableStyling.OnlyRowsBorderedStyle(table);
                break;

            case TableStyle.NoBorders:
                pdfStyling.TableStyling.NoBordersStyle(table);
                break;

            case TableStyle.StripedRows:
                pdfStyling.TableStyling.StripedRowsStyle(table);
                break;

            case TableStyle.Zebra:
                pdfStyling.TableStyling.ZebraStyle(table);
                break;

            case TableStyle.NoSpacing:
                pdfStyling.TableStyling.NoSpacingStyle(table);
                break;
            }
        }
Пример #21
0
        private void SetTableData(Order order, ref Table table)
        {
            for (int i = 0; i < order.OrderLines.Count; i++)
            {
                OrderLine orderLine = order.OrderLines[i];
                Row row = table.AddRow();
                row.TopPadding = 2;
                row.BottomPadding = 2;
                var counter = 0;
                row.Cells[counter++].AddParagraph((i + 1).ToString());
                row.Cells[counter++].AddParagraph(orderLine.Name);

                var quantity = orderLine.Quantity;
                row.Cells[counter++].AddParagraph(quantity.ToString());

                var taxesEnabled = _taxSettings.TaxesEnabled;
                var unitPrice = (taxesEnabled ? orderLine.UnitPricePreTax : orderLine.UnitPrice);
                row.Cells[counter++].AddParagraph(unitPrice.ToCurrencyFormat());

                if (taxesEnabled)
                {
                    row.Cells[counter++].AddParagraph((orderLine.TaxRate) + "%");
                }
                row.Cells[counter++].AddParagraph((unitPrice * quantity).ToCurrencyFormat());

                table.SetEdge(0, table.Rows.Count - 2, 5, 2, Edge.Box, BorderStyle.Single, 0.75);
            }
        }
Пример #22
0
 /// <summary>
 /// Adds a new table to the section.
 /// </summary>
 public void Add(Table table)
 {
   this.Elements.Add(table);
 }
Пример #23
0
        public static void CreatePage(Document document, Ventana ventana)
        {
            MigraDoc.DocumentObjectModel.Tables.Table table = new MigraDoc.DocumentObjectModel.Tables.Table();
            table.Borders.Width = 0.5;

            Column column = table.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromCentimeter(4));

            column.Format.Alignment = ParagraphAlignment.Left;

            table.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromCentimeter(12.5));

            Row row = table.AddRow();

            row.Shading.Color = Colors.White;
            Cell cell = row.Cells[0];

            row.Cells[0].MergeRight = 1;

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("PO:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.PO);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Recursos:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.Recurso);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Cantidades (#pp):");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.Cantidad);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Linea Transportista:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.Carrier.NombreCorto);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Operador:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.Conductor);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Movil:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.MovilConductor);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Origen:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.Procedencia.NombreCorto);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Destino:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.Destino.NombreCorto);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Fecha:");
            cell = row.Cells[1];
            cell.AddParagraph((ventana.Evento.FechaInicio).ToString());

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("No ECO Tractor:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.NumeroEconomico);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Placas Tractor:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.NumeroPlaca);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("No Caja/Contenedor:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.EconomicoRemolque);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Placas Caja/Contenedor:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.PlacaRemolque);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Modelo:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.ModeloContenedor);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Color:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.ColorContenedor);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Tipo Unidad:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.TipoUnidad);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Dimensión:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.Dimension);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Sellos:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.Sellos);

            row = table.AddRow();
            row.Format.Font.Size = 6;
            cell = row.Cells[0];
            cell.AddParagraph("Temperatura Controlada:");
            cell = row.Cells[1];
            cell.AddParagraph(ventana.Temperatura);

            table.SetEdge(0, 0, 2, 20, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, .5, Colors.Black);

            document.LastSection.Add(table);
        }
        /// <summary>
        /// Writes the value of the signature to the table as an image.
        /// </summary>
        /// <param name="table">The <see cref="MigraDoc.DocumentObjectModel.Tables.Table"/> to write to.</param>
        /// <param name="control">The control.</param>
        /// <param name="container">The application data container.</param>
        /// <param name="level">The depth down the control tree being rendered (affects indenting).</param>
        private void WriteValueSignature(Table table, SignaturePadControl control, Dictionary<string, object> container, int level)
        {
            Row row = table.AppendRow(this.DefaultStyle.Font.Size, control.Label, string.Empty);
            row.Cells[0].Format.LeftIndent = new Unit(PdfConstants.IndentMultiplier * level, UnitType.Millimeter);

            string controlValue = container[control.Name].ToString();
            if (string.IsNullOrEmpty(controlValue))
            {
                return;
            }

            byte[] encodedBytes = Convert.FromBase64String(controlValue.Split(',')[1]);
            string path = this.GetTemporaryFileName("png");

            using (FileStream stream = new FileStream(path, FileMode.CreateNew))
            {
                SvgToImageConverter converter = new SvgToImageConverter();
                converter.ConvertToImage(encodedBytes, stream, ImageFormat.Png);
            }

            Unit size = this.DefaultStyle.Font.Size * 2;
            Image addedImage = row.Cells[1].AddParagraph().AddImage(path);
            addedImage.LockAspectRatio = true;
            addedImage.Height = size;
            row.Height = size;
        }
 /// <summary>
 /// Writes the value of <paramref name="likert"/> to the <paramref name="table"/>.
 /// </summary>
 /// <param name="table">The <see cref="MigraDoc.DocumentObjectModel.Tables.Table"/> to write to.</param>
 /// <param name="likert">The control.</param>
 /// <param name="container">The application data container.</param>
 /// <param name="level">The depth down the control tree being rendered (affects indenting).</param>
 private void WriteValueLikert(Table table, LikertControl likert, Dictionary<string, object> container, int level)
 {
     Dictionary<string, object> children = (Dictionary<string, object>)container[likert.Name];
     ControlList proxyControlList = likert.ToProxyControlList();
     this.WriteValue(table, proxyControlList, children, level);
 }
Пример #26
0
        private Table SetUpKampftabelle(double randLinksRechts)
        {
            Table table = new Table();

            table.Style               = CustomStyles.TABLE;
            table.Borders.Color       = Colors.Black;
            table.Borders.Width       = 0.25;
            table.Borders.Left.Width  = 0.25;
            table.Borders.Right.Width = 0.25;
            table.Rows.LeftIndent     = 0;

            // Before you can add a row, you must define the columns
            double a4LandscapeBreite = (29.7 - 2 * randLinksRechts);

            double breite_KampfNr        = 0.7;
            double breite_Stilart        = 1.5;
            double breite_Gewichtsklasse = 1.0;
            double breite_IstGewicht     = 1.1;
            double breite_PassNr         = 1.1;
            double breite_Status         = 1.2;
            double breite_Punkte         = 1.0;
            double breite_Siegart        = 2.8;
            double breite_Wertungen      = 3.2;

            double nochUebrig = a4LandscapeBreite - breite_KampfNr - breite_Stilart - breite_Gewichtsklasse - 2 * breite_IstGewicht -
                                2 * breite_PassNr - 2 * breite_Status - 2 * breite_Punkte - breite_Siegart - breite_Wertungen;
            double breite_Name = nochUebrig / 2;

            Column column = table.AddColumn($"{breite_KampfNr}cm");

            column.Format.Alignment = ParagraphAlignment.Right;
            column = table.AddColumn($"{breite_Stilart}cm");
            column.Format.Alignment = ParagraphAlignment.Left;
            column = table.AddColumn($"{breite_Gewichtsklasse}cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_IstGewicht}cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_Name}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn($"{breite_PassNr}cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_Status}cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column = table.AddColumn($"{breite_Punkte}cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Bold = true;

            column = table.AddColumn($"{breite_IstGewicht}cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_Name}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn($"{breite_PassNr}cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_Status}cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_Punkte}cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Bold = true;

            column = table.AddColumn($"{breite_Siegart}cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn($"{breite_Wertungen}cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            return(table);
        }
Пример #27
0
        public Table generate(MannschaftskampfViewModel mannschaftskampfViewModel, CompetitionInfosViewModel zusatzInfos, double randLinksRechts)
        {
            var table = new Table();

            table.Style = CustomStyles.TABLEINFO;

            table.Borders.Visible = false;

            double a4LandscapeBreite = (29.7 - 2 * randLinksRechts) / 3.0;

            Column column = table.AddColumn($"{a4LandscapeBreite - 2}cm");

            column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn($"{a4LandscapeBreite + 4}cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column = table.AddColumn($"{a4LandscapeBreite - 2}cm");
            column.Format.Alignment = ParagraphAlignment.Right;


            Row zeile = table.AddRow();

            var spalte = zeile.Cells[0].AddParagraph();
            var ft     = spalte.AddFormattedText($"{mannschaftskampfViewModel.LigaId} {mannschaftskampfViewModel.TableId}", TextFormat.Bold);

            ft.Font.Size = CustomStyles.fontSizeGross;
            spalte.AddLineBreak();

            ft           = spalte.AddFormattedText($"{Resources.LanguageFiles.DictPluginMain.Location}:");
            ft.Font.Size = CustomStyles.fontSizeKlein;
            ft.Bold      = true;

            spalte.AddLineBreak();
            ft           = spalte.AddFormattedText($"{mannschaftskampfViewModel.Wettkampfstaette.Split(' ').Last()}");
            ft.Font.Size = CustomStyles.fontSizeNormal;

            spalte       = zeile.Cells[1].AddParagraph();
            ft           = spalte.AddFormattedText(zusatzInfos.Kampfart, TextFormat.Bold);
            ft.Font.Size = CustomStyles.fontSizeGross;
            spalte.AddLineBreak();

            ft           = spalte.AddFormattedText($"{Resources.LanguageFiles.DictPluginMain.LocationAddress}:");
            ft.Font.Size = CustomStyles.fontSizeKlein;
            ft.Bold      = true;

            spalte.AddLineBreak();
            ft           = spalte.AddFormattedText($"{mannschaftskampfViewModel.Wettkampfstaette}");
            ft.Font.Size = CustomStyles.fontSizeNormal;

            spalte       = zeile.Cells[2].AddParagraph();
            ft           = spalte.AddFormattedText(zusatzInfos.VorKampfRueckKampf, TextFormat.Bold);
            ft.Font.Size = CustomStyles.fontSizeGross;

            spalte.AddLineBreak();
            ft           = spalte.AddFormattedText($"{Resources.LanguageFiles.DictPluginMain.BoutDate}:");
            ft.Font.Size = CustomStyles.fontSizeKlein;
            ft.Bold      = true;

            spalte.AddLineBreak();
            ft           = spalte.AddFormattedText($"{mannschaftskampfViewModel.Kampfdatum.ToShortDateString()}");
            ft.Font.Size = CustomStyles.fontSizeNormal;

            return(table);
        }
Пример #28
0
 internal TableRenderer(XGraphics gfx, RenderInfo renderInfo, FieldInfos fieldInfos)
     : base(gfx, renderInfo, fieldInfos)
 {
     this.table = (Table)this.renderInfo.DocumentObject;
 }
Пример #29
0
    private void generatePDFFile()
    {
        // Create a MigraDoc document
        Document doc = new Document();

        doc.Info.Title   = "Expenses";
        doc.Info.Subject = "Expenses No:" + oModExpenses.GetSetexpensesno;
        doc.Info.Author  = "B.I.O.App System";

        //set page orientation
        doc.DefaultPageSetup.Orientation    = MigraDoc.DocumentObjectModel.Orientation.Portrait;
        doc.DefaultPageSetup.TopMargin      = "7.5cm"; //120
        doc.DefaultPageSetup.BottomMargin   = "8.5cm"; //150
        doc.DefaultPageSetup.LeftMargin     = 40;
        doc.DefaultPageSetup.RightMargin    = 40;
        doc.DefaultPageSetup.HeaderDistance = "1.5cm"; //20
        doc.DefaultPageSetup.FooterDistance = "5.5cm"; //20

        MigraDoc.DocumentObjectModel.Style style = doc.Styles["Normal"];
        // Because all styles are derived from Normal, the next line changes the
        // font of the whole document. Or, more exactly, it changes the font of
        // all styles and paragraphs that do not redefine the font.
        style.Font.Name = "Verdana";

        // Create a new style called Table based on style Normal
        style           = doc.Styles.AddStyle("Table", "Normal");
        style.Font.Name = "Verdana";
        style.Font.Name = "Arial";
        style.Font.Size = 8;

        // Each MigraDoc document needs at least one section.
        Section section = doc.AddSection();

        // Put Capital Digital logo in the header

        /*
         * string logo_lima = Server.MapPath("~/images/logo_CD_bgBLUE_BLACK_310x98.png");
         * MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(logo_lima);
         * image.Height = "1cm";
         * image.LockAspectRatio = true;
         * image.RelativeVertical = RelativeVertical.Line;
         * image.RelativeHorizontal = RelativeHorizontal.Margin;
         * image.Top = ShapePosition.Top;
         * image.Left = ShapePosition.Right;
         * image.WrapFormat.Style = WrapStyle.Through;
         */
        // Put CD logo in the header

        /*
         * string logo_mod = Server.MapPath("~/images/logo_versi_4.png");
         * MigraDoc.DocumentObjectModel.Shapes.Image image2 = section.Headers.Primary.AddImage(logo_mod);
         * image2.Height = "1.5cm";
         * image2.LockAspectRatio = true;
         * image2.RelativeVertical = RelativeVertical.Line;
         * image2.RelativeHorizontal = RelativeHorizontal.Margin;
         * image2.Top = ShapePosition.Top;
         * image2.Left = ShapePosition.Left;
         * image2.WrapFormat.Style = WrapStyle.Through;
         */

        // Create Header

        Paragraph header2 = section.Headers.Primary.AddParagraph();

        header2.AddText(modCompInfo.GetSetcomp_name);
        header2.Format.Font.Size = 8;
        header2.Format.Font.Bold = true;
        header2.Format.Alignment = ParagraphAlignment.Center;

        Paragraph header3 = section.Headers.Primary.AddParagraph();

        header3.AddText(modCompInfo.GetSetcomp_address);
        header3.Format.Font.Size = 7;
        header3.Format.Font.Bold = false;
        header3.Format.Alignment = ParagraphAlignment.Center;

        header3 = section.Headers.Primary.AddParagraph();
        header3.AddText("website: " + modCompInfo.GetSetcomp_website);
        header3.Format.Font.Size = 7;
        header3.Format.Font.Bold = false;
        header3.Format.Alignment = ParagraphAlignment.Center;

        header3 = section.Headers.Primary.AddParagraph();
        header3.AddText("Tel: " + modCompInfo.GetSetcomp_contactno);
        header3.Format.Font.Size = 7;
        header3.Format.Font.Bold = false;
        header3.Format.Alignment = ParagraphAlignment.Center;

        Paragraph header = section.Headers.Primary.AddParagraph();

        header.AddText("");
        header.Format.Font.Size = 12;
        header.Format.Font.Bold = true;
        header.Format.Alignment = ParagraphAlignment.Center;

        header = section.Headers.Primary.AddParagraph();
        header.AddText("VOUCHER BAYARAN");
        header.Format.Font.Size = 12;
        header.Format.Font.Bold = true;
        header.Format.Alignment = ParagraphAlignment.Center;


        // Create main section for Sales Order
        //Paragraph main = section.AddParagraph();
        // main = section.AddParagraph();
        //main.Format.SpaceBefore = 1;

        // Create the item table for header
        //MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.AddTable();
        MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.Headers.Primary.AddTable();
        tableTop.Style               = "Table";
        tableTop.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tableTop.Borders.Width       = 0.25;
        tableTop.Borders.Left.Width  = 0.5;
        tableTop.Borders.Right.Width = 0.5;
        tableTop.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column columnTop = tableTop.AddColumn("2cm");

        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("7cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("2cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("2cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("5cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;

        Row rowTop = tableTop.AddRow();

        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Bayar Kepada: ");
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph(oModExpenses.GetSetbpdesc);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[2].AddParagraph();
        rowTop.Cells[2].Borders.Left.Visible   = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;
        rowTop.Cells[2].Borders.Bottom.Visible = false;
        rowTop.Cells[3].AddParagraph("No. Bil & Belanja: ");
        rowTop.Cells[3].Borders.Left.Visible   = false;
        rowTop.Cells[3].Borders.Right.Visible  = false;
        rowTop.Cells[3].Borders.Bottom.Visible = false;
        rowTop.Cells[4].AddParagraph(oModExpenses.GetSetexpensesno);
        rowTop.Cells[4].Borders.Left.Visible   = false;
        rowTop.Cells[4].Borders.Right.Visible  = false;
        rowTop.Cells[4].Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph();
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[0].MergeDown = 2;
        rowTop.Cells[1].AddParagraph(oModExpenses.GetSetbpaddress);
        rowTop.Cells[1].AddParagraph(oModExpenses.GetSetbpcontact);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[1].MergeDown = 2;
        rowTop.Cells[2].AddParagraph();
        rowTop.Cells[2].Borders.Left.Visible   = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;
        rowTop.Cells[2].Borders.Bottom.Visible = false;
        rowTop.Cells[2].MergeDown = 2;
        rowTop.Cells[3].AddParagraph("Tarikh: ");
        rowTop.Cells[3].Borders.Left.Visible   = false;
        rowTop.Cells[3].Borders.Right.Visible  = false;
        rowTop.Cells[3].Borders.Bottom.Visible = false;
        rowTop.Cells[4].AddParagraph(oModExpenses.GetSetexpensesdate);
        rowTop.Cells[4].Borders.Left.Visible   = false;
        rowTop.Cells[4].Borders.Right.Visible  = false;
        rowTop.Cells[4].Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[3].AddParagraph("Status: ");
        rowTop.Cells[3].Borders.Left.Visible   = false;
        rowTop.Cells[3].Borders.Right.Visible  = false;
        rowTop.Cells[3].Borders.Bottom.Visible = false;
        rowTop.Cells[4].AddParagraph(oModExpenses.GetSetstatus);
        rowTop.Cells[4].Borders.Left.Visible   = false;
        rowTop.Cells[4].Borders.Right.Visible  = false;
        rowTop.Cells[4].Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Rujukan: ");
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph(oModExpenses.GetSetremarks);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[2].AddParagraph();
        rowTop.Cells[2].Borders.Left.Visible   = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;
        rowTop.Cells[2].Borders.Bottom.Visible = false;
        rowTop.Cells[3].AddParagraph();
        rowTop.Cells[3].Borders.Left.Visible   = false;
        rowTop.Cells[3].Borders.Right.Visible  = false;
        rowTop.Cells[3].Borders.Bottom.Visible = false;
        rowTop.Cells[4].AddParagraph();
        rowTop.Cells[4].Borders.Left.Visible   = false;
        rowTop.Cells[4].Borders.Right.Visible  = false;
        rowTop.Cells[4].Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Jenis Bayaran: ");
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph(oModExpenses.GetSetexpensestype);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[2].AddParagraph();
        rowTop.Cells[2].Borders.Left.Visible   = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;
        rowTop.Cells[2].Borders.Bottom.Visible = false;
        rowTop.Cells[3].AddParagraph("Rujukan:");
        rowTop.Cells[3].Borders.Left.Visible   = false;
        rowTop.Cells[3].Borders.Right.Visible  = false;
        rowTop.Cells[3].Borders.Bottom.Visible = false;
        rowTop.Cells[4].AddParagraph(oModExpenses.GetSetremarks);
        rowTop.Cells[4].Borders.Left.Visible   = false;
        rowTop.Cells[4].Borders.Right.Visible  = false;
        rowTop.Cells[4].Borders.Bottom.Visible = false;

        // Create the item table
        MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
        table.Style               = "Table";
        table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        table.Borders.Width       = 0.25;
        table.Borders.Left.Width  = 0.5;
        table.Borders.Right.Width = 0.5;
        table.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column column = table.AddColumn("1cm");

        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("4.5cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("6cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("1cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("1.5cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        // Create the header of the table
        Row row = table.AddRow();

        row.HeadingFormat    = true;
        row.Format.Alignment = ParagraphAlignment.Center;
        row.Format.Font.Bold = true;
        row.Height           = "1cm";
        row.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.LightGray;
        row.Cells[0].AddParagraph("KETERANGAN ITEM");
        row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
        row.Cells[0].MergeRight        = 2;
        row.Cells[3].AddParagraph("QTY");
        row.Cells[3].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[3].VerticalAlignment = VerticalAlignment.Center;
        row.Cells[4].AddParagraph("HARGA");
        row.Cells[4].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[4].VerticalAlignment = VerticalAlignment.Center;
        row.Cells[5].AddParagraph("TAX");
        row.Cells[5].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[5].VerticalAlignment = VerticalAlignment.Center;
        row.Cells[6].AddParagraph("JUMLAH");
        row.Cells[6].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[6].VerticalAlignment = VerticalAlignment.Center;

        for (int i = 0; i < lsExpensesLineItem.Count; i++)
        {
            MainModel modExpDet = (MainModel)lsExpensesLineItem[i];

            // Each item fills two rows
            Row row1 = table.AddRow();
            row1.Height     = "1cm";
            row1.TopPadding = 1.5;
            //row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row1.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[3].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[4].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[5].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[6].Format.Alignment = ParagraphAlignment.Right;

            row1.Cells[0].AddParagraph((i + 1).ToString());
            if (oModExpenses.GetSetexpensescat.Equals("PAYMENT_VOUCHER"))
            {
                row1.Cells[1].AddParagraph(oMainCon.getParamDetails("000", modExpDet.GetSetitemno, oModExpenses.GetSetexpensestype, "").GetSetparamdesc);
            }
            else
            {
                row1.Cells[1].AddParagraph(modExpDet.GetSetitemno);
            }
            row1.Cells[2].AddParagraph(modExpDet.GetSetitemdesc);
            row1.Cells[3].AddParagraph(modExpDet.GetSetquantity.ToString());
            row1.Cells[4].AddParagraph(modExpDet.GetSetexpensesprice.ToString("#,##0.00"));
            row1.Cells[5].AddParagraph(modExpDet.GetSettaxamount.ToString("#,##0.00"));
            row1.Cells[6].AddParagraph(modExpDet.GetSettotalexpenses.ToString("#,##0.00"));

            if (i > 0 && ((i + 1) % 10) == 0)
            {
                row1.Cells[0].Borders.Bottom.Visible = true;
                row1.Cells[1].Borders.Bottom.Visible = true;
                row1.Cells[2].Borders.Bottom.Visible = true;
                row1.Cells[3].Borders.Bottom.Visible = true;
                row1.Cells[4].Borders.Bottom.Visible = true;
                row1.Cells[5].Borders.Bottom.Visible = true;
                row1.Cells[6].Borders.Bottom.Visible = true;
            }
            else
            {
                row1.Cells[0].Borders.Bottom.Visible = false;
                row1.Cells[1].Borders.Bottom.Visible = false;
                row1.Cells[2].Borders.Bottom.Visible = false;
                row1.Cells[3].Borders.Bottom.Visible = false;
                row1.Cells[4].Borders.Bottom.Visible = false;
                row1.Cells[5].Borders.Bottom.Visible = false;
                row1.Cells[6].Borders.Bottom.Visible = false;
            }
        }
        if ((lsExpensesLineItem.Count % 10) > 0)
        {
            int totalremainingrow = 10 - (lsExpensesLineItem.Count % 10);
            for (int j = 0; j < totalremainingrow; j++)
            {
                Row rowRemain = table.AddRow();
                rowRemain.Height = "1cm";
                rowRemain.Cells[0].AddParagraph();
                rowRemain.Cells[1].AddParagraph();
                rowRemain.Cells[2].AddParagraph();
                rowRemain.Cells[3].AddParagraph();
                rowRemain.Cells[4].AddParagraph();
                rowRemain.Cells[5].AddParagraph();
                rowRemain.Cells[6].AddParagraph();

                if (j == (totalremainingrow - 1))
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                }
                else if (j > 0 && (j % (totalremainingrow - 1)) == 0)
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                }
                else
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = false;
                    rowRemain.Cells[1].Borders.Bottom.Visible = false;
                    rowRemain.Cells[2].Borders.Bottom.Visible = false;
                    rowRemain.Cells[3].Borders.Bottom.Visible = false;
                    rowRemain.Cells[4].Borders.Bottom.Visible = false;
                    rowRemain.Cells[5].Borders.Bottom.Visible = false;
                    rowRemain.Cells[6].Borders.Bottom.Visible = false;
                }
            }
        }

        Row rowTot = table.AddRow();

        rowTot.Height           = "1cm";
        rowTot.Format.Font.Bold = true;
        rowTot.Cells[0].AddParagraph("Catatan:");
        rowTot.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
        rowTot.Cells[0].VerticalAlignment = VerticalAlignment.Top;
        rowTot.Cells[0].MergeRight        = 2;

        rowTot.Cells[3].AddParagraph("JUMLAH BESAR");
        rowTot.Cells[3].Format.Alignment  = ParagraphAlignment.Right;
        rowTot.Cells[3].VerticalAlignment = VerticalAlignment.Center;
        rowTot.Cells[3].MergeRight        = 2;

        rowTot.Cells[6].AddParagraph(oModExpenses.GetSettotalamount.ToString("#,##0.00"));
        rowTot.Cells[6].Format.Alignment  = ParagraphAlignment.Right;
        rowTot.Cells[6].VerticalAlignment = VerticalAlignment.Center;

        //footer.AddText("Footer");
        //footer.Format.Font.Size = 9;
        //footer.Format.Alignment = ParagraphAlignment.Center;

        // Create the item table for footer
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Headers.Primary.AddImage(logo_lima);
        MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Footers.Primary.AddTable();
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.AddTable();
        tblBtm.Style               = "Table";
        tblBtm.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tblBtm.Borders.Width       = 0.25;
        tblBtm.Borders.Left.Width  = 0.5;
        tblBtm.Borders.Right.Width = 0.5;
        tblBtm.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column colTblBtm = tblBtm.AddColumn("6cm");

        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;

        Row rowTblBtm = tblBtm.AddRow();

        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[1].AddParagraph();
        rowTblBtm.Cells[2].AddParagraph();

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Format.Font.Bold = true;
        rowTblBtm.Height           = "1cm";
        rowTblBtm.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.Gray;
        rowTblBtm.Cells[0].AddParagraph("Disediakan Oleh:");
        rowTblBtm.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
        rowTblBtm.Cells[0].VerticalAlignment = VerticalAlignment.Center;
        rowTblBtm.Cells[1].AddParagraph("Disemak Oleh:");
        rowTblBtm.Cells[1].Format.Alignment  = ParagraphAlignment.Left;
        rowTblBtm.Cells[1].VerticalAlignment = VerticalAlignment.Center;
        rowTblBtm.Cells[2].AddParagraph("Diluluskan Oleh:");
        rowTblBtm.Cells[2].Format.Alignment  = ParagraphAlignment.Left;
        rowTblBtm.Cells[2].VerticalAlignment = VerticalAlignment.Center;
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[1].AddParagraph();
        rowTblBtm.Cells[2].AddParagraph();
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm.Height = "2cm";
        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Nama:");
        rowTblBtm.Cells[1].AddParagraph("Nama:");
        rowTblBtm.Cells[2].AddParagraph("Nama:");
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Jawatan:");
        rowTblBtm.Cells[1].AddParagraph("Jawatan:");
        rowTblBtm.Cells[2].AddParagraph("Jawatan:");
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Cells[0].AddParagraph("Tarikh:");
        rowTblBtm.Cells[1].AddParagraph("Tarikh:");
        rowTblBtm.Cells[2].AddParagraph("Tarikh:");
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        // Create a renderer for PDF that uses Unicode font encoding
        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

        // Set the MigraDoc document
        pdfRenderer.Document = doc;

        // Create the PDF document
        pdfRenderer.RenderDocument();

        // Save the document...
        string pdfFilename = sExpensesNo + ".pdf";
        string file        = Server.MapPath("~/App_Data/" + pdfFilename);
        //string file = HttpContext.Current.Server.MapPath("~/pdf/" + pdfFilename);
        //string file = "C:/TEMP/" + pdfFilename;

        // ...and start a viewer //
        //pdfRenderer.Save(file);
        //Process.Start(file);

        // Send PDF to browser //
        MemoryStream stream = new MemoryStream();

        pdfRenderer.Save(stream, false);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        Response.End();

        //download file //
        //Response.ContentType = "Application/pdf";
        //Response.AppendHeader("Content-Disposition", "attachment; filename=" + pdfFilename);
        //Response.TransmitFile(file);
        //Response.End();
    }
Пример #30
0
    private void generatePDFFile()
    {
        // Create a MigraDoc document
        Document doc = new Document();

        doc.Info.Title   = "Pesanan Agihan";
        doc.Info.Subject = "Order No:" + oModOrder.GetSetorderno;
        doc.Info.Author  = "ZMartPartner System";

        //set page orientation
        doc.DefaultPageSetup.Orientation    = MigraDoc.DocumentObjectModel.Orientation.Portrait;
        doc.DefaultPageSetup.TopMargin      = "7.5cm"; //120
        doc.DefaultPageSetup.BottomMargin   = "8.5cm"; //150
        doc.DefaultPageSetup.LeftMargin     = 40;
        doc.DefaultPageSetup.RightMargin    = 40;
        doc.DefaultPageSetup.HeaderDistance = "1.5cm"; //20
        doc.DefaultPageSetup.FooterDistance = "1cm";   //20

        MigraDoc.DocumentObjectModel.Style style = doc.Styles["Normal"];
        // Because all styles are derived from Normal, the next line changes the
        // font of the whole document. Or, more exactly, it changes the font of
        // all styles and paragraphs that do not redefine the font.
        style.Font.Name = "Verdana";

        // Create a new style called Table based on style Normal
        style           = doc.Styles.AddStyle("Table", "Normal");
        style.Font.Name = "Verdana";
        style.Font.Name = "Arial";
        style.Font.Size = 8;

        // Each MigraDoc document needs at least one section.
        Section section = doc.AddSection();

        // Put 1st logo in the header
        string logo_lima = Server.MapPath("~/images/" + modCompInfo.GetSetcomp_logo1);

        MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(logo_lima);
        image.Height             = "1cm";
        image.LockAspectRatio    = true;
        image.RelativeVertical   = RelativeVertical.Line;
        image.RelativeHorizontal = RelativeHorizontal.Margin;
        image.Top              = ShapePosition.Top;
        image.Left             = ShapePosition.Right;
        image.WrapFormat.Style = WrapStyle.Through;

        // Put 2nd logo in the header
        string logo_mod = Server.MapPath("~/images/" + modCompInfo.GetSetcomp_logo2);

        MigraDoc.DocumentObjectModel.Shapes.Image image2 = section.Headers.Primary.AddImage(logo_mod);
        image2.Height             = "1cm";
        image2.LockAspectRatio    = true;
        image2.RelativeVertical   = RelativeVertical.Line;
        image2.RelativeHorizontal = RelativeHorizontal.Margin;
        image2.Top              = ShapePosition.Top;
        image2.Left             = ShapePosition.Left;
        image2.WrapFormat.Style = WrapStyle.Through;

        // Create Header
        Paragraph header = section.Headers.Primary.AddParagraph();

        header.AddText("PESANAN AGIHAN");
        header.Format.Font.Size = 12;
        header.Format.Font.Bold = true;
        header.Format.Alignment = ParagraphAlignment.Center;

        // Create main section for Sales Order
        //Paragraph main = section.AddParagraph();
        // main = section.AddParagraph();
        //main.Format.SpaceBefore = 1;

        // Create the item table for header
        //MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.AddTable();
        MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.Headers.Primary.AddTable();
        tableTop.Style               = "Table";
        tableTop.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tableTop.Borders.Width       = 0.25;
        tableTop.Borders.Left.Width  = 0.5;
        tableTop.Borders.Right.Width = 0.5;
        tableTop.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column columnTop = tableTop.AddColumn("8cm");

        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("3cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("7cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;

        Row rowTop = tableTop.AddRow();

        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible  = false;
        rowTop.Borders.Right.Visible = false;
        rowTop.Borders.Top.Visible   = false;
        //rowTop.Borders.Bottom.Visible = false;
        rowTop.Cells[0].AddParagraph();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph();
        rowTop.Cells[2].AddParagraph();


        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Daripada:");
        rowTop.Cells[0].AddParagraph(modCompInfo.GetSetcomp_name);
        rowTop.Cells[0].AddParagraph(modCompInfo.GetSetcomp_address);
        rowTop.Cells[0].AddParagraph(modCompInfo.GetSetcomp_website);
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[0].MergeDown = 5;
        rowTop.Cells[1].AddParagraph("No. Pesanan");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderno);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Tarikh");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderdate);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Jenis");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetordertype);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Pejabat Agihan");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + modCompInfo.GetSetcomp_name);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Pegawai Agihan");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetusername);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("No. Dihubungi");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + modCompInfo.GetSetcomp_contactno);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("");
        rowTop.Cells[0].MergeRight             = 2;
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Kepada: ");
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpaddress);
        rowTop.Cells[0].AddParagraph("Hubungi: " + oModOrder.GetSetbpcontact);
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("Support: ");
        rowTop.Cells[1].AddParagraph(modCompInfo.GetSetcomp_contact);
        rowTop.Cells[1].AddParagraph("SALES & SUPPORT");
        rowTop.Cells[1].AddParagraph("Hubungi: " + modCompInfo.GetSetcomp_contactno);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[1].MergeRight             = 1;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        // Create the item table
        MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
        table.Style               = "Table";
        table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        table.Borders.Width       = 0.25;
        table.Borders.Left.Width  = 0.5;
        table.Borders.Right.Width = 0.5;
        table.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column column = table.AddColumn("0.5cm");

        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("4cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("1cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("1.5cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        // Create the header of the table
        Row row = table.AddRow();

        row.HeadingFormat    = true;
        row.Format.Alignment = ParagraphAlignment.Center;
        row.Format.Font.Bold = true;
        row.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.LightGray;
        row.Cells[0].AddParagraph("#");
        row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[1].AddParagraph("NO. ITEM");
        row.Cells[1].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[2].AddParagraph("KETERANGAN");
        row.Cells[2].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[2].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[3].AddParagraph("HARGA UNIT");
        row.Cells[3].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[3].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[4].AddParagraph("DISKAUN");
        row.Cells[4].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[4].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[5].AddParagraph("QTY");
        row.Cells[5].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[6].AddParagraph("HARGA");
        row.Cells[6].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[6].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[7].AddParagraph("TAX");
        row.Cells[7].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[7].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[8].AddParagraph("JUMLAH");
        row.Cells[8].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[8].VerticalAlignment = VerticalAlignment.Bottom;

        for (int i = 0; i < lsOrderLineItem.Count; i++)
        {
            MainModel modOrdDet = (MainModel)lsOrderLineItem[i];

            // Each item fills two rows
            Row row1 = table.AddRow();
            row1.Height     = "2cm";
            row1.TopPadding = 1.5;
            //row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row1.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[4].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[5].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[6].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[7].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[8].Format.Alignment = ParagraphAlignment.Right;

            row1.Cells[0].AddParagraph((i + 1).ToString());
            row1.Cells[1].AddParagraph(modOrdDet.GetSetitemno);
            row1.Cells[2].AddParagraph(modOrdDet.GetSetitemdesc);
            row1.Cells[3].AddParagraph(modOrdDet.GetSetunitprice.ToString("#,##0.00"));
            row1.Cells[4].AddParagraph(modOrdDet.GetSetdiscamount.ToString("#,##0.00"));
            row1.Cells[5].AddParagraph(modOrdDet.GetSetquantity.ToString());
            row1.Cells[6].AddParagraph(modOrdDet.GetSetorderprice.ToString("#,##0.00"));
            row1.Cells[7].AddParagraph(modOrdDet.GetSettaxamount.ToString("#,##0.00"));
            row1.Cells[8].AddParagraph(modOrdDet.GetSettotalprice.ToString("#,##0.00"));

            if (i > 0 && ((i + 1) % 6) == 0)
            {
                row1.Cells[0].Borders.Bottom.Visible = true;
                row1.Cells[1].Borders.Bottom.Visible = true;
                row1.Cells[2].Borders.Bottom.Visible = true;
                row1.Cells[3].Borders.Bottom.Visible = true;
                row1.Cells[4].Borders.Bottom.Visible = true;
                row1.Cells[5].Borders.Bottom.Visible = true;
                row1.Cells[6].Borders.Bottom.Visible = true;
                row1.Cells[7].Borders.Bottom.Visible = true;
                row1.Cells[8].Borders.Bottom.Visible = true;
            }
            else
            {
                row1.Cells[0].Borders.Bottom.Visible = false;
                row1.Cells[1].Borders.Bottom.Visible = false;
                row1.Cells[2].Borders.Bottom.Visible = false;
                row1.Cells[3].Borders.Bottom.Visible = false;
                row1.Cells[4].Borders.Bottom.Visible = false;
                row1.Cells[5].Borders.Bottom.Visible = false;
                row1.Cells[6].Borders.Bottom.Visible = false;
                row1.Cells[7].Borders.Bottom.Visible = false;
                row1.Cells[8].Borders.Bottom.Visible = false;
            }
        }
        if ((lsOrderLineItem.Count % 6) > 0)
        {
            int totalremainingrow = 6 - (lsOrderLineItem.Count % 6);
            for (int j = 0; j < totalremainingrow; j++)
            {
                Row rowRemain = table.AddRow();
                rowRemain.Height = "2cm";
                rowRemain.Cells[0].AddParagraph();
                rowRemain.Cells[1].AddParagraph();
                rowRemain.Cells[2].AddParagraph();
                rowRemain.Cells[3].AddParagraph();
                rowRemain.Cells[4].AddParagraph();
                rowRemain.Cells[5].AddParagraph();
                rowRemain.Cells[6].AddParagraph();
                rowRemain.Cells[7].AddParagraph();
                rowRemain.Cells[8].AddParagraph();

                if (j == (totalremainingrow - 1))
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else if (j > 0 && (j % (totalremainingrow - 1)) == 0)
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = false;
                    rowRemain.Cells[1].Borders.Bottom.Visible = false;
                    rowRemain.Cells[2].Borders.Bottom.Visible = false;
                    rowRemain.Cells[3].Borders.Bottom.Visible = false;
                    rowRemain.Cells[4].Borders.Bottom.Visible = false;
                    rowRemain.Cells[5].Borders.Bottom.Visible = false;
                    rowRemain.Cells[6].Borders.Bottom.Visible = false;
                    rowRemain.Cells[7].Borders.Bottom.Visible = false;
                    rowRemain.Cells[8].Borders.Bottom.Visible = false;
                }
            }
        }

        /*
         * Row rowTax = table.AddRow();
         * //rowTax.Height = "1cm";
         * rowTax.Cells[0].AddParagraph();
         * rowTax.Cells[0].Borders.Left.Visible = false;
         * rowTax.Cells[0].Borders.Right.Visible = false;
         * rowTax.Cells[0].Borders.Bottom.Visible = false;
         * rowTax.Cells[0].MergeRight = 6;
         * rowTax.Cells[7].AddParagraph("TAX");
         * rowTax.Cells[7].Format.Alignment = ParagraphAlignment.Left;
         * rowTax.Cells[8].AddParagraph(oModOrder.GetSettaxamount.ToString("#,##0.00"));
         * rowTax.Cells[8].Format.Alignment = ParagraphAlignment.Right;
         */

        Row rowTot = table.AddRow();

        rowTot.Height           = "1cm";
        rowTot.Format.Font.Bold = true;
        rowTot.Cells[0].AddParagraph();
        rowTot.Cells[0].Borders.Left.Visible   = false;
        rowTot.Cells[0].Borders.Right.Visible  = false;
        rowTot.Cells[0].Borders.Bottom.Visible = false;
        rowTot.Cells[0].MergeRight             = 6;

        /*
         * rowTot.Cells[1].AddParagraph();
         * rowTot.Cells[1].Borders.Left.Visible = false;
         * rowTot.Cells[2].AddParagraph();
         * rowTot.Cells[2].Borders.Left.Visible = false;
         * rowTot.Cells[3].AddParagraph();
         * rowTot.Cells[3].Borders.Left.Visible = false;
         * rowTot.Cells[4].AddParagraph();
         * rowTot.Cells[4].Borders.Left.Visible = false;
         * rowTot.Cells[5].AddParagraph();
         * rowTot.Cells[5].Borders.Left.Visible = false;
         * rowTot.Cells[6].AddParagraph();
         * rowTot.Cells[6].Borders.Left.Visible = false;
         */
        rowTot.Cells[6].Borders.Right.Visible = false;

        rowTot.Cells[7].AddParagraph("JUMLAH BESAR");
        rowTot.Cells[7].Format.Alignment     = ParagraphAlignment.Left;
        rowTot.Cells[7].VerticalAlignment    = VerticalAlignment.Center;
        rowTot.Cells[7].Borders.Left.Visible = false;
        //rowTot.Cells[7].Borders.Right.Visible = false;
        rowTot.Cells[7].Borders.Bottom.Visible = false;

        rowTot.Cells[8].AddParagraph(oModOrder.GetSettotalamount.ToString("#,##0.00"));
        rowTot.Cells[8].Format.Alignment  = ParagraphAlignment.Right;
        rowTot.Cells[8].VerticalAlignment = VerticalAlignment.Center;

        //footer.AddText("Footer");
        //footer.Format.Font.Size = 9;
        //footer.Format.Alignment = ParagraphAlignment.Center;

        // Create the item table for footer
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Headers.Primary.AddImage(logo_lima);
        MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Footers.Primary.AddTable();
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.AddTable();
        tblBtm.Style               = "Table";
        tblBtm.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tblBtm.Borders.Width       = 0.25;
        tblBtm.Borders.Left.Width  = 0.5;
        tblBtm.Borders.Right.Width = 0.5;
        tblBtm.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column colTblBtm = tblBtm.AddColumn("6cm");

        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;

        Row rowTblBtm = tblBtm.AddRow();

        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Catatan:");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        //rowTblBtm.Borders.Top.Visible = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetorderremarks);
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Height = "2cm";
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("1. Setelah Pesanan Agihan disahkan, sebarang pembatalan dan perubahan pesanan tidak dibenarkan.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("2. Penghantaran item Pesanan Agihan akan dilakukan setelah menerima pengesahan daripada Pejabat Agihan.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("3. Perubahan pada harga item Pesanan Agihan adalah tertakluk kepada terma & syarat tanpa sebarang notis.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 1;
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Format.Font.Bold = true;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        //rowTblBtm.Cells[0].Borders.Top.Visible = true;
        rowTblBtm.Cells[1].AddParagraph(modCompInfo.GetSetcomp_name);
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Disahkan Oleh: (Cop dan Tandatangan)");
        rowTblBtm.Cells[1].AddParagraph("Disemak Oleh:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible          = false;
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm.Height = "2cm";
        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Nama:");
        rowTblBtm.Cells[1].AddParagraph("Nama:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Jawatan:");
        rowTblBtm.Cells[1].AddParagraph("Jawatan: Pegawai Agihan & Pemasaran");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Cells[0].AddParagraph("Tarikh:");
        rowTblBtm.Cells[1].AddParagraph("Tarikh:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        // Create a renderer for PDF that uses Unicode font encoding
        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

        // Set the MigraDoc document
        pdfRenderer.Document = doc;

        // Create the PDF document
        pdfRenderer.RenderDocument();

        // Save the document...
        string pdfFilename = sOrderNo + ".pdf";
        string file        = Server.MapPath("~/App_Data/" + pdfFilename);
        //string file = HttpContext.Current.Server.MapPath("~/pdf/" + pdfFilename);
        //string file = "C:/TEMP/" + pdfFilename;

        // ...and start a viewer //
        //pdfRenderer.Save(file);
        //Process.Start(file);

        // Send PDF to browser //
        MemoryStream stream = new MemoryStream();

        pdfRenderer.Save(stream, false);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        Response.End();

        //download file //
        //Response.ContentType = "Application/pdf";
        //Response.AppendHeader("Content-Disposition", "attachment; filename=" + pdfFilename);
        //Response.TransmitFile(file);
        //Response.End();
    }
Пример #31
0
        private void AddCell(
            IPdfStyling pdfStyling,
            MigraDoc.DocumentObjectModel.Tables.Table table,
            PdfTableRow pdfRow,
            bool isTFoot)
        {
            // Each item fills one row
            Row row = table.AddRow();

            row.TopPadding = Unit.FromPoint(5);
            //row.BottomPadding = Unit.FromPoint(2);

            IPdfTableCell pdfCell;
            int           pdfCellIndex, pdfCellIndexWithColspan;

            for (int j = 0; j < pdfRow.Cells.Count; j++)
            {
                pdfCellIndex            = j;
                pdfCellIndexWithColspan = pdfCellIndex;
                pdfCell = pdfRow.Cells[j];

                if (pdfCellIndex > 0)
                {
                    // If we have a colspan we have to update the index
                    // http://www.pdfsharp.net/wiki/invoice-sample.ashx
                    for (int y = 0; y < pdfCellIndex; y++)
                    {
                        if (pdfRow.Cells[y].Colspan > 1)
                        {
                            pdfCellIndexWithColspan += pdfRow.Cells[y].Colspan - 1;
                        }
                    }
                }

                AddText(
                    pdfStyling: pdfStyling,
                    pdfCell: pdfCell,
                    cell: row.Cells[pdfCellIndexWithColspan]);

                row.Cells[pdfCellIndexWithColspan].VerticalAlignment = VerticalAlignment.Top;

                if (pdfCell.Alignment != Alignment.Inherit)
                {
                    row.Cells[pdfCellIndexWithColspan].Format.Alignment = pdfCell.Alignment.GetAlignment();
                }

                if (pdfCell.Colspan > 1)
                {
                    row.Cells[pdfCellIndexWithColspan].MergeRight = pdfCell.Colspan - 1;
                }

                if (isTFoot)
                {
                    row.Cells[pdfCellIndexWithColspan].Style = PdfStyleNames.Table.TFoot;
                }
                else
                {
                    row.Cells[pdfCellIndexWithColspan].Style = PdfStyleNames.Table.TBody;
                }
            }
        }
Пример #32
0
        private MigraDoc.DocumentObjectModel.Tables.Table AddTable(IPdfStyling pdfStyling, Section section)
        {
            // This is a little bit faky, otherwise we can't add spaces before and after table
            if (this._spaceBefore > 0 || this._spaceAfter > 0)
            {
                IPdfElement pdfSpace = new PdfSpace(this._spaceBefore, this._spaceAfter);
                pdfSpace.Render(pdfStyling: pdfStyling, section: section);
            }

            // Add table to the section
            MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();

            // This is a little bit faky, otherwise we can't add spaces before and after table
            if (this._spaceBefore > 0 || this._spaceAfter > 0)
            {
                IPdfElement pdfSpace = new PdfSpace(this._spaceBefore, this._spaceAfter);
                pdfSpace.Render(pdfStyling: pdfStyling, section: section);
            }

            //THead (and Columns)

            // Calculate widths if necessary
            double[] widths = TableExtensions.CalculateColumnWidths(
                pdfStyling: pdfStyling,
                document: section.Document,
                tHead: this.THead,
                tBody: this.TBody,
                fitToDocument: _fitToDocument);

            // Create columns from THead
            Column column;

            for (int c = 0; c < this.THead.Count; c++)
            {
                column = table.AddColumn(new Unit(widths[c]));
                column.Format.Alignment = this.THead[c].Alignment.GetAlignment();
            }

            // Create the header of the table
            Row thead;

            if (this.THead.Any(o => string.IsNullOrWhiteSpace(o.Text.Trim())) == false)
            {
                //HINT: If an error appears here because you did not added PdfTableHeaderCells -> you have to add but with empty strings :-)
                thead            = table.AddRow();
                thead.TopPadding = Unit.FromPoint(5);
                //titleRow.BottomPadding = Unit.FromPoint(5);
                thead.HeadingFormat = true;

                for (int i = 0; i < this.THead.Count; i++)
                {
                    AddText(
                        pdfStyling: pdfStyling,
                        pdfCell: this.THead[i],
                        cell: thead.Cells[i]);

                    thead.Cells[i].VerticalAlignment = VerticalAlignment.Top;
                    thead.Cells[i].Style             = PdfStyleNames.Table.THead;
                }
            }

            //TBody

            for (int i = 0; i < this.TBody.Count; i++)
            {
                AddCell(
                    pdfStyling: pdfStyling,
                    table: table,
                    pdfRow: this.TBody[i],
                    isTFoot: false);
            }

            //TFoot

            for (int i = 0; i < this.TFoot.Count; i++)
            {
                AddCell(
                    pdfStyling: pdfStyling,
                    table: table,
                    pdfRow: this.TFoot[i],
                    isTFoot: true);
            }

            return(table);
        }
Пример #33
0
 internal TableRenderer(XGraphics gfx, Table documentObject, FieldInfos fieldInfos)
   :
   base(gfx, documentObject, fieldInfos)
 {
   this.table = (Table)documentObject;
 }
Пример #34
0
        private void RightSide(IPdfStyling pdfStyling, Section section)
        {
            MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();

            table.TopPadding    = 0;
            table.RightPadding  = 0;
            table.BottomPadding = 0;
            table.LeftPadding   = 0;
            table.Borders.Width = 0;

            table.Rows.LeftIndent = GetTableIndent(pdfStyling);
            table.AddColumn(_tableLeftWidth);
            table.AddColumn(_tableRightWidth);

            Row row = table.AddRow();

            Cell header = row.Cells[0];

            header.MergeRight = 1;

            Paragraph logoWrapper = header.AddParagraph();

            logoWrapper.Format.Alignment = ParagraphAlignment.Center;

            Image logo = logoWrapper.AddImage(@"D:\DEVELOPMENT\GIT\OPTEN Solutions\tests\Opten.Web.Infrastructure.Pdf.Test\Images\logo_rimuss_secco.jpg");

            logo.LockAspectRatio           = true;
            logo.Height                    = Unit.FromMillimeter(18);
            logoWrapper.Format.SpaceBefore = 0;
            logoWrapper.Format.SpaceAfter  = Unit.FromCentimeter(1);

            Paragraph h1 = header.AddParagraph();

            h1.AddText("WINTER-BOWLE");
            h1.Format.Font.Size = 16;
            //h1.Format.Font.Bold = true;
            h1.Format.SpaceBefore = 0;
            h1.Format.SpaceAfter  = Unit.FromCentimeter(0.5);
            h1.Format.Alignment   = ParagraphAlignment.Center;

            h1.AddBookmark("Receipt1");
            h1.Format.OutlineLevel = OutlineLevel.Level1;

            TextFrame pWrapper = header.AddTextFrame();

            pWrapper.Height = Unit.FromCentimeter(1);
            pWrapper.Width  = _leftSideWidth;
            Paragraph p = pWrapper.AddParagraph();

            p.Format.Font.Color      = pdfStyling.ParagraphSmallColor;
            p.Format.LineSpacing     = Unit.FromCentimeter(0.5);
            p.Format.LineSpacingRule = LineSpacingRule.AtLeast;
            p.Format.SpaceAfter      = Unit.FromCentimeter(-0.25);        // Line spacing
            p.AddText("Warum eigentlich eine Fruchtbowle nur im Sommer geniessen?\nDiese Bowleiessen?\nDiese Bowle verhilft auch an kalten und unliessen?\nDiese Bowle verhilft auch an kalten und unl verhilft auch an kalten und unlustigen Winterabenden zu\neiner beschwingten Leichtigkeit.");
            p.Format.Alignment = ParagraphAlignment.Center;

            HorizontalRule(pdfStyling, header);

            Paragraph h2 = header.AddParagraph();

            h2.AddText("ZUBEREITUNG FÜR 1 GLAS");
            h2.Format.Font.Size   = 12;
            h2.Format.SpaceBefore = 0;
            h2.Format.SpaceAfter  = Unit.FromCentimeter(0.5);
            h2.Format.LeftIndent  = Unit.FromCentimeter(1);
            h2.Format.Alignment   = ParagraphAlignment.Left;

            IDictionary <string, string> rows = new Dictionary <string, string> {
                { "frische Babyananas", "1" },
                { "Kiwi", "1" },
                { "Clementine, alle Früchte schneiden", "1" },
                { "Zitrone, Saft", "1" },
                { "Esslöffel Zucker, ales mischen", "1" },
                { "Secco dazugiessen, zugedeckt", "7 dl" },
                { "kühl stellen", "ca. 1 Std." },
                { "kaltes Mineralwasser kurz vor dem Servieren dazugiessen", "3 dl" }
            };

            Table(pdfStyling, table, rows);

            row = table.AddRow();

            Cell bottom = row.Cells[0];

            bottom.MergeRight = 1;

            Paragraph small = bottom.AddParagraph();

            small.AddText("Deko: 1 Schnitz Grapefruit");
            small.Format.SpaceBefore = Unit.FromCentimeter(0.5);
            small.Format.SpaceAfter  = 0;
            small.Format.LeftIndent  = Unit.FromCentimeter(1);
            small.Format.Font.Size   = 10;
            small.Format.Font.Color  = pdfStyling.ParagraphSmallColor;
            small.Format.Alignment   = ParagraphAlignment.Left;

            HorizontalRule(pdfStyling, bottom);
        }
Пример #35
0
        private void GenerateSeatingPDF(string file)
        {
            StreamReader File = new StreamReader(file);
            Document document = new Document();
            document.Info.Title = "Seating Arrangement";
            document.Info.Subject = "Seating Arrangement";
            document.Info.Author = "BPHC-Instruction Division";
            getStyles(document);

            Section section = document.AddSection();
            section.PageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Portrait;
            section.PageSetup.TopMargin = Unit.FromCentimeter(4.0);
            section.PageSetup.BottomMargin = Unit.FromCentimeter(1);
            HeaderFooter header = section.Headers.Primary;
            MigraDoc.DocumentObjectModel.Shapes.Image image = header.AddImage(txtImageFile.Text);
            image.Width = Unit.FromCentimeter(15);
            Table table = new Table();
            Column column = table.AddColumn(Unit.FromCentimeter(2.3)); 
            table.AddColumn(Unit.FromCentimeter(2.4)).Format.Alignment = ParagraphAlignment.Center;
            table.AddColumn(Unit.FromCentimeter(2.4)).Format.Alignment = ParagraphAlignment.Center;
            table.AddColumn(Unit.FromCentimeter(1.3)).Format.Alignment = ParagraphAlignment.Center;
            table.AddColumn(Unit.FromCentimeter(2)).Format.Alignment = ParagraphAlignment.Center;
            table.AddColumn(Unit.FromCentimeter(3)).Format.Alignment = ParagraphAlignment.Center;
            table.AddColumn(Unit.FromCentimeter(3)).Format.Alignment = ParagraphAlignment.Center;
            table.Borders.Width = 0.75;
            Row row = table.AddRow();row.HeadingFormat = true;
            row.Shading.Color = MigraDoc.DocumentObjectModel.Colors.PaleGoldenrod;
            Cell cell = row.Cells[0];
            cell.AddParagraph("COURSE CODE");
            cell = row.Cells[1];
            cell.AddParagraph("DATE");
            cell = row.Cells[2];
            cell.AddParagraph("TIME");
            cell = row.Cells[3];
            cell.AddParagraph("ROOM NO");
            cell = row.Cells[4];
            cell.AddParagraph("STRENGTH");
            cell = row.Cells[5];
            cell.AddParagraph("IDs FROM");
            cell = row.Cells[6];
            cell.AddParagraph("IDs TO");
            string line = "";
            File.ReadLine();
            while ((line = File.ReadLine()) != null)
            {
                string[] ar1 = line.Split(',');
                if (line.StartsWith(",,,"))
                {
                    row = table.AddRow();
                    cell = row.Cells[3];
                    cell.AddParagraph(ar1[3]);
                    cell = row.Cells[4];
                    cell.AddParagraph(ar1[4]);
                    cell = row.Cells[5];
                    cell.AddParagraph(ar1[5]);
                    cell = row.Cells[6];
                    cell.AddParagraph(ar1[6]);
                }
                else if (ar1.Length == 7)
                {
                    row = table.AddRow(); 
                    cell = row.Cells[0];
                    cell.AddParagraph(ar1[0]);
                    cell = row.Cells[1];
                    cell.AddParagraph((ar1[1]+", "+ar1[2]).Replace("\"",""));
                    cell = row.Cells[2];
                    cell.AddParagraph(ar1[3]);
                    cell = row.Cells[3];
                    cell.AddParagraph(ar1[4]);
                    cell = row.Cells[4];
                    cell.AddParagraph(ar1[5]);
                    cell = row.Cells[5];
                    cell.AddParagraph(ar1[6]);
                    cell.MergeRight = 1;
                }
                else if (ar1.Length == 8)
                {
                    row = table.AddRow(); 
                    cell = row.Cells[0];
                    cell.AddParagraph(ar1[0]);
                    cell = row.Cells[1];
                    cell.AddParagraph((ar1[1] + ", " + ar1[2]).Replace("\"", ""));
                    cell = row.Cells[2];
                    cell.AddParagraph(ar1[3]);
                    cell = row.Cells[3];
                    cell.AddParagraph(ar1[4]);
                    cell = row.Cells[4];
                    cell.AddParagraph(ar1[5]);
                    cell = row.Cells[5];
                    cell.AddParagraph(ar1[6]);
                    cell = row.Cells[6];
                    cell.AddParagraph(ar1[7]);
                }
            }
            section.Add(table);
            MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl");
            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
            renderer.Document = document;
            renderer.RenderDocument();
            // Save the document...
            string filename = WorkingFolder + "/SEATING ARRANGEMENT.pdf";
            renderer.PdfDocument.Save(filename);
            Process.Start(filename);
            txtStatus.Text = "Student Seating Arrangement: " + file + Environment.NewLine + "Student Seating Arrangement: " + WorkingFolder + "/SEATING ARRANGEMENT.pdf";

        }
Пример #36
0
        /// <summary>
        /// Write the specified table to the TextWriter.
        /// </summary>
        /// <param name="writer">The writer to write to</param>
        /// <param name="table">The table to write</param>
        /// <param name="outtype">Indicates the format to be produced</param>
        /// <param name="className">The class name of the generated html table</param>
        /// <param name="document">Document object if using MigraDoc to generate output, null otherwise </param>
        private static void WriteTable(TextWriter writer, DataTable table, OutputType outtype, string className, Document document)
        {
            bool showHeadings = className != "PropertyTable";

            if (outtype == OutputType.html)
            {
                if (showHeadings)
                {
                    writer.WriteLine("<table class='headered'>");
                    writer.Write("<tr>");
                    for (int i = 0; i < table.Columns.Count; i++)
                    {
                        writer.Write("<th");
                        if (i == 0)
                        {
                            writer.Write(" class='col1'");
                        }
                        writer.Write(">" + table.Columns[i].ColumnName + "</th>");
                    }
                }
                else
                {
                    writer.WriteLine("<table>");
                }

                foreach (DataRow row in table.Rows)
                {
                    bool titleRow = Convert.IsDBNull(row[0]);
                    if (titleRow)
                    {
                        writer.Write("<tr class='total'>");
                    }
                    else
                    {
                        writer.Write("<tr>");
                    }

                    for (int i = 0; i < table.Columns.Count; i++)
                    {
                        string st;
                        if (titleRow && i == 0)
                        {
                            st = "Total";
                        }
                        else
                        {
                            st = row[i].ToString();
                        }

                        writer.Write("<td");
                        if (i == 0)
                        {
                            writer.Write(" class='col1'");
                        }
                        writer.Write(">");
                        writer.Write(st);
                        writer.Write("</td>");
                    }
                    writer.WriteLine("</tr>");
                }
                writer.WriteLine("</table><br/>");
            }
            else if (outtype == OutputType.rtf)
            {
                MigraDoc.DocumentObjectModel.Tables.Table tabl = new MigraDoc.DocumentObjectModel.Tables.Table();
                tabl.Borders.Width = 0.75;

                foreach (DataColumn col in table.Columns)
                {
                    Column column = tabl.AddColumn(Unit.FromCentimeter(18.0 / table.Columns.Count));
                }

                if (showHeadings)
                {
                    MigraDoc.DocumentObjectModel.Tables.Row row = tabl.AddRow();
                    row.Shading.Color  = Colors.PaleGoldenrod;
                    tabl.Shading.Color = new Color(245, 245, 255);
                    for (int i = 0; i < table.Columns.Count; i++)
                    {
                        Cell      cell      = row.Cells[i];
                        Paragraph paragraph = cell.AddParagraph();
                        if (i == 0)
                        {
                            paragraph.Format.Alignment = ParagraphAlignment.Left;
                        }
                        else
                        {
                            paragraph.Format.Alignment = ParagraphAlignment.Right;
                        }
                        paragraph.AddText(table.Columns[i].ColumnName);
                    }
                }

                foreach (DataRow row in table.Rows)
                {
                    bool   titleRow = Convert.IsDBNull(row[0]);
                    string st;
                    MigraDoc.DocumentObjectModel.Tables.Row newRow = tabl.AddRow();

                    for (int i = 0; i < table.Columns.Count; i++)
                    {
                        if (titleRow && i == 0)
                        {
                            st = "Total";
                            newRow.Format.Font.Color = Colors.DarkOrange;
                            newRow.Format.Font.Bold  = true;
                        }
                        else
                        {
                            st = row[i].ToString();
                        }

                        Cell      cell      = newRow.Cells[i];
                        Paragraph paragraph = cell.AddParagraph();
                        if (!showHeadings)
                        {
                            cell.Borders.Style         = BorderStyle.None;
                            paragraph.Format.Alignment = ParagraphAlignment.Left;
                        }
                        else if (i == 0)
                        {
                            paragraph.Format.Alignment = ParagraphAlignment.Left;
                        }
                        else
                        {
                            paragraph.Format.Alignment = ParagraphAlignment.Right;
                        }

                        if (showHeadings && i == 0)
                        {
                            paragraph.AddFormattedText(st, TextFormat.Bold);
                        }
                        else
                        {
                            paragraph.AddText(st);
                        }
                    }
                }

                document.LastSection.Add(tabl);
                document.LastSection.AddParagraph(); // Just to give a bit of spacing
            }
            else
            {
                DataTableUtilities.DataTableToText(table, 0, "  ", showHeadings, writer);
            }
        }
Пример #37
0
        private void backgroundInviTask()
        {
            if (WorkingFolder.Equals(""))
            {
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                DialogResult result = fbd.ShowDialog();
                WorkingFolder = fbd.SelectedPath;
            }
            string file = txtInvigilatorsFile.Text;
            StreamReader File1 = new StreamReader(file);
            Directory.CreateDirectory(WorkingFolder + "/Invigilations");
            StreamWriter writer1 = new StreamWriter(WorkingFolder + "/InvigilatorEmails.csv");
            StreamWriter writer = new StreamWriter(WorkingFolder + "/Invigilators2.csv");
            StreamWriter writer2 = new StreamWriter(WorkingFolder + "/Invigilators.id");
            string line = "";
            List<string> lines = new List<string>();
            try
            {
                string s = "", s1 = "";
                while ((line = File1.ReadLine()) != null)
                {
                    if (line.StartsWith("Instructor-in-charge  Prof./ Dr./ Mr./ Ms. "))
                    {
                        s = s1 + s;
                        lines.Add(s); s = ""; s1 = line;
                    }
                    else
                    {
                        s += line + "\n";
                    }
                }
                int x = 0;
                foreach (string st in lines)
                {
                    if (x != 0)
                    {
                        s = ""; s1 = "";
                        string[] arr = st.Split('\n');
                        string Name = arr[0].Substring(44, arr[0].IndexOf(',') - 44);
                        writer1.WriteLine(Name);
                        Document document = new Document();
                        document.Info.Title = Name;
                        document.Info.Subject = "Details of rooms and invigilators for your course(s)";
                        document.Info.Author = "BPHC-Instruction Division";
                        getStyles(document);

                        Section section = document.AddSection();
                        section.PageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape;
                        Paragraph paragraph = section.AddParagraph("BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE-PILANI, HYDERABAD CAMPUS", "Heading1");
                        paragraph.Format.Alignment = ParagraphAlignment.Center;
                        paragraph = section.AddParagraph("INSTRUCTION DIVISION", "Heading1");
                        paragraph.Format.Alignment = ParagraphAlignment.Center;
                        paragraph = section.AddParagraph("FIRST SEMESTER 2015-2016", "Heading2");
                        paragraph.Format.Alignment = ParagraphAlignment.Center;
                        section.AddParagraph(arr[0].Replace(",", " "), "Heading2");
                        section.AddParagraph("Details of rooms and invigilators for your course(s):", "Heading2");
                        Table table = new Table();
                        Column column = table.AddColumn(Unit.FromCentimeter(1.3));column.Format.Alignment = ParagraphAlignment.Center;
                        table.AddColumn(Unit.FromCentimeter(2)).Format.Alignment = ParagraphAlignment.Center;
                        table.AddColumn(Unit.FromCentimeter(4)).Format.Alignment = ParagraphAlignment.Center;
                        table.AddColumn(Unit.FromCentimeter(2)).Format.Alignment = ParagraphAlignment.Center;
                        table.AddColumn(Unit.FromCentimeter(2.5)).Format.Alignment = ParagraphAlignment.Center;
                        table.AddColumn(Unit.FromCentimeter(4)).Format.Alignment = ParagraphAlignment.Center;
                        table.AddColumn(Unit.FromCentimeter(6)).Format.Alignment = ParagraphAlignment.Center;
                        table.AddColumn(Unit.FromCentimeter(2)).Format.Alignment = ParagraphAlignment.Center;
                        table.Borders.Width = 0.75;
                        Row row = table.AddRow();
                        row.Shading.Color = MigraDoc.DocumentObjectModel.Colors.PaleGoldenrod;
                        Cell cell = row.Cells[0];
                        cell.AddParagraph("CODE");
                        cell = row.Cells[1];
                        cell.AddParagraph("COURSE NO");
                        cell = row.Cells[2];
                        cell.AddParagraph("COURSE TITLE");
                        cell = row.Cells[3];
                        cell.AddParagraph("DATE");
                        cell = row.Cells[4];
                        cell.AddParagraph("TIME");
                        cell = row.Cells[5];
                        cell.AddParagraph("ROOM");
                        cell = row.Cells[6];
                        cell.AddParagraph("INVIGILATOR");
                        cell = row.Cells[7];
                        cell.AddParagraph("GROUP");

                        writer.WriteLine(arr[0]);
                        List<string> lines1 = new List<string>();

                        for (int i = 6; i < arr.Length; i += 3)
                        {
                            while (arr[i].Equals(",,,,,,,,,,,,,,,,,,,,,")) { i++; }
                            if (arr[i].StartsWith("\"1. In courses with less strength"))
                            {
                                s = s1 + s;
                                if (!s1.Equals(""))
                                    lines1.Add(s);
                                s = ""; s1 = "";
                                break;
                            }
                            if (arr[i].StartsWith(",,,,,,,,,,,,,,,")) s += arr[i] + "\n";
                            else
                            {
                                s = s1 + s;
                                if (!s1.Equals(""))
                                    lines1.Add(s);
                                s = "";
                                if (arr[i].StartsWith("\""))
                                {
                                    s1 = arr[i][1] + "" + arr[i][3] + "" + arr[i][4] + "" + arr[i][5] + arr[i].Substring(7) + "\n";
                                }
                                else
                                    s1 = arr[i] + "\n";
                            }
                        }
                        foreach (string str in lines1)
                        {
                            writer.WriteLine(str);
                            string[] ard = str.Split('\n');
                            int xd = 0;
                            string line1 = "";
                            foreach (string xc in ard)
                            {
                                string[] ds = xc.Split(',');
                                if (ds.Length < 13)
                                { continue; }
                                if (xd == 0)
                                {
                                    row = table.AddRow();
                                    cell = row.Cells[0];
                                    cell.AddParagraph(ds[0]);
                                    cell = row.Cells[1];
                                    cell.AddParagraph(ds[2] + " " + ds[3]);
                                    cell = row.Cells[2];
                                    cell.AddParagraph(ds[5]);
                                    cell = row.Cells[3];
                                    if (ds[7].IndexOf('\"') == -1) { int lh = xc.IndexOf(ds[8]);
                                        string ab = xc.Substring(lh);
                                        string bc = xc.Substring(0, lh);
                                        ds = (bc + "," + ab).Split(',');
                                    }
                                    cell.AddParagraph((ds[7]+","+ds[8]).Replace("\"", ""));
                                    cell = row.Cells[4];
                                    cell.AddParagraph(ds[9]);
                                    line1 += ds[2] + " " + ds[3] + ","+ ds[5] + ","+ (ds[7] + "," + ds[8]).Replace("\"", "") + ","+ ds[9].Replace(" ","") + ",";
                                    if (ds[12].StartsWith("\""))
                                    {
                                        int ld = xc.IndexOf(ds[12]);
                                        string rooms = xc.Substring(ld + 1, xc.IndexOf('\"', ld + 2) - ld - 1);
                                        cell = row.Cells[5];
                                        cell.AddParagraph(rooms);
                                        //line1 += rooms.Replace(',','|')+",";
                                    }
                                    else
                                    {
                                        cell = row.Cells[5];
                                        cell.AddParagraph(ds[12]);
                                        //line1 +=  ds[12] + ",";
                                    }
                                    int lc = ds.Length;
                                    cell = row.Cells[6];
                                    cell.AddParagraph(ds[lc - 7]);
                                    cell = row.Cells[7];
                                    cell.AddParagraph(ds[lc - 3]);
                                    line1 += ds[lc - 7] + ":";//+ ds[lc - 3]+"|";
                                    xd++;
                                }
                                else
                                {
                                    row = table.AddRow();
                                    cell = row.Cells[6];
                                    cell.AddParagraph(ds[15]);
                                    cell = row.Cells[7];
                                    cell.AddParagraph(ds[19]);
                                    line1 += ds[15] + ":";//+ ds[19]+"|";
                                }
                            }
                            writer2.WriteLine(line1);
                            line1 = "";
                        }
                        section.Add(table);
                        section.AddParagraph("1. In courses with less strength (viz. a course in which upto 45 students are registered), the Instructor-In-Charge is the only invigilator.", "Heading3");
                        section.AddParagraph("2. In case of any problems, contact  Prof. P K Sahoo (In-charge, Test Scheduling).", "Heading3");
                        paragraph = section.AddParagraph("ASSOCIATE DEAN", "Heading2");
                        paragraph.Format.Alignment = ParagraphAlignment.Right;
                        paragraph = section.AddParagraph("INSTRUCTION DIVISION", "Heading2");
                        paragraph.Format.Alignment = ParagraphAlignment.Right;
                        MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl");
                        PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
                        renderer.Document = document;
                        renderer.RenderDocument();
                        // Save the document...
                        string filename = WorkingFolder + "/Invigilations/" + Name + ".pdf";
                        renderer.PdfDocument.Save(filename);
                        writer.WriteLine("-,-,-,-,-,-,-,-,-,--,-,-,-,-,-,-,-,-,-,-,-,-,--,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-");
                        //writer.WriteLine(st);
                    }
                    x = 1;
                }
            }
            catch (Exception e1)
            {
            }
            File1.Close();
            writer.Close();
            writer1.Close();
            writer2.Close();
            txtInvigilators.Text = WorkingFolder + "/Invigilators.id";
        }
        /// <summary>
        /// Writes the value of <paramref name="group"/> to the <paramref name="table"/>.
        /// </summary>
        /// <param name="table">The <see cref="MigraDoc.DocumentObjectModel.Tables.Table"/> to write to.</param>
        /// <param name="group">The control.</param>
        /// <param name="container">The application data container.</param>
        /// <param name="level">The depth down the control tree being rendered (affects indenting).</param>
        private void WriteValueGroup(Table table, GroupControl group, Dictionary<string, object> container, int level)
        {
            Color backgroundColour = new Color(100 - (level * PdfConstants.AlphaMultiplier * 100), this.BorderColour.C, this.BorderColour.M, this.BorderColour.Y, this.BorderColour.K);

            table.AppendHeaderRow(this.DefaultStyle.Font.Size, group.Label, PdfResources.StyleNameHeaderRow, backgroundColour)
                .Format.LeftIndent = new Unit(PdfConstants.IndentMultiplier * level, UnitType.Millimeter);
            level = level < 5 ? level + 1 : level;
            this.WriteValue(table, group.Controls, container, level);
        }
        /// <summary>
        /// Creates a new table with the given number of column + column width
        /// </summary>
        /// <param name="columnNames"></param>
        /// <param name="columnWidth"></param>
        public void AddTable(string[] columnNames, int[] columnWidth)
        {
            table = section.AddTable();
            table.Style = "Table";
            table.Borders.Color = Colors.Black;
            table.Borders.Width = 0.25;
            table.Borders.Left.Width = 0.5;
            table.Borders.Right.Width = 0.5;
            table.Rows.LeftIndent = 0;

            Unit totalWidth = 0;
            for (int i = 0; i <= columnWidth.Length - 2; i++)
            {
                Unit colWidth = new Unit(columnWidth[i], UnitType.Millimeter);
                table.AddColumn(colWidth);
                totalWidth += colWidth;
            }
            table.AddColumn(TABLE_WIDTH - totalWidth);

            AddTableHeader(columnNames);
        }
        /// <summary>
        /// Writes the value of <paramref name="repeater"/> to the <paramref name="table"/>.
        /// </summary>
        /// <param name="table">The <see cref="MigraDoc.DocumentObjectModel.Tables.Table"/> to write to.</param>
        /// <param name="repeater">The control.</param>
        /// <param name="container">The application data container.</param>
        /// <param name="level">The depth down the control tree being rendered (affects indenting).</param>
        private void WriteValueRepeater(Table table, RepeaterControl repeater, Dictionary<string, object> container, int level)
        {
            Color backgroundColour = new Color(100 - (level * PdfConstants.AlphaMultiplier * 100), this.BorderColour.C, this.BorderColour.M, this.BorderColour.Y, this.BorderColour.K);

            table.AppendHeaderRow(this.DefaultStyle.Font.Size, repeater.Label, PdfResources.StyleNameHeaderRow, backgroundColour)
                .Format.LeftIndent = new Unit(PdfConstants.IndentMultiplier * level, UnitType.Millimeter);

            if (((object[])container[repeater.Name]).Length == 0)
            {
                return;
            }

            Dictionary<string, object>[] items = (Dictionary<string, object>[])container[repeater.Name];
            level = level < 5 ? level + 1 : level;
            foreach (Dictionary<string, object> repeaterItem in items)
            {
                this.WriteValue(table, repeater.Controls, repeaterItem, level);
            }
        }
Пример #41
0
        internal override void VisitTable(Table table)
        {
            Document document = table.Document;

            if (table._leftPadding.IsNull)
                table._leftPadding = Unit.FromMillimeter(1.2);
            if (table._rightPadding.IsNull)
                table._rightPadding = Unit.FromMillimeter(1.2);

            ParagraphFormat format;
            Style style = document._styles[table._style.Value];
            if (style != null)
                format = ParagraphFormatFromStyle(style);
            else
            {
                table.Style = "Normal";
                format = document._styles.Normal._paragraphFormat;
            }

            if (table._format == null)
            {
                table._format = format.Clone();
                table._format._parent = table;
            }
            else
                FlattenParagraphFormat(table._format, format);

            int rows = table.Rows.Count;
            int clms = table.Columns.Count;

            for (int idxclm = 0; idxclm < clms; idxclm++)
            {
                Column column = table.Columns[idxclm];
                ParagraphFormat colFormat;
                style = document._styles[column._style.Value];
                if (style != null)
                    colFormat = ParagraphFormatFromStyle(style);
                else
                {
                    column._style = table._style;
                    colFormat = table.Format;
                }

                if (column._format == null)
                {
                    column._format = colFormat.Clone();
                    column._format._parent = column;
                    if (column._format._shading == null && table._format._shading != null)
                        column._format._shading = table._format._shading;
                }
                else
                    FlattenParagraphFormat(column._format, colFormat);

                if (column._leftPadding.IsNull)
                    column._leftPadding = table._leftPadding;
                if (column._rightPadding.IsNull)
                    column._rightPadding = table._rightPadding;

                if (column._shading == null)
                    column._shading = table._shading;

                else if (table._shading != null)
                    FlattenShading(column._shading, table._shading);

                if (column._borders == null)
                    column._borders = table._borders;
                else if (table._borders != null)
                    FlattenBorders(column._borders, table._borders);
            }

            for (int idxrow = 0; idxrow < rows; idxrow++)
            {
                Row row = table.Rows[idxrow];

                ParagraphFormat rowFormat;
                style = document._styles[row._style.Value];
                if (style != null)
                {
                    rowFormat = ParagraphFormatFromStyle(style);
                }
                else
                {
                    row._style = table._style;
                    rowFormat = table.Format;
                }

                for (int idxclm = 0; idxclm < clms; idxclm++)
                {
                    Column column = table.Columns[idxclm];
                    Cell cell = row[idxclm];

                    ParagraphFormat cellFormat;
                    Style cellStyle = document._styles[cell._style.Value];
                    if (cellStyle != null)
                    {
                        cellFormat = ParagraphFormatFromStyle(cellStyle);

                        if (cell._format == null)
                            cell._format = cellFormat;
                        else
                            FlattenParagraphFormat(cell._format, cellFormat);
                    }
                    else
                    {
                        if (row._format != null)
                            FlattenParagraphFormat(cell.Format, row._format);

                        if (style != null)
                        {
                            cell._style = row._style;
                            FlattenParagraphFormat(cell.Format, rowFormat);
                        }
                        else
                        {
                            cell._style = column._style;
                            FlattenParagraphFormat(cell.Format, column._format);
                        }
                    }

                    if (cell._format._shading == null && table._format._shading != null)
                        cell._format._shading = table._format._shading;

                    if (cell._shading == null)
                        cell._shading = row._shading;
                    else if (row._shading != null)
                        FlattenShading(cell._shading, row._shading);
                    if (cell._shading == null)
                        cell._shading = column._shading;
                    else if (column._shading != null)
                        FlattenShading(cell._shading, column._shading);
                    if (cell._borders == null)
                        CloneHelper(ref cell._borders, row._borders);
                    else if (row._borders != null)
                        FlattenBorders(cell._borders, row._borders);
                    if (cell._borders == null)
                        cell._borders = column._borders;
                    else if (column._borders != null)
                        FlattenBorders(cell._borders, column._borders);
                }

                if (row._format == null)
                {
                    row._format = rowFormat.Clone();
                    row._format._parent = row;
                    if (row._format._shading == null && table._format._shading != null)
                        row._format._shading = table._format._shading;
                }
                else
                    FlattenParagraphFormat(row._format, rowFormat);

                if (row._topPadding.IsNull)
                    row._topPadding = table._topPadding;
                if (row._bottomPadding.IsNull)
                    row._bottomPadding = table._bottomPadding;

                if (row._shading == null)
                    row._shading = table._shading;
                else if (table._shading != null)
                    FlattenShading(row._shading, table._shading);

                if (row._borders == null)
                    row._borders = table._borders;
                else if (table._borders != null)
                    FlattenBorders(row._borders, table._borders);
            }
        }
Пример #42
0
        private static void CreateMicTable(Document doc, SetItem itemSet, Section section, out Table table, out Row row, out Cell cell)
        {
            table = new Table();
            table.Borders.Width = "0.015cm";

            int i = 0;
            int cntr = 0;

            //Add CEll, Number, MusNumber, Organism to table
            //CEll
            var column = table.AddColumn("0.8cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            // MusNumber
            column = table.AddColumn("2cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            // Organism
            column = table.AddColumn("1.8cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            // Mic
            var micCount = itemSet.MICList.Count;
            double micWidth = ((doc.DefaultPageSetup.PageWidth.Centimeter - 5.5*(section.PageSetup.LeftMargin.Centimeter + section.PageSetup.RightMargin.Centimeter) )
                / micCount);

            for (int j = 0; j < micCount ; j++)
            {
                column = table.AddColumn(micWidth.ToString() + "cm");
                column.Format.Alignment = ParagraphAlignment.Center;
            }

            // Total Mic
            column = table.AddColumn("1.8cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            //Add header row
            row = table.AddRow();

            row.Height = "0.4cm";
            row.HeadingFormat = true;
            row.Borders.Bottom.Width = "0.05cm";

            cell = row.Cells[0];
            cell.AddParagraph("Ячейка");
            cell.VerticalAlignment = VerticalAlignment.Center;

            cell = row.Cells[1];
            cell.AddParagraph("Муз.№");
            cell.VerticalAlignment = VerticalAlignment.Center;

            cell = row.Cells[2];
            cell.AddParagraph("МО");
            cell.VerticalAlignment = VerticalAlignment.Center;

            for (int j = 0; j < micCount ; j++)
            {
                cell = row.Cells[3 + j];
                cell.VerticalAlignment = VerticalAlignment.Center;
                cell.AddParagraph(itemSet.MICList[j].ToString());
            }

            cell = row.Cells[3 + micCount];
            cell.VerticalAlignment = VerticalAlignment.Center;
            cell.AddParagraph("МПК");
        }
Пример #43
0
        public static void CreateHeader(Document document)
        {
            MigraDoc.DocumentObjectModel.Tables.Table header = new MigraDoc.DocumentObjectModel.Tables.Table();
            header.Shading.Color     = Colors.MidnightBlue;
            header.Format.Font.Color = Colors.White;
            header.Format.Alignment  = ParagraphAlignment.Center;
            header.Format.Font.Bold  = true;

            Column h_column = header.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromCentimeter(4));

            h_column.Format.Alignment = ParagraphAlignment.Center;

            h_column = header.AddColumn("2.5cm");
            h_column.Format.Alignment = ParagraphAlignment.Center;

            h_column = header.AddColumn("2.5cm");
            h_column.Format.Alignment = ParagraphAlignment.Center;

            h_column = header.AddColumn("2.5cm");
            h_column.Format.Alignment = ParagraphAlignment.Center;

            h_column = header.AddColumn("2.5cm");
            h_column.Format.Alignment = ParagraphAlignment.Center;

            h_column = header.AddColumn("2.5cm");
            h_column.Format.Alignment = ParagraphAlignment.Center;

            Row  h_row  = header.AddRow();
            Cell h_cell = h_row.Cells[5];

            h_row  = header.AddRow();
            h_cell = h_row.Cells[0];
            h_row.Cells[0].MergeDown = 2;
            h_cell.AddImage(HttpContext.Current.Server.MapPath("~/img/pmm-mini.png")).Width = "3.5cm";
            h_cell = h_row.Cells[1];
            h_cell.VerticalAlignment = VerticalAlignment.Top;
            h_cell.AddParagraph("Datos del Transporte");
            h_row.Cells[1].MergeRight = 4;

            h_row = header.AddRow();
            h_row.HeadingFormat     = true;
            h_row.Format.Font.Size  = 6;
            h_row.VerticalAlignment = VerticalAlignment.Top;
            h_cell = h_row.Cells[1];
            h_cell.AddParagraph("Código del Formato:");
            h_cell = h_row.Cells[2];
            h_cell.AddParagraph("Fecha de Efectividad:");
            h_cell = h_row.Cells[3];
            h_cell.AddParagraph("Tiempo de Retención:");
            h_cell = h_row.Cells[4];
            h_cell.AddParagraph("Versión:");
            h_cell = h_row.Cells[5];
            h_cell.AddParagraph("Página:");

            h_row = header.AddRow();
            h_row.Format.Font.Size = 6;
            h_cell = h_row.Cells[1];
            h_cell.AddParagraph("QM0474.F01");
            h_cell = h_row.Cells[2];
            h_cell.AddParagraph(DateTime.Now.ToString());
            h_cell = h_row.Cells[3];
            h_cell.AddParagraph("");
            h_cell = h_row.Cells[4];
            h_cell.AddParagraph("1.0");
            h_cell = h_row.Cells[5];
            h_cell.AddParagraph("1 de 1");

            header.SetEdge(0, 0, 6, 4, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, .5, Colors.Black);
            document.LastSection.Add(header);
        }
Пример #44
0
        public IActionResult OnGet(string pdf)
        {
            //get the session first!
            UserName  = HttpContext.Session.GetString(SessionKeyName1);
            FirstName = HttpContext.Session.GetString(SessionKeyName2);
            SessionID = HttpContext.Session.GetString(SessionKeyName3);


            DatabaseConnect dbstring     = new DatabaseConnect();     //creating an object from the class
            string          DbConnection = dbstring.DatabaseString(); //calling the method from the class

            Console.WriteLine(DbConnection);
            SqlConnection conn = new SqlConnection(DbConnection);

            conn.Open();

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = @"SELECT EmployeeID,
                                        EmpFName + ' ' + EmpLName AS EmployeeName,
                                        EmpDoB AS EmployeeBornOn,
                                        EmpHireDate AS EmployedOn
                                        FROM EmployeesTable;";

                var reader = command.ExecuteReader();

                Employee = new List <Employee>();
                while (reader.Read())
                {
                    Employee Row = new Employee(); //each record found from the table
                    Row.EmployeeId        = reader.GetInt32(0);
                    Row.EmployeeFirstName = reader.GetString(1);
                    Row.EmployeeDoB       = reader.GetDateTime(2);
                    Row.EmployeeDateHired = reader.GetDateTime(3);
                    Employee.Add(Row);
                }
            }


            //PDF code here!
            if (pdf == "1")
            {
                //Create an object for pdf document
                Document  doc  = new Document();
                Section   sec  = doc.AddSection();
                Paragraph para = sec.AddParagraph();

                para.Format.Font.Name  = "Arial";
                para.Format.Font.Size  = 14;
                para.Format.Font.Color = Color.FromCmyk(0, 0, 0, 100); //black colour
                para.AddFormattedText("List of Employees", TextFormat.Bold);
                para.Format.SpaceAfter = "1.0cm";

                para.AddFormattedText();

                //Table
                Table tab = new Table();
                tab.Borders.Width = 0.75;
                tab.TopPadding    = 5;
                tab.BottomPadding = 5;

                //Column
                Column col = tab.AddColumn(Unit.FromCentimeter(3));
                col.Format.Alignment = ParagraphAlignment.Center;
                tab.AddColumn(Unit.FromCentimeter(3));
                tab.AddColumn(Unit.FromCentimeter(3));
                tab.AddColumn(Unit.FromCentimeter(3));
                //tab.AddColumn(Unit.FromCentimeter(3));


                //Row
                Row row = tab.AddRow();
                row.Shading.Color = Colors.Coral;//select your preference colour!

                //Cell for header
                Cell cell = new Cell();
                cell = row.Cells[0];
                cell.AddParagraph("EmployeeID");
                cell = row.Cells[1];
                cell.AddParagraph("Employee First Name");
                cell = row.Cells[2];
                cell.AddParagraph("Employee Date of Birth");
                cell = row.Cells[3];
                cell.AddParagraph("Employee Hire Date");

                //Add data to table
                for (int i = 0; i < Employee.Count; i++)
                {
                    row  = tab.AddRow();
                    cell = row.Cells[0];
                    cell.AddParagraph(Convert.ToString(i + 1));
                    cell = row.Cells[1];
                    cell.AddParagraph(Employee[i].EmployeeFirstName);
                    cell = row.Cells[2];
                    cell.AddParagraph(Convert.ToString(Employee[i].EmployeeDateHired));
                    cell = row.Cells[3];
                    cell.AddParagraph(Convert.ToString(Employee[i].EmployeeDoB));
                }

                tab.SetEdge(0, 0, 4, (Employee.Count + 1), Edge.Box, BorderStyle.Single, 1.5, Colors.Black);
                sec.Add(tab);

                //Rendering
                PdfDocumentRenderer pdfRen = new PdfDocumentRenderer();
                pdfRen.Document = doc;
                pdfRen.RenderDocument();

                //Create a memory stream
                MemoryStream stream = new MemoryStream();
                pdfRen.PdfDocument.Save(stream); //saving the file into the stream

                Response.Headers.Add("content-disposition", new[] { "inline; filename = ListofEmployees.pdf" });
                return(File(stream, "application/pdf"));
            }
            return(Page());
        }
Пример #45
0
        /// <summary>
        /// Parses the keyword «\table».
        /// </summary>
        private void ParseTable(DocumentElements elements, Table table)
        {
            Table tbl = table;
            try
            {
                if (tbl == null)
                    tbl = elements.AddTable();

                MoveToCode();
                AssertSymbol(Symbol.Table);

                ReadCode();
                if (_scanner.Symbol == Symbol.BracketLeft)
                    ParseAttributes(tbl);

                AssertSymbol(Symbol.BraceLeft);
                ReadCode();

                // Table must start with «\columns»...
                AssertSymbol(Symbol.Columns);
                ParseColumns(tbl);

                // ...followed by «\rows».
                AssertSymbol(Symbol.Rows);
                ParseRows(tbl);

                AssertSymbol(Symbol.BraceRight);
                ReadCode(); // read beyond '}'
            }
            catch (DdlParserException ex)
            {
                ReportParserException(ex);
                AdjustToNextBlock();
            }
        }
Пример #46
0
        private void SetTableHeader(ref Table table, Color tableColor)
        {
            var columns = new Dictionary<string, Dictionary<string, ParagraphAlignment>>();
            columns.Add("#", new Dictionary<string, ParagraphAlignment>
            {
                {"1cm", ParagraphAlignment.Center}
            });
            columns.Add("Title", new Dictionary<string, ParagraphAlignment>
            {
                {"6cm", ParagraphAlignment.Left}
            });
            var taxesEnabled = _taxSettings.TaxesEnabled;
            var columnWidth = taxesEnabled ? "2cm" : "3cm";
            columns.Add("Qty", new Dictionary<string, ParagraphAlignment>
            {
                {columnWidth, ParagraphAlignment.Center}
            });
            columns.Add("Unit Price" + (taxesEnabled ? " (ex TAX)" : ""), new Dictionary<string, ParagraphAlignment>
            {
                {columnWidth, ParagraphAlignment.Right}
            });
            if (taxesEnabled)
            {
                columns.Add("Tax Rate", new Dictionary<string, ParagraphAlignment>
                {
                    {columnWidth, ParagraphAlignment.Right}
                });
            }
            columns.Add("Net Sub Total", new Dictionary<string, ParagraphAlignment>
            {
                {"3cm", ParagraphAlignment.Right}
            });

            foreach (var item in columns)
            {
                Column column = table.AddColumn(item.Value.First().Key);
                column.Format.Alignment = item.Value.First().Value;
            }

            Row row = table.AddRow();
            row.HeadingFormat = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color = tableColor;
            row.TopPadding = 2;
            row.BottomPadding = 2;
            int rowId = 0;
            foreach (var item in columns)
            {
                row.Cells[rowId].AddParagraph(item.Key);
                row.Cells[rowId].Format.Alignment = ParagraphAlignment.Center;
                rowId++;
            }

            table.SetEdge(0, 0, 5, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }
Пример #47
0
        /// <summary>
        /// Parses the keyword «\rows».
        /// </summary>
        private void ParseRows(Table table)
        {
            Debug.Assert(table != null);
            Debug.Assert(Symbol == Symbol.Rows);

            ReadCode();
            if (Symbol == Symbol.BracketLeft)
                ParseAttributes(table.Rows);

            AssertSymbol(Symbol.BraceLeft);
            ReadCode();

            bool loop = true;
            while (loop)
            {
                switch (Symbol)
                {
                    case Symbol.Eof:
                        ThrowParserException(DomMsgID.UnexpectedEndOfFile);
                        break;

                    case Symbol.BraceRight:
                        ReadCode(); // read '}'
                        loop = false;
                        break;

                    case Symbol.Row:
                        ParseRow(table.AddRow());
                        break;

                    default:
                        AssertSymbol(Symbol.Row);
                        break;
                }
            }
        }
Пример #48
0
        private void SetTableSummary(Order order, ref Table table)
        {
            var summaryData = new Dictionary<string, string>();
            var subtotal = _taxSettings.TaxesEnabled ? order.Subtotal : order.Total - order.ShippingTotal;
            summaryData.Add("Sub-total", subtotal.ToCurrencyFormat());
            var shipping = _taxSettings.TaxesEnabled && _taxSettings.ShippingRateTaxesEnabled
                ? (order.ShippingSubtotal - order.ShippingTax)
                : order.ShippingSubtotal;
            summaryData.Add("Shipping", shipping.ToCurrencyFormat());
            if (_taxSettings.TaxesEnabled)
            {
                summaryData.Add("Tax", order.Tax.ToCurrencyFormat());
            }
            summaryData.Add("Discount", order.DiscountAmount.ToCurrencyFormat());
            summaryData.Add("Total", order.Total.ToCurrencyFormat());

            var startIndex = _taxSettings.TaxesEnabled ? 5 : 4;
            foreach (var item in summaryData)
            {
                Row row = table.AddRow();
                row.TopPadding = 2;
                row.BottomPadding = 2;
                row.Cells[0].Borders.Visible = false;
                row.Cells[0].AddParagraph(item.Key + ":");
                row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
                row.Cells[0].MergeRight = startIndex - 1;
                if (item.Key == "Total")
                    row.Cells[startIndex].Format.Font.Bold = true;
                row.Cells[startIndex].AddParagraph(item.Value);
            }

            table.SetEdge(startIndex, table.Rows.Count - 3, 1, 3, Edge.Box, BorderStyle.Single, 0.75);
        }
Пример #49
0
        /// <summary>
        /// Parses one of the keywords «\document», «\styles», «\section», «\table», «\textframe», «\chart»
        /// and «\paragraph» and returns the corresponding DocumentObject or DocumentObjectCollection.
        /// </summary>
        internal DocumentObject ParseDocumentObject()
        {
            DocumentObject obj = null;

            MoveToCode();
            switch (Symbol)
            {
                case Symbol.Document:
                    obj = ParseDocument(null);
                    break;

                case Symbol.Styles:
                    obj = ParseStyles(new Styles());
                    break;

                case Symbol.Section:
                    obj = ParseSection(new Sections());
                    break;

                case Symbol.Table:
                    obj = new Table();
                    ParseTable(null, (Table)obj);
                    break;

                case Symbol.TextFrame:
                    DocumentElements elems = new DocumentElements();
                    ParseTextFrame(elems);
                    obj = elems[0];
                    break;

                case Symbol.Chart:
                    throw new NotImplementedException();

                case Symbol.Paragraph:
                    obj = new DocumentElements();
                    ParseParagraph((DocumentElements)obj);
                    break;

                default:
                    ThrowParserException(DomMsgID.UnexpectedSymbol);
                    break;
            }
            ReadCode();
            AssertCondition(Symbol == Symbol.Eof, DomMsgID.EndOfFileExpected);

            return obj;
        }
Пример #50
0
        private void PlaceImage(Stone stone)
        {
            Section section = this.document.AddSection();

            //Table mainTable  = section.AddTable();
            //mainTable.Style = "Table";
            //mainTable.Borders.Color = new Color(81, 125, 192);
            //mainTable.Borders.Width = 0.25;
            //mainTable.Format.SpaceAfter = "5mm";

            //Column column = mainTable.AddColumn(Unit.FromMillimeter(170));
            //column.Format.Alignment = ParagraphAlignment.Center;

            ////column = mainTable.AddColumn("7cm");
            ////column.Format.Alignment = ParagraphAlignment.Center;

            //Row row2 = mainTable.AddRow();
            //row2.Format.Alignment = ParagraphAlignment.Center;
            //row2.Format.Font.Bold = true;

            Image image =  section.AddImage(stone.FullFilePath);
            image.Width = Unit.FromMillimeter(170);
            image.LockAspectRatio = true;

            //write the properties table

            TextFrame frame = section.AddTextFrame();

            frame.Left = ShapePosition.Center;
            frame.Top = "1cm";

            this.infopartTable = frame.AddTable();

               // this.infopartTable.Format.SpaceBefore = "10mm";
            this.infopartTable.Style = "Table";
            this.infopartTable.Borders.Color = new Color(81, 125, 192);
            this.infopartTable.Borders.Width = 0.25;
            this.infopartTable.BottomPadding = "2mm";
            this.infopartTable.LeftPadding = "2mm";
            this.infopartTable.RightPadding = "2mm";
            this.infopartTable.TopPadding = "2mm";

            Column column2 = this.infopartTable.AddColumn("3cm");
            column2.Format.Alignment = ParagraphAlignment.Center;

            column2 = this.infopartTable.AddColumn("2cm");
            column2.Format.Alignment = ParagraphAlignment.Center;

            foreach (var infopart in stone.InfoList)
            {
                  Row row = this.infopartTable.AddRow();

                  row.Cells[0].AddParagraph(infopart.TitleForReport);
                  row.Cells[0].Format.Font.Bold = true;
                  row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
                  row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;

                  row.Cells[1].AddParagraph(infopart.Value);
                  row.Cells[1].Format.Font.Bold = false;
                  row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                  row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;

            }
        }
Пример #51
0
        /// <summary>
        /// Erstellt aus einer DataTable eine Micradoc Tabelle
        /// </summary>
        /// <param name="dt">DataTable</param>
        /// <param name="columnWidths">Spaltenbreite</param>
        /// <param name="shadedColumns">Spalten mit Schattierung</param>
        /// <param name="stretchToPageWidth">Gibt an ob die Tabelle auf das gesamte Blatt gestretcht werden soll</param>
        /// <returns>Micradoc Tabelle</returns>
        protected Table GetTableFromDataTable(DataTable dt, List<int> columnWidths, List<int> shadedColumns, bool stretchToPageWidth)
        {
            Table table = new Table();
            if (columnWidths != null)
            {
                foreach (int width in columnWidths)
                {
                    table.AddColumn(new Unit((double)width, UnitType.Millimeter));
                }
            }

            while (dt.Columns.Count > table.Columns.Count)
            {
                table.AddColumn();
            }

            if (stretchToPageWidth)
            {
                double pageWidth = this.Document.LastSection.PageSetup.PageWidth.Millimeter - this.Document.LastSection.PageSetup.LeftMargin.Millimeter - this.Document.LastSection.PageSetup.RightMargin.Millimeter;
                double columnWidthSum = 0;
                foreach (Column column in table.Columns)
                {
                    columnWidthSum += column.Width.Millimeter;
                }

                foreach (Column column in table.Columns)
                {
                    column.Width = new Unit(column.Width.Millimeter * pageWidth / columnWidthSum, UnitType.Millimeter);

                    if (!IsInvoice)
                    {
                        Border bor = new Border();
                        bor.Style = BorderStyle.Single;

                        column.Borders.Left = bor;

                        bor = new Border();
                        bor.Style = BorderStyle.Single;
                        column.Borders.Right = bor;
                    }
                }
            }

            var headerRow = table.AddRow();
            headerRow.HeadingFormat = true;
            headerRow.Format.Font.Bold = true;
            int i = 0;
            foreach (DataColumn dc in dt.Columns)
            {
                headerRow[i].AddParagraph(dc.ColumnName);
                headerRow[i].Shading.Color = this.TableShadingColor;
                i++;
            }

            foreach (DataRow dr in dt.Rows)
            {
                var row = table.AddRow(dr.ItemArray);
                row.Height = new Unit((IsInvoice)?0.5:0.8, UnitType.Centimeter);
                if (!IsInvoice)
                {
                    Border bor = new Border();
                    bor.Style = BorderStyle.Single;
                    row.Borders.Left = bor;
                    bor = new Border();
                    bor.Style = BorderStyle.Single;
                    row.Borders.Right = bor;

                    bor = new Border();
                    bor.Style = BorderStyle.Single;
                    row.Borders.Bottom = bor;
                }
                foreach (int sc in shadedColumns)
                {
                    row[sc].Shading.Color = this.TableShadingColor;
                }
            }

            table.SetEdge(0, 0, table.Columns.Count, 1, Edge.Box, BorderStyle.Single, new Unit(1, UnitType.Point));
            table.SetEdge(0, 1, table.Columns.Count, table.Rows.Count - 1, Edge.Box, BorderStyle.Single, new Unit(1, UnitType.Point));
            return table;
        }
        public void Render(IPdfStyling pdfStyling, Section section)
        {
            Unit height = Unit.FromCentimeter(3) + Unit.FromCentimeter(0.7 * 10);             // 3cm from top and bottom + cm per line

            TextFrame space = section.AddTextFrame();

            space.Height = ((pdfStyling.MaxHeightInPoints - height) / 2) - Unit.FromCentimeter(1);             // -1cm from margin-top of horizontal rule
            space.Width  = pdfStyling.MaxHeightInPoints;

            HorizontalRule(pdfStyling, section);

            Paragraph h2 = section.AddParagraph();

            h2.AddText("INHALTSVERZEICHNIS");
            h2.Format.Font.Size   = 12;
            h2.Format.SpaceBefore = 0;
            h2.Format.SpaceAfter  = Unit.FromCentimeter(0.5);
            h2.Format.LeftIndent  = Unit.FromCentimeter(1);
            h2.Format.Alignment   = ParagraphAlignment.Left;

            MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();

            table.TopPadding    = 0;
            table.RightPadding  = 0;
            table.BottomPadding = 0;
            table.LeftPadding   = 0;
            table.Borders.Width = 0;

            table.Rows.LeftIndent = Unit.FromCentimeter(1);
            table.AddColumn(pdfStyling.MaxWidthInPoints / 2);
            table.AddColumn(pdfStyling.MaxWidthInPoints / 2);

            Row row = table.AddRow();

            IDictionary <int, string> pages = new Dictionary <int, string>
            {
                { 1, "frische Babyananas" },
                { 2, "frische Babyananas" },
                { 3, "frische Babyananas" },
                { 4, "frische Babyananas" },
                { 5, "frische Babyananas" },
                { 6, "frische Babyananas" },
                { 7, "frische Babyananas" },
                { 8, "frische Babyananas" },
                { 9, "frische Babyananas" },
                { 10, "frische Babyananas" },
                { 11, "frische Babyananas" },
                { 12, "frische Babyananas" },
                { 13, "frische Babyananas" },
                { 14, "frische Babyananas" },
                { 15, "frische Babyananas" },
                { 16, "frische Babyananas" },
                { 17, "frische Babyananas" },
                { 18, "frische Babyananas" },
                { 19, "frische Babyananas" },
                { 20, "frische Babyananas" }
            };

            decimal numberOfGroups = 2;
            int     counter        = 0;
            int     groupSize      = Convert.ToInt32(Math.Ceiling(pages.Count / numberOfGroups));

            var result = pages.GroupBy(x => counter++ / groupSize);

            int       cellIndex = 0;
            Font      font;
            Paragraph paragraph;
            Hyperlink hyperlink;

            foreach (IEnumerable <KeyValuePair <int, string> > group in result)
            {
                foreach (KeyValuePair <int, string> page in group)
                {
                    paragraph = row.Cells[cellIndex].AddParagraph();
                    paragraph.Format.Font.Size  = 10;
                    paragraph.Format.Font.Color = pdfStyling.ParagraphSmallColor;
                    if (cellIndex == 1)
                    {
                        paragraph.Format.LeftIndent = Unit.FromCentimeter(1);
                    }

                    font       = paragraph.Format.Font.Clone();
                    font.Color = pdfStyling.FontColor;

                    paragraph.Format.AddTabStop("2.5cm", TabAlignment.Left, TabLeader.Lines);

                    hyperlink = paragraph.AddHyperlink("Receipt1");
                    hyperlink.AddFormattedText(page.Key.ToString(), font);
                    hyperlink.AddTab();
                    hyperlink.AddFormattedText(page.Value, font);
                }
                cellIndex++;
            }

            HorizontalRule(pdfStyling, section);

            Footer(pdfStyling, section);

            section.AddPageBreak();
        }
 /// <summary>
 /// Loops over <paramref name="controls"/> and adds the corresponding application values
 /// in <paramref name="container"/> to the <paramref name="table"/>.
 /// </summary>
 /// <param name="table">The <see cref="MigraDoc.DocumentObjectModel.Tables.Table"/> to write to.</param>
 /// <param name="controls">The list of controls.</param>
 /// <param name="container">The application data container.</param>
 /// <param name="level">The depth down the control tree being rendered (affects indenting).</param>
 private void WriteValue(Table table, ControlList controls, Dictionary<string, object> container, int level)
 {
     IEnumerable<Control> orderedControls = controls.OrderBy(c => c.Position);
     foreach (Control control in orderedControls)
     {
         this.WriteValue(table, control, container, level);
     }
 }
        /// <summary>
        /// Writes the application value from <paramref name="container"/>
        /// that corresponds to <paramref name="control"/> to the <paramref name="table"/>.
        /// </summary>
        /// <param name="table">The <see cref="MigraDoc.DocumentObjectModel.Tables.Table"/> to write to.</param>
        /// <param name="control">The control.</param>
        /// <param name="container">The application data container.</param>
        /// <param name="level">The depth down the control tree being rendered (affects indenting).</param>
        private void WriteValue(Table table, Control control, Dictionary<string, object> container, int level)
        {
            if (control.Type == ControlType.Group)
            {
                this.WriteValueGroup(table, (GroupControl)control, container, level);
                return;
            }

            if (!container.ContainsKey(control.Name))
            {
                return;
            }

            switch (control.Type)
            {
                case ControlType.Group:
                    break;

                case ControlType.Repeater:
                    this.WriteValueRepeater(table, (RepeaterControl)control, container, level);
                    break;

                case ControlType.Calculation:
                    Row calcRow = table.AppendRow(this.DefaultStyle.Font.Size, ((CalculationControl)control).Label, container[control.Name].ToString());
                    calcRow.Cells[0].Format.LeftIndent = new Unit(PdfConstants.IndentMultiplier * level, UnitType.Millimeter);
                    break;

                case ControlType.Checkbox:
                case ControlType.CheckboxGroup:
                case ControlType.Combo:
                case ControlType.Date:
                case ControlType.FileBrowser:
                case ControlType.Hidden:
                case ControlType.Radio:
                case ControlType.Text:
                case ControlType.Time:
                    string formattedValue = this.formatter.FormatApplicationValue(container[control.Name], control);
                    Row row = table.AppendRow(this.DefaultStyle.Font.Size, ((ValueControl)control).Label, formattedValue);
                    row.Cells[0].Format.LeftIndent = new Unit(PdfConstants.IndentMultiplier * level, UnitType.Millimeter);
                    break;

                case ControlType.Geolocation:
                    this.WriteValueGeolocation(table, (GeolocationControl)control, container, level);
                    break;

                case ControlType.SignaturePad:
                    this.WriteValueSignature(table, (SignaturePadControl)control, container, level);
                    break;

                case ControlType.Likert:
                    this.WriteValueLikert(table, (LikertControl)control, container, level);
                    break;

                default:
                    throw new InvalidOperationException(string.Format(ExceptionMessages.UnknownControlType, control.Type));
            }
        }
        /// <summary>
        /// Writes the value of the geolocation to the table as an image.
        /// </summary>
        /// <param name="table">The <see cref="MigraDoc.DocumentObjectModel.Tables.Table"/> to write to.</param>
        /// <param name="control">The control.</param>
        /// <param name="container">The application data container.</param>
        /// <param name="level">The depth down the control tree being rendered (affects indenting).</param>
        private void WriteValueGeolocation(Table table, GeolocationControl control, Dictionary<string, object> container, int level)
        {
            if (control.DisplayStyle == GeolocationDisplayStyle.None)
            {
                return;
            }

            Row row = table.AppendRow(this.DefaultStyle.Font.Size, control.Label, string.Empty);
            row.Cells[0].Format.LeftIndent = new Unit(PdfConstants.IndentMultiplier * level, UnitType.Millimeter);

            string coords = container[control.Name].ToString();

            if (control.DisplayStyle == GeolocationDisplayStyle.Both || control.DisplayStyle == GeolocationDisplayStyle.Coordinates)
            {
                row.Cells[1].AddParagraph(coords);
            }

            if (control.DisplayStyle != GeolocationDisplayStyle.Both && control.DisplayStyle != GeolocationDisplayStyle.Map)
            {
                return;
            }

            string path = this.GetTemporaryFileName("png");
            Coordinate coordinate = Coordinate.Parse(coords);
            GoogleMapProvider provider = new GoogleMapProvider();

            using (FileStream fileStream = new FileStream(path, FileMode.Create))
            {
                provider.Write(coordinate, new Size(225, 225), fileStream);
            }

            row.Cells[1].AddParagraph().AddImage(path);
        }
Пример #56
0
        /// <summary>
        /// Creates the static parts of the invoice.
        /// </summary>
        void CreatePage()
        {
            // Each MigraDoc document needs at least one section.
              Section section = this.document.AddSection();

              // Put a logo in the header
              Image image = section.Headers.Primary.AddImage("../../PowerBooks.png");
              image.Height = "2.5cm";
              image.LockAspectRatio = true;
              image.RelativeVertical = RelativeVertical.Line;
              image.RelativeHorizontal = RelativeHorizontal.Margin;
              image.Top = ShapePosition.Top;
              image.Left = ShapePosition.Right;
              image.WrapFormat.Style = WrapStyle.Through;

              // Create footer
              Paragraph paragraph = section.Footers.Primary.AddParagraph();
              paragraph.AddText("PowerBooks Inc · Sample Street 42 · 56789 Cologne · Germany");
              paragraph.Format.Font.Size = 9;
              paragraph.Format.Alignment = ParagraphAlignment.Center;

              // Create the text frame for the address
              this.addressFrame = section.AddTextFrame();
              this.addressFrame.Height = "3.0cm";
              this.addressFrame.Width = "7.0cm";
              this.addressFrame.Left = ShapePosition.Left;
              this.addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
              this.addressFrame.Top = "5.0cm";
              this.addressFrame.RelativeVertical = RelativeVertical.Page;

              // Put sender in address frame
              paragraph = this.addressFrame.AddParagraph("PowerBooks Inc · Sample Street 42 · 56789 Cologne");
              paragraph.Format.Font.Name = "Times New Roman";
              paragraph.Format.Font.Size = 7;
              paragraph.Format.SpaceAfter = 3;

              // Add the print date field
              paragraph = section.AddParagraph();
              paragraph.Format.SpaceBefore = "8cm";
              paragraph.Style = "Reference";
              paragraph.AddFormattedText("INVOICE", TextFormat.Bold);
              paragraph.AddTab();
              paragraph.AddText("Cologne, ");
              paragraph.AddDateField("dd.MM.yyyy");

              // Create the item table
              this.table = section.AddTable();
              this.table.Style = "Table";
              this.table.Borders.Color = TableBorder;
              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;

              // Before you can add a row, you must define the columns
              Column column = this.table.AddColumn("1cm");
              column.Format.Alignment = ParagraphAlignment.Center;

              column = this.table.AddColumn("2.5cm");
              column.Format.Alignment = ParagraphAlignment.Right;

              column = this.table.AddColumn("3cm");
              column.Format.Alignment = ParagraphAlignment.Right;

              column = this.table.AddColumn("3.5cm");
              column.Format.Alignment = ParagraphAlignment.Right;

              column = this.table.AddColumn("2cm");
              column.Format.Alignment = ParagraphAlignment.Center;

              column = this.table.AddColumn("4cm");
              column.Format.Alignment = ParagraphAlignment.Right;

              // Create the header of the table
              Row row = table.AddRow();
              row.HeadingFormat = true;
              row.Format.Alignment = ParagraphAlignment.Center;
              row.Format.Font.Bold = true;
              row.Shading.Color = TableBlue;
              row.Cells[0].AddParagraph("Item");
              row.Cells[0].Format.Font.Bold = false;
              row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
              row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
              row.Cells[0].MergeDown = 1;
              row.Cells[1].AddParagraph("Title and Author");
              row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
              row.Cells[1].MergeRight = 3;
              row.Cells[5].AddParagraph("Extended Price");
              row.Cells[5].Format.Alignment = ParagraphAlignment.Left;
              row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
              row.Cells[5].MergeDown = 1;

              row = table.AddRow();
              row.HeadingFormat = true;
              row.Format.Alignment = ParagraphAlignment.Center;
              row.Format.Font.Bold = true;
              row.Shading.Color = TableBlue;
              row.Cells[1].AddParagraph("Quantity");
              row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
              row.Cells[2].AddParagraph("Unit Price");
              row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
              row.Cells[3].AddParagraph("Discount (%)");
              row.Cells[3].Format.Alignment = ParagraphAlignment.Left;
              row.Cells[4].AddParagraph("Taxable");
              row.Cells[4].Format.Alignment = ParagraphAlignment.Left;

              this.table.SetEdge(0, 0, 6, 2, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }
Пример #57
0
        private void CreatePage()
        {
            // Each MigraDoc document needs at least one section.
            MigraDoc.DocumentObjectModel.Section section = this.document.AddSection();

            // Put a logo in the header
            Image image = section.Headers.Primary.AddImage("Image_Icons/logo1.png");

            image.Height             = "2.5cm";
            image.Width              = "5cm";
            image.LockAspectRatio    = true;
            image.RelativeVertical   = RelativeVertical.Line;
            image.RelativeHorizontal = RelativeHorizontal.Margin;
            image.Top              = ShapePosition.Top;
            image.Left             = ShapePosition.Right;
            image.WrapFormat.Style = WrapStyle.Through;

            // Create the text frame for the address
            this.addressFrame                    = section.AddTextFrame();
            this.addressFrame.Height             = "8.0cm";
            this.addressFrame.Width              = "10.0cm";
            this.addressFrame.Left               = ShapePosition.Left;
            this.addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.addressFrame.Top                = "4cm";
            this.addressFrame.RelativeVertical   = RelativeVertical.Page;

            this.PriceFrame                    = section.AddTextFrame();
            this.PriceFrame.Height             = "5.0cm";
            this.PriceFrame.Width              = "5.0cm";
            this.PriceFrame.Left               = ShapePosition.Right;
            this.PriceFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.PriceFrame.Top                = "4.0cm";
            this.PriceFrame.RelativeVertical   = RelativeVertical.Page;

            // Put sender in address frame
            //= addressFrame.AddParagraph("ul.Pralki 5, 13-342 Lodówka");
            //paragraph.Format.Font.Name = "Times New Roman";
            //paragraph.Format.Font.Size = 7;
            //paragraph.Format.SpaceAfter = 3;

            // Add the print date field
            MigraDoc.DocumentObjectModel.Paragraph paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "8cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText($"Faktura nr {order.Date.Year}/{order.Id}", TextFormat.Bold);
            paragraph.AddTab();
            paragraph.AddText("Białystok, ");
            paragraph.AddDateField("dd.MM.yyyy");

            paragraph = section.Footers.Primary.AddParagraph();
            paragraph.AddText($"\u00a9 2021 RTV&AGD \n ul.Pralki 5, 13-342 Lodówka \n Data wydruku: {DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss")} ");
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            // Create the item table
            this.table                = section.AddTable();
            table.Format.Alignment    = ParagraphAlignment.Justify;
            table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Black;
            table.Borders.Width       = 0.25;
            table.Borders.Left.Width  = 0.5;
            table.Borders.Right.Width = 0.5;
            table.Rows.LeftIndent     = 5;
            table.TopPadding          = 10;
            table.BottomPadding       = 10;

            // Before you can add a row, you must define the columns
            Column column = this.table.AddColumn("7.5cm");

            column.Format.Alignment = ParagraphAlignment.Center;

            column = this.table.AddColumn("1.5cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("3.5cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("3.5cm");
            column.Format.Alignment = ParagraphAlignment.Right;


            // Create the header of the table
            Row row = table.AddRow();

            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Left;
            row.Format.Font.Bold = true;
            row.Shading.Color    = TableBlue;
            row.Cells[0].AddParagraph("Nazwa");
            row.Cells[0].Format.Font.Bold  = true;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[0].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;

            row.Cells[1].AddParagraph("Ilość");
            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[2].AddParagraph("Cena/szt");
            row.Cells[2].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[2].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;

            row.Cells[3].AddParagraph("Wartosc");
            row.Cells[3].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[3].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;



            this.table.SetEdge(0, 0, 4, 1, Edge.Box, BorderStyle.Single, 0.75, MigraDoc.DocumentObjectModel.Color.Empty);
        }
Пример #58
0
        public string pdfRapportoAgentePlus(string autore, string emailAutore, string periodoRiferimento, Single acconto, Single recupero, Single daRiportare, Single monete, Single carta, string targa, List <cCostanti.tOperazione> info)
        {
            cCostanti costanti = new cCostanti();
            string    testo = "";
            string    fileName, pathFileName;
            string    pageFooterText = "";

            DateTime  currentTime     = DateTime.Now;
            Document  document        = new Document();
            Table     table           = new MigraDoc.DocumentObjectModel.Tables.Table();
            Paragraph infoPremilinari = new MigraDoc.DocumentObjectModel.Paragraph();
            Column    colonna;

            FormattedText ftextTarga = new FormattedText();

            fileName     = ("pdf_" + emailAutore).Replace(" ", "").Replace(".", "_").Replace("@", "_") + ".pdf";
            pathFileName = HttpContext.Current.Server.MapPath(costanti.pathRemoto + "/" + fileName);

            Style style = document.Styles["Normal"];

            style.Font.Name = "Arial Unicode MS";
            style.Font.Size = 12;
            style.Font.Bold = false;


            //table Style
            style           = document.Styles.AddStyle("tabella", "Normal");
            style.Font.Name = "Verdana";
            style.Font.Size = 12;
            style.Font.Bold = false;

            style           = document.Styles.AddStyle("rigaBold", "Normal");
            style.Font.Name = "Verdana";
            style.Font.Size = 12;
            style.Font.Bold = true;

            style           = document.Styles.AddStyle("riga24", "Normal");
            style.Font.Name = "Verdana";
            style.Font.Size = 24;
            style.Font.Bold = true;

            style           = document.Styles.AddStyle("testoBold", "Normal");
            style.Font.Name = "Verdana";
            style.Font.Size = 12;
            style.Font.Bold = true;

            style            = document.Styles.AddStyle("testoRosso", "Normal");
            style.Font.Name  = "Verdana";
            style.Font.Size  = 14;
            style.Font.Bold  = true;
            style.Font.Color = Colors.OrangeRed;

            style            = document.Styles.AddStyle("testoBlu", "Normal");
            style.Font.Name  = "Verdana";
            style.Font.Size  = 14;
            style.Font.Bold  = true;
            style.Font.Color = Colors.DarkBlue;

            style            = document.Styles.AddStyle("testoLightBlu", "Normal");
            style.Font.Name  = "Verdana";
            style.Font.Size  = 12;
            style.Font.Bold  = false;
            style.Font.Color = Colors.DarkBlue;

            style            = document.Styles.AddStyle("testoNero", "Normal");
            style.Font.Name  = "Verdana";
            style.Font.Size  = 14;
            style.Font.Bold  = true;
            style.Font.Color = Colors.Black;

            style            = document.Styles.AddStyle("Titolo", "Normal");
            style.Font.Name  = "Verdana";
            style.Font.Size  = 16;
            style.Font.Bold  = true;
            style.Font.Color = Colors.Orange;

            Section page = document.AddSection();

            //header
            Paragraph header = page.Headers.Primary.AddParagraph();

            header.AddText("Money BOX");
            header.Format.Alignment = ParagraphAlignment.Left;
            header.Style            = "Titolo";
            testo  = string.Format("{0}, {1}, targa: ", autore, emailAutore);
            header = page.Headers.Primary.AddParagraph();
            header.AddText(testo);
            ftextTarga.AddText(targa.ToUpper());
            ftextTarga.Color = Colors.Red;
            header.Add(ftextTarga);
            header.AddText("\n");
            header.Format.Alignment = ParagraphAlignment.Left;

            //footer
            pageFooterText = string.Format(" report del {0} ", currentTime.ToShortDateString()) + "\n";
            Paragraph footer = page.Footers.Primary.AddParagraph();

            footer.AddText(pageFooterText);
            footer.Format.Alignment = ParagraphAlignment.Center;

            table.Style               = "tabella";
            table.Borders.Color       = Colors.Black;
            table.Borders.Width       = 0.25;
            table.Borders.Left.Width  = 0.5;
            table.Borders.Right.Width = 0.5;
            table.Rows.LeftIndent     = 0;

            colonna = table.AddColumn("6cm");
            colonna.Format.Alignment = ParagraphAlignment.Left;
            colonna = table.AddColumn("3.5cm");
            colonna.Format.Alignment = ParagraphAlignment.Left;
            colonna = table.AddColumn("3.5cm");
            colonna.Format.Alignment = ParagraphAlignment.Left;
            colonna = table.AddColumn("3.5cm");
            colonna.Format.Alignment = ParagraphAlignment.Left;

            infoPremilinari.AddText("\nPeriodo di riferimento: ");
            infoPremilinari.AddFormattedText(periodoRiferimento, TextFormat.Bold);
            infoPremilinari.AddText("\n\n");


            page.Add(infoPremilinari);
            Row riga = table.AddRow();

            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("Locale");
            riga.Cells[1].AddParagraph("acconto");
            riga.Cells[2].AddParagraph("recupero \n da riportare");
            riga.Cells[3].AddParagraph("da Riportare");
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Left;
            riga.Cells[1].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[3].Format.Alignment = ParagraphAlignment.Right;

            foreach (var value in info)
            {
                riga = table.AddRow();
                int position = value.data.IndexOf(" ");

                if (value.acconto == 0 && value.recupero == 0 && value.daRiportare == 0)
                {
                    riga.Cells[0].AddParagraph(value.nomeLocale + "\n" + value.data.Substring(0, position));
                    riga.Cells[0].Style = "testoLightBlu";
                    riga.Cells[1].AddParagraph("*** OPERAZIONE GENERICA ***");
                    riga.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                    riga.Cells[1].MergeRight       = 2;
                }
                else
                {
                    riga.Cells[0].AddParagraph(value.nomeLocale + "\n" + value.data.Substring(0, position));
                    if (value.acconto == 0)
                    {
                        riga.Cells[1].AddParagraph("");
                    }
                    else
                    {
                        riga.Cells[1].AddParagraph(String.Format("{0:0,0.00}", value.acconto));
                    }

                    if (value.recupero == 0)
                    {
                        riga.Cells[2].AddParagraph("");
                    }
                    else
                    {
                        riga.Cells[2].AddParagraph(String.Format("{0:0,0.00}", value.recupero));
                    }
                    if (value.daRiportare == 0)
                    {
                        riga.Cells[3].AddParagraph("");
                    }
                    else
                    {
                        riga.Cells[3].AddParagraph(String.Format("{0:0,0.00}", value.daRiportare));
                    }
                    riga.Cells[0].Format.Alignment = ParagraphAlignment.Left;
                    riga.Cells[1].Format.Alignment = ParagraphAlignment.Right;
                    riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
                    riga.Cells[3].Format.Alignment = ParagraphAlignment.Right;
                }
            }

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("\nFlusso acconti\n\n");
            riga.Cells[1].AddParagraph("\n" + String.Format("{0:0,0.00}", acconto));
            riga.Cells[2].AddParagraph("");
            riga.Cells[2].MergeRight       = 1;
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Left;
            riga.Cells[1].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[0].Style            = "testoNero";
            riga.Cells[1].Style            = "testoBlu";

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("Flusso di cassa");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph(String.Format("{0:0,0.00}", recupero));
            riga.Cells[3].AddParagraph(String.Format("{0:0,0.00}", daRiportare));
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Left;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[3].Format.Alignment = ParagraphAlignment.Right;


            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("Monete");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph(String.Format("{0:0,0.00}", monete));
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[3].MergeDown        = 3;

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("Carta");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph(String.Format("{0:0,0.00}", carta));
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("Tot. cassa");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph(String.Format("{0:0,0.00}", monete + carta + recupero));
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[0].Style            = "testoNero";
            riga.Cells[2].Style            = "testoNero";

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("\nFlusso di cassa\n\n");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph("\n" + String.Format("{0:0,0.00}", monete + carta + recupero - daRiportare));
            riga.Cells[3].AddParagraph("\n");
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[0].Style            = "testoNero";
            riga.Cells[2].Style            = "testoRosso";

            riga       = table.AddRow();
            riga.Style = "rigaBold";
            riga.Cells[0].AddParagraph("\nCassa Generale\n\n");
            riga.Cells[0].MergeRight = 1;
            riga.Cells[2].AddParagraph("\n" + String.Format("{0:0,0.00}", acconto + monete + carta + recupero - daRiportare));
            riga.Cells[3].AddParagraph("\n");
            riga.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            riga.Cells[0].Style            = "testoNero";
            riga.Cells[2].Style            = "testoNero";

            page.Add(table);

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();
            pdfRenderer.PdfDocument.Save(pathFileName);

            //Process.Start(fileName);
            return(fileName);
        }
Пример #59
0
    private void generatePDFFile()
    {
        // Create a MigraDoc document
        Document doc = new Document();

        doc.Info.Title   = "Work Order";
        doc.Info.Subject = "Order No:" + oModOrder.GetSetorderno;
        doc.Info.Author  = "B.I.O.App System";

        //set page orientation
        doc.DefaultPageSetup.Orientation    = MigraDoc.DocumentObjectModel.Orientation.Portrait;
        doc.DefaultPageSetup.TopMargin      = "7.5cm"; //120
        doc.DefaultPageSetup.BottomMargin   = "8.5cm"; //150
        doc.DefaultPageSetup.LeftMargin     = 40;
        doc.DefaultPageSetup.RightMargin    = 40;
        doc.DefaultPageSetup.HeaderDistance = "1.5cm"; //20
        doc.DefaultPageSetup.FooterDistance = "1cm";   //20

        MigraDoc.DocumentObjectModel.Style style = doc.Styles["Normal"];
        // Because all styles are derived from Normal, the next line changes the
        // font of the whole document. Or, more exactly, it changes the font of
        // all styles and paragraphs that do not redefine the font.
        style.Font.Name = "Verdana";

        // Create a new style called Table based on style Normal
        style           = doc.Styles.AddStyle("Table", "Normal");
        style.Font.Name = "Verdana";
        style.Font.Name = "Arial";
        style.Font.Size = 8;

        // Each MigraDoc document needs at least one section.
        Section section = doc.AddSection();

        // Put Capital Digital logo in the header
        string logo_lima = Server.MapPath("~/images/logo_CD_bgBLUE_BLACK_310x98.png");

        MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(logo_lima);
        image.Height             = "1cm";
        image.LockAspectRatio    = true;
        image.RelativeVertical   = RelativeVertical.Line;
        image.RelativeHorizontal = RelativeHorizontal.Margin;
        image.Top              = ShapePosition.Top;
        image.Left             = ShapePosition.Right;
        image.WrapFormat.Style = WrapStyle.Through;

        // Put CD logo in the header
        string logo_mod = Server.MapPath("~/images/logo_versi_4.png");

        MigraDoc.DocumentObjectModel.Shapes.Image image2 = section.Headers.Primary.AddImage(logo_mod);
        image2.Height             = "1.5cm";
        image2.LockAspectRatio    = true;
        image2.RelativeVertical   = RelativeVertical.Line;
        image2.RelativeHorizontal = RelativeHorizontal.Margin;
        image2.Top              = ShapePosition.Top;
        image2.Left             = ShapePosition.Left;
        image2.WrapFormat.Style = WrapStyle.Through;

        // Create Header
        Paragraph header = section.Headers.Primary.AddParagraph();

        header.AddText("WORK ORDER FORM");
        header.Format.Font.Size = 12;
        header.Format.Font.Bold = true;
        header.Format.Alignment = ParagraphAlignment.Center;

        // Create main section for Sales Order
        //Paragraph main = section.AddParagraph();
        // main = section.AddParagraph();
        //main.Format.SpaceBefore = 1;

        // Create the item table for header
        //MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.AddTable();
        MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.Headers.Primary.AddTable();
        tableTop.Style               = "Table";
        tableTop.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tableTop.Borders.Width       = 0.25;
        tableTop.Borders.Left.Width  = 0.5;
        tableTop.Borders.Right.Width = 0.5;
        tableTop.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column columnTop = tableTop.AddColumn("8cm");

        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("3cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("7cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;

        Row rowTop = tableTop.AddRow();

        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible  = false;
        rowTop.Borders.Right.Visible = false;
        rowTop.Borders.Top.Visible   = false;
        //rowTop.Borders.Bottom.Visible = false;
        rowTop.Cells[0].AddParagraph();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph();
        rowTop.Cells[2].AddParagraph();


        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("From:");
        rowTop.Cells[0].AddParagraph("CAPITAL DIGITAL");
        rowTop.Cells[0].AddParagraph("NO. 1, JALAN BUNGA RAYA 1, LANGKAWI MALL");
        rowTop.Cells[0].AddParagraph("07000 KUAH, LANGKAWI");
        rowTop.Cells[0].AddParagraph("KEDAH DARUL AMAN");
        rowTop.Cells[0].AddParagraph("www.capitaldigital.com.my");
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[0].MergeDown = 5;
        rowTop.Cells[1].AddParagraph("Order No");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderno);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Date");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderdate);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Type");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetordertype);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Sales Office");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": CAPITAL DIGITAL LANGKAWI");
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Sales Person");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": HAZZARUL ANAS");
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("Contact No");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": +6017-552 4447");
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("");
        rowTop.Cells[0].MergeRight             = 2;
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("To: ");
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpaddress);
        rowTop.Cells[0].AddParagraph("Contact: " + oModOrder.GetSetbpcontact);
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("Support: ");
        rowTop.Cells[1].AddParagraph("HAZZARUL ANAS HALIM");
        rowTop.Cells[1].AddParagraph("SALES & SUPPORT");
        rowTop.Cells[1].AddParagraph("Contact: +6017-552 4447");
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[1].MergeRight             = 1;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        // Create the item table
        MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
        table.Style               = "Table";
        table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        table.Borders.Width       = 0.25;
        table.Borders.Left.Width  = 0.5;
        table.Borders.Right.Width = 0.5;
        table.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column column = table.AddColumn("0.5cm");

        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("4cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("1cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("1.5cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        // Create the header of the table
        Row row = table.AddRow();

        row.HeadingFormat    = true;
        row.Format.Alignment = ParagraphAlignment.Center;
        row.Format.Font.Bold = true;
        row.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.LightGray;
        row.Cells[0].AddParagraph("NO.");
        row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[1].AddParagraph("ITEM NO");
        row.Cells[1].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[2].AddParagraph("DESCRIPTION");
        row.Cells[2].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[2].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[3].AddParagraph("UNIT PRICE");
        row.Cells[3].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[3].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[4].AddParagraph("DISCOUNT");
        row.Cells[4].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[4].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[5].AddParagraph("QTY");
        row.Cells[5].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[6].AddParagraph("PRICE");
        row.Cells[6].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[6].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[7].AddParagraph("TAX");
        row.Cells[7].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[7].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[8].AddParagraph("TOTAL");
        row.Cells[8].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[8].VerticalAlignment = VerticalAlignment.Bottom;

        for (int i = 0; i < lsOrderLineItem.Count; i++)
        {
            MainModel modOrdDet = (MainModel)lsOrderLineItem[i];

            // Each item fills two rows
            Row row1 = table.AddRow();
            row1.Height     = "2cm";
            row1.TopPadding = 1.5;
            //row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row1.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[4].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[5].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[6].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[7].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[8].Format.Alignment = ParagraphAlignment.Right;

            row1.Cells[0].AddParagraph((i + 1).ToString());
            row1.Cells[1].AddParagraph(modOrdDet.GetSetitemno);
            row1.Cells[2].AddParagraph(modOrdDet.GetSetitemdesc);
            row1.Cells[3].AddParagraph(modOrdDet.GetSetunitprice.ToString("#,##0.00"));
            row1.Cells[4].AddParagraph(modOrdDet.GetSetdiscamount.ToString("#,##0.00"));
            row1.Cells[5].AddParagraph(modOrdDet.GetSetquantity.ToString());
            row1.Cells[6].AddParagraph(modOrdDet.GetSetorderprice.ToString("#,##0.00"));
            row1.Cells[7].AddParagraph(modOrdDet.GetSettaxamount.ToString("#,##0.00"));
            row1.Cells[8].AddParagraph(modOrdDet.GetSettotalprice.ToString("#,##0.00"));

            if (i > 0 && ((i + 1) % 6) == 0)
            {
                row1.Cells[0].Borders.Bottom.Visible = true;
                row1.Cells[1].Borders.Bottom.Visible = true;
                row1.Cells[2].Borders.Bottom.Visible = true;
                row1.Cells[3].Borders.Bottom.Visible = true;
                row1.Cells[4].Borders.Bottom.Visible = true;
                row1.Cells[5].Borders.Bottom.Visible = true;
                row1.Cells[6].Borders.Bottom.Visible = true;
                row1.Cells[7].Borders.Bottom.Visible = true;
                row1.Cells[8].Borders.Bottom.Visible = true;
            }
            else
            {
                row1.Cells[0].Borders.Bottom.Visible = false;
                row1.Cells[1].Borders.Bottom.Visible = false;
                row1.Cells[2].Borders.Bottom.Visible = false;
                row1.Cells[3].Borders.Bottom.Visible = false;
                row1.Cells[4].Borders.Bottom.Visible = false;
                row1.Cells[5].Borders.Bottom.Visible = false;
                row1.Cells[6].Borders.Bottom.Visible = false;
                row1.Cells[7].Borders.Bottom.Visible = false;
                row1.Cells[8].Borders.Bottom.Visible = false;
            }
        }
        if ((lsOrderLineItem.Count % 6) > 0)
        {
            int totalremainingrow = 6 - (lsOrderLineItem.Count % 6);
            for (int j = 0; j < totalremainingrow; j++)
            {
                Row rowRemain = table.AddRow();
                rowRemain.Height = "2cm";
                rowRemain.Cells[0].AddParagraph();
                rowRemain.Cells[1].AddParagraph();
                rowRemain.Cells[2].AddParagraph();
                rowRemain.Cells[3].AddParagraph();
                rowRemain.Cells[4].AddParagraph();
                rowRemain.Cells[5].AddParagraph();
                rowRemain.Cells[6].AddParagraph();
                rowRemain.Cells[7].AddParagraph();
                rowRemain.Cells[8].AddParagraph();

                if (j == (totalremainingrow - 1))
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else if (j > 0 && (j % (totalremainingrow - 1)) == 0)
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = false;
                    rowRemain.Cells[1].Borders.Bottom.Visible = false;
                    rowRemain.Cells[2].Borders.Bottom.Visible = false;
                    rowRemain.Cells[3].Borders.Bottom.Visible = false;
                    rowRemain.Cells[4].Borders.Bottom.Visible = false;
                    rowRemain.Cells[5].Borders.Bottom.Visible = false;
                    rowRemain.Cells[6].Borders.Bottom.Visible = false;
                    rowRemain.Cells[7].Borders.Bottom.Visible = false;
                    rowRemain.Cells[8].Borders.Bottom.Visible = false;
                }
            }
        }

        /*
         * Row rowTax = table.AddRow();
         * //rowTax.Height = "1cm";
         * rowTax.Cells[0].AddParagraph();
         * rowTax.Cells[0].Borders.Left.Visible = false;
         * rowTax.Cells[0].Borders.Right.Visible = false;
         * rowTax.Cells[0].Borders.Bottom.Visible = false;
         * rowTax.Cells[0].MergeRight = 6;
         * rowTax.Cells[7].AddParagraph("TAX");
         * rowTax.Cells[7].Format.Alignment = ParagraphAlignment.Left;
         * rowTax.Cells[8].AddParagraph(oModOrder.GetSettaxamount.ToString("#,##0.00"));
         * rowTax.Cells[8].Format.Alignment = ParagraphAlignment.Right;
         */

        Row rowTot = table.AddRow();

        rowTot.Height           = "1cm";
        rowTot.Format.Font.Bold = true;
        rowTot.Cells[0].AddParagraph();
        rowTot.Cells[0].Borders.Left.Visible   = false;
        rowTot.Cells[0].Borders.Right.Visible  = false;
        rowTot.Cells[0].Borders.Bottom.Visible = false;
        rowTot.Cells[0].MergeRight             = 6;

        /*
         * rowTot.Cells[1].AddParagraph();
         * rowTot.Cells[1].Borders.Left.Visible = false;
         * rowTot.Cells[2].AddParagraph();
         * rowTot.Cells[2].Borders.Left.Visible = false;
         * rowTot.Cells[3].AddParagraph();
         * rowTot.Cells[3].Borders.Left.Visible = false;
         * rowTot.Cells[4].AddParagraph();
         * rowTot.Cells[4].Borders.Left.Visible = false;
         * rowTot.Cells[5].AddParagraph();
         * rowTot.Cells[5].Borders.Left.Visible = false;
         * rowTot.Cells[6].AddParagraph();
         * rowTot.Cells[6].Borders.Left.Visible = false;
         */
        rowTot.Cells[6].Borders.Right.Visible = false;

        rowTot.Cells[7].AddParagraph("GRAND TOTAL");
        rowTot.Cells[7].Format.Alignment     = ParagraphAlignment.Left;
        rowTot.Cells[7].VerticalAlignment    = VerticalAlignment.Center;
        rowTot.Cells[7].Borders.Left.Visible = false;
        //rowTot.Cells[7].Borders.Right.Visible = false;
        rowTot.Cells[7].Borders.Bottom.Visible = false;

        rowTot.Cells[8].AddParagraph(oModOrder.GetSettotalamount.ToString("#,##0.00"));
        rowTot.Cells[8].Format.Alignment  = ParagraphAlignment.Right;
        rowTot.Cells[8].VerticalAlignment = VerticalAlignment.Center;

        //footer.AddText("Footer");
        //footer.Format.Font.Size = 9;
        //footer.Format.Alignment = ParagraphAlignment.Center;

        // Create the item table for footer
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Headers.Primary.AddImage(logo_lima);
        MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Footers.Primary.AddTable();
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.AddTable();
        tblBtm.Style               = "Table";
        tblBtm.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tblBtm.Borders.Width       = 0.25;
        tblBtm.Borders.Left.Width  = 0.5;
        tblBtm.Borders.Right.Width = 0.5;
        tblBtm.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column colTblBtm = tblBtm.AddColumn("6cm");

        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;

        Row rowTblBtm = tblBtm.AddRow();

        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Remarks:");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        //rowTblBtm.Borders.Top.Visible = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetorderremarks);
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Height = "2cm";
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("1. Once the order is confirmed, any cancellation and changes of the order is not allowed.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("2. Delivery lead time is 3 working days upon receive the confirmed Work Order & advert content.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("3. All prices are subject to change without any prior notices.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 1;
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Format.Font.Bold = true;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        //rowTblBtm.Cells[0].Borders.Top.Visible = true;
        rowTblBtm.Cells[1].AddParagraph("CAPITAL DIGITAL");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Confirmed By: (Please stamp and sign)");
        rowTblBtm.Cells[1].AddParagraph("Checked By:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible          = false;
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm.Height = "2cm";
        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Name:");
        rowTblBtm.Cells[1].AddParagraph("Name: HAZZARUL ANAS HALIM");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Designation:");
        rowTblBtm.Cells[1].AddParagraph("Designation: Sales & Marketing Advisor");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Cells[0].AddParagraph("Date:");
        rowTblBtm.Cells[1].AddParagraph("Date:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        // Create a renderer for PDF that uses Unicode font encoding
        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

        // Set the MigraDoc document
        pdfRenderer.Document = doc;

        // Create the PDF document
        pdfRenderer.RenderDocument();

        // Save the document...
        string pdfFilename = sOrderNo + ".pdf";
        string file        = Server.MapPath("~/App_Data/" + pdfFilename);
        //string file = HttpContext.Current.Server.MapPath("~/pdf/" + pdfFilename);
        //string file = "C:/TEMP/" + pdfFilename;

        // ...and start a viewer //
        //pdfRenderer.Save(file);
        //Process.Start(file);

        // Send PDF to browser //
        MemoryStream stream = new MemoryStream();

        pdfRenderer.Save(stream, false);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        Response.End();

        //download file //
        //Response.ContentType = "Application/pdf";
        //Response.AppendHeader("Content-Disposition", "attachment; filename=" + pdfFilename);
        //Response.TransmitFile(file);
        //Response.End();
    }
Пример #60
-2
        /// <summary>
        /// Sets the corner cells of the table to rounded corners.
        /// </summary>
        /// <param name="table"></param>
        public static void SetRoundedCorners(Table table)
        {
            int rowCount = table.Rows.Count;
            int colCount = table.Columns.Count;

            if (rowCount < 2 || colCount < 2)
                return;

            table.Rows[0].Cells[0].RoundedCorner = RoundedCorner.TopLeft;
            table.Rows[0].Cells[colCount - 1].RoundedCorner = RoundedCorner.TopRight;
            table.Rows[rowCount - 1].Cells[colCount - 1].RoundedCorner = RoundedCorner.BottomRight;
            table.Rows[rowCount - 1].Cells[0].RoundedCorner = RoundedCorner.BottomLeft;
        }