SetColor() публичный Метод

Sets the color.
public SetColor ( int red, int green, int blue ) : void
red int the red-value of the new color
green int the green-value of the new color
blue int the blue-value of the new color
Результат void
Пример #1
0
        /// <summary>
        /// Converts a report style to a new font definition.
        /// </summary>
        /// <param name="reportStyle">The report style.</param>
        /// <param name="fontFamily">Name of the font.</param>
        /// <returns>The font.</returns>
        public static Font ConvertStyleToFont(ReportStyle reportStyle, string fontFamily)
        {
            var font = new Font();

            font.SetFamily(fontFamily);

            if (reportStyle.Underline)
            {
                font.SetStyle(Font.UNDERLINE);
            }
            else if (reportStyle.Bold || reportStyle.Italic)
            {
                if (reportStyle.Bold && reportStyle.Italic)
                {
                    font.SetStyle(Font.BOLDITALIC);
                }
                else if (reportStyle.Bold)
                {
                    font.SetStyle(Font.BOLD);
                }
                else
                {
                    font.SetStyle(Font.ITALIC);
                }
            }

            font.Size = reportStyle.FontSize;
            font.SetColor(reportStyle.ForeColor.R, reportStyle.ForeColor.G, reportStyle.ForeColor.B);
            return(font);
        }
        private void cabecalho(Document doc, int num)
        {
            // gera uma nova página
            doc.NewPage();

            // define a fonte a ser utilizada
            iTextSharp.text.Font fonteCab = FontFactory.GetFont("Courier");
            fonteCab.Size = 12;
            fonteCab.SetStyle(2);
            fonteCab.SetColor(5, 0, 125);

            Paragraph cab = new Paragraph("Academia SportFitness", fonteCab);
            cab.Alignment = Element.ALIGN_CENTER;
            doc.Add(cab);

            if (num == 0)
            {
                cab = new Paragraph("Relatório de Alunos Cadastrados", fonteCab);
            }
            else if (num == 1)
            {
                cab = new Paragraph("Relatório de Funcionários Cadastrados", fonteCab);
            }
            else if (num == 2)
            {
                cab = new Paragraph("Relatório do Financeiro (Renda Mensal)", fonteCab);
            }
            cab.Alignment = Element.ALIGN_CENTER;
            doc.Add(cab);

            // muda o tamanho da fonte
            fonteCab.Size = 10;
            fonteCab.SetColor(0, 0, 0);

            cab = new Paragraph(geraTracos(87), fonteCab);
            cab.Alignment = Element.ALIGN_CENTER;
            doc.Add(cab);
        }
        private void PDF_Click(object sender, EventArgs e)
        {
            iTextSharp.text.Image Logo     = iTextSharp.text.Image.GetInstance("C:\\Program Files\\OMB\\Programa OMB Seguros\\Images\\Logo.png");
            iTextSharp.text.Font  palatino = FontFactory.GetFont("MS GOTHIC", 15, iTextSharp.text.Font.BOLD);
            palatino.SetColor(246, 246, 246);

            // VALIDANDO SI EL DATAGRID ESTA VACIO O NO
            if (DataGrid_Listado_Vig_Pol.DataSource == null)
            {
                Alert.Alert.Show_Alert_Message("Genere la tabla para realizar PDF", Alert.Alert.AlertType.warning);
            }
            else
            {
                //CREANDO EL ARCHIVO CON ITEXTSHARP
                PdfPTable pdfTable = new PdfPTable(DataGrid_Listado_Vig_Pol.ColumnCount);
                pdfTable.DefaultCell.Padding         = 3;
                pdfTable.DefaultCell.BackgroundColor = new iTextSharp.text.BaseColor(240, 240, 240);
                pdfTable.WidthPercentage             = 100;
                pdfTable.HorizontalAlignment         = Element.ALIGN_LEFT;
                pdfTable.DefaultCell.BorderWidth     = 1;

                //AÑADIENDO EL HEADER DE LA COLUMNA
                foreach (DataGridViewColumn column in DataGrid_Listado_Vig_Pol.Columns)
                {
                    PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText, palatino));
                    cell.BackgroundColor = new iTextSharp.text.BaseColor(31, 48, 76);
                    pdfTable.AddCell(cell);
                }

                //AÑADIENDO LOS REGISTROS
                foreach (DataGridViewRow row in DataGrid_Listado_Vig_Pol.Rows)
                {
                    try
                    {
                        foreach (DataGridViewCell cell in row.Cells)
                        {
                            if (cell != null)
                            {
                                pdfTable.AddCell(cell.Value.ToString());
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

                //EXPORTANDO A PDF
                SaveFileDialog save = new SaveFileDialog();
                save.FileName = "Reporte Vigencia Polizas";
                save.Filter   = "PDF (*.pdf)|*.pdf";
                if (save.ShowDialog() == DialogResult.OK)
                {
                    FileStream stream = new FileStream(save.FileName, FileMode.Create);

                    Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f);
                    PdfWriter.GetInstance(pdfDoc, stream);
                    pdfDoc.Open();
                    pdfDoc.Add(Logo);
                    pdfDoc.AddTitle("REPORTE VIGENCIA POLIZAS");
                    pdfDoc.Add(new Paragraph("REPORTE VIGENCIA POLIZAS", FontFactory.GetFont("MS GOTHIC", 30, iTextSharp.text.Font.BOLD)));
                    pdfDoc.Add(new Paragraph("                          "));
                    pdfDoc.Add(pdfTable);
                    pdfDoc.Add(new Paragraph("FECHA REPORTE: ", FontFactory.GetFont("ARIAL", 9, iTextSharp.text.Font.UNDERLINE)));
                    pdfDoc.Add(new Paragraph("" + System.DateTime.Now + "", FontFactory.GetFont("ARIAL", 9, iTextSharp.text.Font.NORMAL)));
                    pdfDoc.Close();
                    stream.Close();
                    Alert.Alert.Show_Alert_Message("PDF Guardado correctamente", Alert.Alert.AlertType.success);
                }
                else
                {
                    Alert.Alert.Show_Alert_Message("Error al guardar PDF", Alert.Alert.AlertType.error);
                }
            }
        }
Пример #4
0
        public void addheader()
        {
            iTextSharp.text.Font f1 = FontFactory.GetFont("Arial", 13f, 1);
            f1.Color = BaseColor.BLUE;
            PdfPCell pdfcl = new PdfPCell(new Phrase("Merit List ", f1));

            pdfcl.Colspan = 1;
            f1.IsItalic();
            f1.IsBold();


            //f1.SetStyle(4);
            pdfcl.PaddingTop          = 10f;
            pdfcl.HorizontalAlignment = Element.ALIGN_CENTER;
            pdfcl.BackgroundColor     = BaseColor.WHITE;
            pdfcl.VerticalAlignment   = Element.ALIGN_LEFT;
            pdfcl.Border              = 3;
            pdfcl.BorderColorBottom   = BaseColor.BLACK;
            pdfcl.BorderColorTop      = BaseColor.WHITE;
            pdfcl.BorderColorLeft     = BaseColor.WHITE;
            pdfcl.BorderColorRight    = BaseColor.WHITE;
            pdfcl.ExtraParagraphSpace = 0;
            pdft.AddCell(pdfcl);



            iTextSharp.text.Font f = FontFactory.GetFont("Arial", 15f, 1);

            f.IsBold();
            f.Color = BaseColor.DARK_GRAY;


            PdfPCell pdfcl1 = new PdfPCell(new Phrase("University of Engg & Technology, Lahore ", f));

            pdfcl1.FixedHeight         = 30f;
            pdfcl1.PaddingTop          = 30f;
            pdfcl1.Colspan             = 3;
            pdfcl1.HorizontalAlignment = Element.ALIGN_CENTER;
            pdfcl1.BackgroundColor     = BaseColor.WHITE;
            pdfcl1.Border = 0;
            pdfcl1.ExtraParagraphSpace = 0;
            pdft.AddCell(pdfcl1);

            iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance("G:/Visual Studio Pros/Admission_Office/Admission_Office/Photos/UET_Lahore_Logo.png");
            PdfPCell pdfcl7           = new PdfPCell(img);

            pdfcl7.Colspan       = 2;
            pdfcl7.BorderColor   = BaseColor.WHITE;
            pdfcl7.Border        = 0;
            pdfcl7.PaddingBottom = 5f;

            pdft.AddCell(pdfcl7);

            iTextSharp.text.Font f2 = FontFactory.GetFont("calibri", 10f, 1);
            f2.SetColor(66, 134, 244);
            PdfPCell pdfcl2 = new PdfPCell(new Phrase("ARN number", f2));
            PdfPCell pdfcl3 = new PdfPCell(new Phrase("Name of Student", f2));
            PdfPCell pdfcl6 = new PdfPCell(new Phrase("Email", f2));
            PdfPCell pdfcl4 = new PdfPCell(new Phrase("Aggregate", f2));
            PdfPCell pdfcl5 = new PdfPCell(new Phrase("Dept of Admission", f2));
            PdfPCell pdfcl9 = new PdfPCell(new Phrase("Category", f2));

            pdfcl2.BackgroundColor = BaseColor.LIGHT_GRAY;
            pdfcl2.BorderWidth     = 1f;
            pdfcl3.BorderWidth     = 1f;
            pdfcl4.BorderWidth     = 1f;
            pdfcl5.BorderWidth     = 1f;
            pdfcl6.BorderWidth     = 1f;
            pdfcl9.BorderWidth     = 1f;

            pdfcl2.BorderColor = BaseColor.GRAY;
            pdfcl3.BorderColor = BaseColor.GRAY;
            pdfcl4.BorderColor = BaseColor.GRAY;
            pdfcl5.BorderColor = BaseColor.GRAY;
            pdfcl6.BorderColor = BaseColor.GRAY;
            pdfcl9.BorderColor = BaseColor.GRAY;

            pdfcl2.Left = 10f;
            pdfcl3.Left = 10f;
            pdfcl6.Left = 5f;

            pdfcl3.BackgroundColor = BaseColor.LIGHT_GRAY;
            pdfcl4.BackgroundColor = BaseColor.LIGHT_GRAY;
            pdfcl5.BackgroundColor = BaseColor.LIGHT_GRAY;
            pdfcl6.BackgroundColor = BaseColor.LIGHT_GRAY;
            pdfcl9.BackgroundColor = BaseColor.LIGHT_GRAY;
            pdft.AddCell(pdfcl2);
            pdft.AddCell(pdfcl3);
            pdft.AddCell(pdfcl4);
            pdft.AddCell(pdfcl5);
            pdft.AddCell(pdfcl6);
            pdft.AddCell(pdfcl9);
        }
        private void PDF_Click(object sender, EventArgs e)
        {
            iTextSharp.text.Image Logo     = iTextSharp.text.Image.GetInstance("C:\\Program Files\\OMB\\Programa OMB Seguros\\Images\\Logo.png");
            iTextSharp.text.Font  palatino = FontFactory.GetFont("MS GOTHIC", 15, iTextSharp.text.Font.BOLD);
            palatino.SetColor(246, 246, 246);
            //CREANDO EL ARCHIVO CON ITEXTSHARP
            PdfPTable pdfTable = new PdfPTable(DataGrid_Listado_Veh.ColumnCount);

            pdfTable.DefaultCell.Padding         = 3;
            pdfTable.DefaultCell.BackgroundColor = new iTextSharp.text.BaseColor(224, 224, 224);
            pdfTable.WidthPercentage             = 100;
            pdfTable.HorizontalAlignment         = Element.ALIGN_LEFT;
            pdfTable.DefaultCell.BorderWidth     = 1;

            //AÑADIENDO EL HEADER DE LA COLUMNA
            foreach (DataGridViewColumn column in DataGrid_Listado_Veh.Columns)
            {
                PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText, palatino));
                cell.BackgroundColor = new iTextSharp.text.BaseColor(31, 48, 76);
                pdfTable.AddCell(cell);
            }

            //AÑADIENDO LOS REGISTROS
            foreach (DataGridViewRow row in DataGrid_Listado_Veh.Rows)
            {
                try
                {
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        if (cell != null)
                        {
                            pdfTable.AddCell(cell.Value.ToString());
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            //EXPORTANDO A PDF
            SaveFileDialog save = new SaveFileDialog();

            save.FileName = "Listado Vehiculos";
            save.Filter   = "PDF (*.pdf)|*.pdf";
            if (save.ShowDialog() == DialogResult.OK)
            {
                FileStream stream = new FileStream(save.FileName, FileMode.Create);

                Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f);
                PdfWriter.GetInstance(pdfDoc, stream);
                pdfDoc.Open();
                pdfDoc.Add(Logo);
                pdfDoc.AddTitle("LISTADO VEHICULOS");
                pdfDoc.Add(new Paragraph("LISTADO VEHICULOS", FontFactory.GetFont("MS GOTHIC", 30, iTextSharp.text.Font.BOLD)));
                pdfDoc.Add(new Paragraph("                          "));
                pdfDoc.Add(pdfTable);
                pdfDoc.Add(new Paragraph("FECHA REPORTE: ", FontFactory.GetFont("ARIAL", 9, iTextSharp.text.Font.UNDERLINE)));
                pdfDoc.Add(new Paragraph("" + System.DateTime.Now + "", FontFactory.GetFont("ARIAL", 9, iTextSharp.text.Font.NORMAL)));
                pdfDoc.Close();
                stream.Close();
            }
        }
Пример #6
0
        private PdfPTable CreateTable(LineBean lb)
        {
            BaseFont bf1 = BaseFont.CreateFont("C:\\Windows\\Fonts\\SIMSUN.TTC,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);     //用系统中的字体文件SimSun.ttc创建文件字体

            iTextSharp.text.Font namefont    = new iTextSharp.text.Font(bf1, 12);
            iTextSharp.text.Font contentfont = new iTextSharp.text.Font(bf1, 10);
            contentfont.SetColor(105, 105, 105);

            PdfPTable table = new PdfPTable(4);

            //table.TableEvent = new AlternatingBackground();
            table.WidthPercentage = 85;                    //设置表格占的宽度,百分比
            table.SetWidths(new int[] { 35, 65, 35, 65 }); //两个单元格所占比例 20% 80%
                                                           //table.TotalWidth = 200;//设置表格占的宽度,单位点数
                                                           //table.SetTotalWidth();
                                                           //table.SetWidthPercentage();
            //cell.Colspan = (4); //合并列;
            //cell.Rowspan = (1); //合并行;

            PdfPCell cell = new PdfPCell(new Phrase("测线名称", namefont));

            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.OBSLINENAME, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);


            cell = new PdfPCell(new Phrase("所属场地", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(SiteBll.Instance.GetSitenameByID(lb.SITECODE), contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("曾用名称", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.NAMEBEFORE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("基础测项", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.BASEOBSTYPE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);


            cell = new PdfPCell(new Phrase("辅助测项", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.AIDSOBSTYPE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("观测周期", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.OBSCYCLE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("上盘-下盘", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.UP_BOT, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("建立时间", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.BUILDDATE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("开测时间", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.STARTDATE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);


            cell = new PdfPCell(new Phrase("停测时间", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.ENDDATE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);


            cell = new PdfPCell(new Phrase("测线长度", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.LENGTH, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("测站数", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.STATIONCOUNT, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("所属断层", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.FAULTZONE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);


            cell = new PdfPCell(new Phrase("断层走向", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.FAULTSTRIKE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("断层倾向", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.FAULTTENDENCY, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("断层倾角", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.FAULTDIP, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("夹角", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.LINE_FAULT_ANGLE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("测点岩性", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.PTROCK, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("仪器更换情况", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.INSTRREPLACEDISCRIP, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("运行状况", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.LINESTATUS, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);


            cell = new PdfPCell(new Phrase("起点", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.STARTPOINTCODE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("终点", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(lb.ENDPOINTCODE, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);



            cell = new PdfPCell(new Phrase("备注", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell         = new PdfPCell(new Phrase(lb.NOTE, contentfont));
            cell.Colspan = (3); //合并列;
            table.AddCell(cell);


            return(table);
        }
Пример #7
0
        private PdfPTable CreateTable(SiteBean sb)
        {
            BaseFont bf1 = BaseFont.CreateFont("C:\\Windows\\Fonts\\SIMSUN.TTC,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);     //用系统中的字体文件SimSun.ttc创建文件字体

            iTextSharp.text.Font namefont    = new iTextSharp.text.Font(bf1, 12);
            iTextSharp.text.Font contentfont = new iTextSharp.text.Font(bf1, 10);
            contentfont.SetColor(105, 105, 105);

            PdfPTable table = new PdfPTable(4);

            //table.TableEvent = new AlternatingBackground();
            table.WidthPercentage = 85;                    //设置表格占的宽度,百分比
            table.SetWidths(new int[] { 35, 65, 35, 65 }); //两个单元格所占比例 20% 80%
                                                           //table.TotalWidth = 200;//设置表格占的宽度,单位点数
                                                           //table.SetTotalWidth();
                                                           //table.SetWidthPercentage();
            //cell.Colspan = (4); //合并列;
            //cell.Rowspan = (1); //合并行;

            PdfPCell cell = new PdfPCell(new Phrase("场地名称", namefont));

            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.SiteName, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("所跨断裂断层", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.FaultCode, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("运行状况", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.SiteStatus, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("观测周期", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.ObsCyc, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("历史场地", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.Historysite, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("场地类型", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.SiteType, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("观测类型", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.ObsType, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("标石类型", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.MarkStoneType, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("所在地", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.Place, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            //cell.Colspan = (3); //合并列;
            cell.MinimumHeight = 30;
            table.AddCell(cell);


            cell = new PdfPCell(new Phrase("场地坐标", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.Longtitude + "," + sb.Latitude, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);


            cell = new PdfPCell(new Phrase("海拔高程", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.Altitude.ToString(), contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("起测时间", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.StartDate, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("建设单位", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.BuildUnit, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("监测单位", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.ObsUnit, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("资料变更", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase(sb.Datachg, contentfont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            //cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight = 30;
            cell.Colspan       = (3); //合并列;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("场地概况", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell         = new PdfPCell(new Phrase(sb.SiteSituation, contentfont));
            cell.Colspan = (3); //合并列;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("地质状况", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell         = new PdfPCell(new Phrase(sb.GeoSituation, contentfont));
            cell.Colspan = (3); //合并列;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("备注", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);
            cell         = new PdfPCell(new Phrase(sb.Note, contentfont));
            cell.Colspan = (3); //合并列;
            table.AddCell(cell);

            try
            {
                cell = new PdfPCell(new Phrase("卫星图", namefont));
                cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                cell.MinimumHeight       = 30;
                table.AddCell(cell);
                iTextSharp.text.Image imgremote = null;
                List <RemoteMapBean>  rblist    = RemotemapBll.Instance.GetWhere(new { sitecode = sb.SiteCode }).ToList();
                if (rblist.Count != 0)
                {
                    if (rblist[0].remotemap != null && rblist[0].remotemap.Length > 0)
                    {
                        imgremote = iTextSharp.text.Image.GetInstance(rblist[0].remotemap);
                        imgremote.ScaleToFit(200f, 200f);

                        cell                     = new PdfPCell(imgremote, false);
                        cell.Colspan             = (3); //合并列;
                        cell.MinimumHeight       = 220;
                        cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                        table.AddCell(cell);
                    }
                    else
                    {
                        imgremote = iTextSharp.text.Image.GetInstance(Application.StartupPath + "\\图片缓存\\noPic.png");
                        imgremote.ScaleToFit(50f, 50f);

                        cell                     = new PdfPCell(imgremote, false);
                        cell.Colspan             = (3); //合并列;
                        cell.MinimumHeight       = 60;
                        cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                        table.AddCell(cell);
                    }
                }
                else
                {
                    imgremote = iTextSharp.text.Image.GetInstance(Application.StartupPath + "\\图片缓存\\noPic.png");
                    imgremote.ScaleToFit(50f, 50f);

                    cell                     = new PdfPCell(imgremote, false);
                    cell.Colspan             = (3); //合并列;
                    cell.MinimumHeight       = 60;
                    cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                    table.AddCell(cell);
                }
            }
            catch
            { }

            try
            {
                cell = new PdfPCell(new Phrase("场地图", namefont));
                cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                cell.MinimumHeight       = 30;
                table.AddCell(cell);
                iTextSharp.text.Image imglayout = null;
                List <LayoutmapBean>  lblist    = LayoutmapBll.Instance.GetWhere(new { sitecode = sb.SiteCode }).ToList();
                if (lblist.Count != 0)
                {
                    if (lblist[0].layoutmap != null && lblist[0].layoutmap.Length > 0)
                    {
                        imglayout = iTextSharp.text.Image.GetInstance(lblist[0].layoutmap);
                        imglayout.ScaleToFit(200f, 200f);

                        cell                     = new PdfPCell(imglayout, false);
                        cell.Colspan             = (3); //合并列;
                        cell.MinimumHeight       = 220;
                        cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                        table.AddCell(cell);
                    }
                    else
                    {
                        imglayout = iTextSharp.text.Image.GetInstance(Application.StartupPath + "\\图片缓存\\noPic.png");
                        imglayout.ScaleToFit(50f, 50f);

                        cell                     = new PdfPCell(imglayout, false);
                        cell.Colspan             = (3); //合并列;
                        cell.MinimumHeight       = 60;
                        cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                        table.AddCell(cell);
                    }
                }
                else
                {
                    imglayout = iTextSharp.text.Image.GetInstance(Application.StartupPath + "\\图片缓存\\noPic.png");
                    imglayout.ScaleToFit(50f, 50f);

                    cell                     = new PdfPCell(imglayout, false);
                    cell.Colspan             = (3); //合并列;
                    cell.MinimumHeight       = 60;
                    cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                    table.AddCell(cell);
                }
            }
            catch
            { }

            cell = new PdfPCell(new Phrase("其他情况", namefont));
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(cell);
            cell                     = new PdfPCell(new Phrase(sb.OtherSituation, contentfont));
            cell.Colspan             = (3); //合并列;
            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.MinimumHeight       = 30;
            table.AddCell(cell);

            return(table);
        }
    protected void Prepare_Print()
    {
        String[] weekDays = new String[] { " ","Sun", "Mon", "Tue", "Wed", "Thu" };
        int[] sessions = new int[] {0,1,2,3,4,5,6,7,8,9};
        PdfPTable tblSchedule = new PdfPTable(10);
        PdfPRow[] tempRow = new PdfPRow[6];
        PdfPCell[][] tempCell = new PdfPCell[6][];
        int rowIndex = 0;
        int cellIndex = 0;
        Paragraph subject = new Paragraph();
        Paragraph teacher = new Paragraph();
        Paragraph lunch = new Paragraph();
        Paragraph dayPara = new Paragraph();
        Paragraph sessionPara = new Paragraph();
        Paragraph teacherPara = new Paragraph();

        Font lunch_font = new Font();
        Font day_session_para = new Font();
        Font session_font = new Font();
        Font teacher_font = new Font();

        session_font.Size = 10;
        teacher_font.SetStyle("Italics");
        teacher_font.Size = 7;

        lunch_font.SetColor(153, 153, 255);
        lunch_font.SetStyle("italics");
        lunch = new Paragraph("Lunch", lunch_font);

        day_session_para.SetColor(0, 0, 153);

        foreach (String weekDay in weekDays)
        {
            tempCell[rowIndex] = new PdfPCell[10];
            tempRow[rowIndex] = new PdfPRow(tempCell[rowIndex]);
            foreach (int session in sessions)
            {
                if (session == 0 || session == 6)
                {
                    if (session == 0)
                    {
                        dayPara = new Paragraph(weekDays[rowIndex],day_session_para);
                        tempCell[rowIndex][cellIndex] = new PdfPCell(dayPara);
                    }
                    else
                        if (weekDay != " ")
                        {
                            tempCell[rowIndex][cellIndex] = new PdfPCell(lunch);
                        }
                        else
                        {
                            //tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(Convert.ToString(sessions[cellIndex])));
                            dayPara = new Paragraph(Convert.ToString(sessions[cellIndex]), day_session_para);
                            tempCell[rowIndex][cellIndex] = new PdfPCell(dayPara);
                        }
                }
                else
                {
                    if (weekDay == " ")
                    {
                        dayPara = new Paragraph(Convert.ToString(sessions[cellIndex]), day_session_para);
                        tempCell[rowIndex][cellIndex] = new PdfPCell(dayPara);
                        //tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(Convert.ToString(sessions[cellIndex])));
                    }
                    else
                    {
                        string query = "select B.CourseTitle,A.TeacherID from tblStudentCourseMap as A,tblCourses as B where A.ComCod = B.ComCod and A.DaySession = '" + weekDay + session + "' and A.StudentID = '" + Current_User_ID + "'";
                        myCon.ConOpen();
                        SqlDataReader sessionDet = myCon.ExecuteReader(query);

                        if (sessionDet.Read())
                            if (!sessionDet.IsDBNull(0))
                            {
                                sessionPara = new Paragraph(sessionDet.GetString(0), session_font);
                                //tempCell[rowIndex][cellIndex] = new PdfPCell(sessionPara);
                                teacherPara = new Paragraph(sessionDet.GetString(1), teacher_font);
                                tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(sessionPara));
                                tempCell[rowIndex][cellIndex].Phrase.Add(new Phrase("\n"));
                                tempCell[rowIndex][cellIndex].Phrase.Add(teacherPara);
                                //tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(sessionDet.GetString(0) + "\n" + sessionDet.GetString(1)));
                            }
                            else
                            {
                                tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(""));
                                //tempCell[rowIndex][cellIndex
                            }
                        else
                            tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(""));
                        myCon.ConClose();
                        tempCell[rowIndex][cellIndex].FixedHeight = 75;
                    }

                }

                //tempCell[rowIndex][cellIndex].Width = 50;
                cellIndex++;
                //tempRow[rowIndex].Cells.Add(tempCell[cellIndex++, rowIndex]);
            }
            cellIndex = 0;
            //rowIndex++;
            tblSchedule.Rows.Add(tempRow[rowIndex++]);
        }

        Font HeaderFont = new Font();
        Font HeadingFont = new Font();
        HeaderFont.Size = 20;
        HeaderFont.SetStyle(Font.UNDERLINE);
        HeadingFont.Size = 15;
        HeadingFont.SetStyle(Font.UNDERLINE);
        Paragraph HeaderPara = new Paragraph("BITS PILANI, DUBAI OFFCAMPUS - TIMETABLE", HeaderFont);
        Paragraph HeadingPara = new Paragraph("Time Table allotment for " + Current_User_ID + ".",HeadingFont);
        HeaderPara.Alignment = HeadingPara.Alignment = 1;

        Document rptTimetable = new Document(PageSize.A4_LANDSCAPE.Rotate());
        PdfWriter.GetInstance(rptTimetable, new FileStream(Request.PhysicalApplicationPath + "\\" + Current_User_ID + "_timetable.pdf", FileMode.Create));
        rptTimetable.Open();
        rptTimetable.AddCreationDate();
        rptTimetable.AddHeader("BITS PILANI, DUBAI OFFCAMPUS", "TIMETABLE");
        rptTimetable.Add(new Paragraph("\n"));
        rptTimetable.AddTitle("BITS PILANI, DUBAI OFFCAMPUS - TIMETABLE");
        rptTimetable.Add(HeaderPara);
        rptTimetable.Add(HeadingPara);
        rptTimetable.Add(new Paragraph("\n\n"));

        if (rptTimetable != null && tblSchedule != null)
        {
            rptTimetable.Add(tblSchedule);
        }
        rptTimetable.Close();
        Response.Redirect("~\\" + Current_User_ID + "_timetable.pdf");
    }
Пример #9
0
        private void GetPdfSheet(CouponModel couponModel, iTextSharp.text.Document pdfDoc)
        {
            #region HeaderTable
            // tabla header
            PdfPTable tableHeader = new PdfPTable(4);
            tableHeader.WidthPercentage = 97;
            tableHeader.SetWidths(new[] { 20, 62, 15, 12 });

            BaseFont             bfHeader   = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontHeader = new iTextSharp.text.Font(bfHeader, 7, iTextSharp.text.Font.NORMAL);

            iTextSharp.text.Font fontRed = new iTextSharp.text.Font(bfHeader, 7, iTextSharp.text.Font.NORMAL);
            fontRed.SetColor(255, 0, 0);

            PdfPCell cellHeader = new PdfPCell(new Phrase("", fontHeader));
            cellHeader.Rowspan             = 3;
            cellHeader.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHeader.Border = PdfPCell.NO_BORDER;
            tableHeader.AddCell(cellHeader);

            cellHeader = new PdfPCell(new Phrase("Secretaría de Desarrollo Social", fontHeader));
            cellHeader.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHeader.Border = PdfPCell.NO_BORDER;
            tableHeader.AddCell(cellHeader);

            cellHeader = new PdfPCell(new Phrase("Folio Comedor:", fontHeader));
            //cellHeader.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHeader.Border = PdfPCell.NO_BORDER;
            tableHeader.AddCell(cellHeader);

            cellHeader        = new PdfPCell(new Phrase(couponModel.Folio, fontHeader));
            cellHeader.Border = PdfPCell.NO_BORDER;
            tableHeader.AddCell(cellHeader);

            //linea 2
            cellHeader = new PdfPCell(new Phrase("Programa de Comedores Comunitarios", fontHeader));
            cellHeader.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHeader.Border = PdfPCell.NO_BORDER;
            tableHeader.AddCell(cellHeader);

            cellHeader = new PdfPCell(new Phrase("Folio Vale:", fontHeader));
            //cellHeader.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHeader.Border = PdfPCell.NO_BORDER;
            tableHeader.AddCell(cellHeader);

            cellHeader        = new PdfPCell(new Phrase(couponModel.Coupon_Folio, fontHeader));
            cellHeader.Border = PdfPCell.NO_BORDER;
            tableHeader.AddCell(cellHeader);

            //linea 3
            cellHeader = new PdfPCell(new Phrase("FCCOM G", fontRed));
            cellHeader.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHeader.Border = PdfPCell.NO_BORDER;
            tableHeader.AddCell(cellHeader);

            cellHeader = new PdfPCell(new Phrase("Concepto del Vale:", fontHeader));
            //cellHeader.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHeader.Border = PdfPCell.NO_BORDER;
            tableHeader.AddCell(cellHeader);

            cellHeader = new PdfPCell(new Phrase("ABASTO", fontHeader));
            //cellHeader.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHeader.Border = PdfPCell.NO_BORDER;
            tableHeader.AddCell(cellHeader);

            pdfDoc.Add(tableHeader);

            #endregion

            #region TableLocation
            //*****************************************************************************************
            //tabla location
            PdfPTable tableLoc = new PdfPTable(3);
            tableLoc.WidthPercentage = 97;
            tableLoc.SpacingBefore   = 5;
            tableLoc.SetWidths(new[] { 15, 20, 65 });

            BaseFont             bfLoc   = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontLoc = new iTextSharp.text.Font(bfLoc, 7, iTextSharp.text.Font.NORMAL);


            PdfPCell cellLoc = new PdfPCell(new Phrase("Región:", fontHeader));
            tableLoc.AddCell(cellLoc);

            cellLoc = new PdfPCell(new Phrase(couponModel.Region, fontHeader));
            tableLoc.AddCell(cellLoc);

            cellLoc         = new PdfPCell(new Phrase("Domicilio:\n" + couponModel.Address, fontHeader));
            cellLoc.Rowspan = 5;
            tableLoc.AddCell(cellLoc);

            cellLoc = new PdfPCell(new Phrase("Municipio:", fontHeader));
            tableLoc.AddCell(cellLoc);

            cellLoc = new PdfPCell(new Phrase(couponModel.Description, fontHeader));
            tableLoc.AddCell(cellLoc);

            cellLoc = new PdfPCell(new Phrase("No de Beneficiarios:", fontHeader));
            tableLoc.AddCell(cellLoc);

            cellLoc = new PdfPCell(new Phrase(couponModel.RationQuantity.ToString(), fontHeader));
            tableLoc.AddCell(cellLoc);

            cellLoc = new PdfPCell(new Phrase("Fecha de Solicitud:", fontHeader));
            tableLoc.AddCell(cellLoc);

            cellLoc = new PdfPCell(new Phrase(DateTime.Now.ToShortDateString(), fontHeader));
            tableLoc.AddCell(cellLoc);

            pdfDoc.Add(tableLoc);
            #endregion

            #region ProductTable
            //*****************************************************************************************
            //tabla productos
            PdfPTable table = new PdfPTable(13);
            table.WidthPercentage = 97;
            table.SpacingBefore   = 5;

            table.SetWidths(new[] { 3, 39, 10, 10, 10, 10, 10, 10, 10, 4, 4, 4, 4 });
            BaseFont             bf     = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontTP = new iTextSharp.text.Font(bf, 7, iTextSharp.text.Font.NORMAL);


            //linea 1
            PdfPCell cell = new PdfPCell(new Phrase(""));
            cell.Colspan             = 3;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.Border = PdfPCell.NO_BORDER;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("Primera Entrega", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(165, 165, 165);
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("Segunda Entrega", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(165, 165, 165);
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("Tercera Entrega", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(165, 165, 165);
            table.AddCell(cell);

            cell          = new PdfPCell(new Phrase("Tercera Entrega", fontTP));
            cell.Rotation = -90;
            cell.Rowspan  = 6;
            table.AddCell(cell);

            cell          = new PdfPCell(new Phrase("Segunda Entrega", fontTP));
            cell.Rotation = -90;
            cell.Rowspan  = 6;
            table.AddCell(cell);

            cell          = new PdfPCell(new Phrase("Primera Entrega", fontTP));
            cell.Rotation = -90;
            cell.Rowspan  = 6;
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase("Nombre responsable DICOINSA", fontTP));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(216, 216, 216);
            cell.Rotation            = -90;
            cell.Rowspan             = 27;
            table.AddCell(cell);

            //linea 2
            cell                     = new PdfPCell(new Phrase("Descripción del Producto", fontTP));
            cell.Colspan             = 2;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(216, 216, 216);
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase("Cantidad Solicitada", fontTP));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(216, 216, 216);
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase("Cantidad Entregada", fontTP));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(216, 216, 216);
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase("Diferencia Pendiente", fontTP));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(216, 216, 216);
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase("Cantidad Entregada", fontTP));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(216, 216, 216);
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase("Diferencia Pendiente", fontTP));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(216, 216, 216);
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase("Cantidad Entregada", fontTP));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(216, 216, 216);
            table.AddCell(cell);
            cell = new PdfPCell(new Phrase("Diferencia Pendiente", fontTP));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(216, 216, 216);
            table.AddCell(cell);



            for (int i = 1; i < 54; i++)
            {
                cell = new PdfPCell(new Phrase(i.ToString(), fontTP));
                cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242);
                table.AddCell(cell);
                if (couponModel.ListProduct.Count > i)
                {
                    cell = new PdfPCell(new Phrase(couponModel.ListProduct[i - 1].Description.ToString(), fontTP));
                    cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242);
                    table.AddCell(cell);
                    cell = new PdfPCell(new Phrase(couponModel.ListProduct[i - 1].QuantityCoupon.ToString(), fontTP));
                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    table.AddCell(cell);
                }
                else
                {
                    cell = new PdfPCell(new Phrase("", fontTP));
                    cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242);
                    table.AddCell(cell);
                    cell = new PdfPCell(new Phrase("", fontTP));
                    table.AddCell(cell);
                }
                cell = new PdfPCell(new Phrase("", fontTP));
                table.AddCell(cell);
                cell = new PdfPCell(new Phrase("", fontTP));
                table.AddCell(cell);
                cell = new PdfPCell(new Phrase("", fontTP));
                table.AddCell(cell);
                cell = new PdfPCell(new Phrase("", fontTP));
                table.AddCell(cell);
                cell = new PdfPCell(new Phrase("", fontTP));
                table.AddCell(cell);
                cell = new PdfPCell(new Phrase("", fontTP));
                table.AddCell(cell);
                if (i == 5)
                {
                    cell         = new PdfPCell(new Phrase(" ", fontTP));
                    cell.Rowspan = 21;
                    table.AddCell(cell);

                    cell         = new PdfPCell(new Phrase(" ", fontTP));
                    cell.Rowspan = 21;
                    table.AddCell(cell);

                    cell         = new PdfPCell(new Phrase(" ", fontTP));
                    cell.Rowspan = 21;
                    table.AddCell(cell);
                }
                if (i == 26)
                {
                    cell          = new PdfPCell(new Phrase("Tercera Entrega", fontTP));
                    cell.Rotation = -90;
                    cell.Rowspan  = 6;
                    table.AddCell(cell);

                    cell          = new PdfPCell(new Phrase("Segunda Entrega", fontTP));
                    cell.Rotation = -90;
                    cell.Rowspan  = 6;
                    table.AddCell(cell);

                    cell          = new PdfPCell(new Phrase("Primera Entrega", fontTP));
                    cell.Rotation = -90;
                    cell.Rowspan  = 6;
                    table.AddCell(cell);

                    cell                     = new PdfPCell(new Phrase("Nombre Vocal de Alimentación", fontTP));
                    cell.Rowspan             = 28;
                    cell.BackgroundColor     = new iTextSharp.text.BaseColor(216, 216, 216);
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell.Rotation            = -90;
                    table.AddCell(cell);
                }
                if (i == 32)
                {
                    cell         = new PdfPCell(new Phrase(" ", fontTP));
                    cell.Rowspan = 22;
                    table.AddCell(cell);

                    cell         = new PdfPCell(new Phrase(" ", fontTP));
                    cell.Rowspan = 22;
                    table.AddCell(cell);

                    cell          = new PdfPCell(new Phrase(couponModel.Contact, fontTP));
                    cell.Rowspan  = 22;
                    cell.Rotation = -90;
                    table.AddCell(cell);
                }
            }

            //footer
            cell                     = new PdfPCell(new Phrase("Fecha de la Entrega:", fontTP));
            cell.Colspan             = 3;
            cell.Rowspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("DD/MM/AAAA", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(242, 242, 242);
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("DD/MM/AAAA", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(242, 242, 242);
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("DD/MM/AAAA", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.BackgroundColor     = new iTextSharp.text.BaseColor(242, 242, 242);
            table.AddCell(cell);

            cell         = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan = 4;
            cell.Rowspan = 2;
            table.AddCell(cell);

            //linea 2
            cell                     = new PdfPCell(new Phrase(" ", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(cell);

            //footer
            cell                     = new PdfPCell(new Phrase("Firma Responsable DICOINSA:", fontTP));
            cell.Colspan             = 3;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.FixedHeight         = 20;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.FixedHeight         = 20;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.FixedHeight         = 20;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.FixedHeight         = 20;
            table.AddCell(cell);

            cell             = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan     = 4;
            cell.FixedHeight = 20;
            table.AddCell(cell);

            //footer
            cell                     = new PdfPCell(new Phrase("Firma Vocal de Alimentación:", fontTP));
            cell.Colspan             = 3;
            cell.Rowspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.FixedHeight         = 20;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.FixedHeight         = 20;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan             = 2;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.FixedHeight         = 20;
            table.AddCell(cell);

            cell             = new PdfPCell(new Phrase("", fontTP));
            cell.Colspan     = 4;
            cell.FixedHeight = 20;
            table.AddCell(cell);

            pdfDoc.Add(table);

            #endregion

            #region FooterTable
            //*************************** tabla footer
            PdfPTable tablefooter = new PdfPTable(1);
            tablefooter.WidthPercentage = 97;
            tablefooter.SpacingBefore   = 7;
            tablefooter.SetWidths(new[] { 100 });

            BaseFont             bfFooter   = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontFooter = new iTextSharp.text.Font(bfFooter, 7, iTextSharp.text.Font.NORMAL);

            PdfPCell cellFooter = new PdfPCell(new Phrase("Este Programa es público, ajeno a cualquier partido político. Queda prohibido su uso para fines distintos al desarrollo social.", fontFooter));
            cellFooter.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFooter.Border = PdfPCell.NO_BORDER;
            tablefooter.AddCell(cellFooter);

            pdfDoc.Add(tablefooter);

            #endregion

            iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(Server.MapPath("../img") + "/logo_logo_color_Sedesol_gobmx.png");
            pdfImage.ScaleToFit(100, 50);
            pdfImage.Alignment = iTextSharp.text.Image.UNDERLYING; pdfImage.SetAbsolutePosition(30, 800);
            pdfDoc.Add(pdfImage);

            //return pdfDoc;
        }
Пример #10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            iText.Rectangle pageSize = new iText.Rectangle(216f, 1000f);
            pageSize.BackgroundColor = BaseColor.BLUE;
            Document document = new Document();
            //			Document document = new Document(pageSize, 72, 72, 144, 144);
            //			Document doc = new Document(PageSize.LETTER);
            //			Document doc = new Document(PageSize.LETTER.Rotate());

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(@"HelloWorld.pdf", FileMode.Create));

            writer.PageEvent = new FoxDogGeneric1();

            document.AddTitle("Hello world example");
            document.AddSubject("This example shows how to add metadata");
            document.AddKeywords("Metadata, iText, step 3, tutorial");
            document.AddCreator("My program using iText");
            document.AddAuthor("Bruno Lowagie");
            document.AddHeader("Expires", "0");
            document.Open();

            /* chapter04/FoxDogChunk1.java */
            document.Add(new Paragraph("This is an example of chunks"));
            iText.Font font = new iText.Font(iText.Font.FontFamily.COURIER, 10, iText.Font.BOLD);
            font.SetColor(0xFF, 0xFF, 0xFF);
            Chunk fox = new Chunk("quick brown fox", font);

            fox.SetBackground(new BaseColor(0xa5, 0x2a, 0x2a));
            Chunk jumps = new Chunk(" jumps over ", new iText.Font());
            Chunk dog   = new Chunk("the lazy dog", new iText.Font(iText.Font.FontFamily.TIMES_ROMAN, 14, iText.Font.ITALIC));

            document.Add(fox);
            document.Add(jumps);
            document.Add(dog);

            document.Add(new Paragraph("This is an example of a Phrase"));

            /* chapter04/FoxDogPhrase.java */
            Phrase phrase = new Phrase(30);
            Chunk  space  = new Chunk(' ');

            phrase.Add(fox);
            phrase.Add(jumps);
            phrase.Add(dog);
            phrase.Add(space);

            for (int i = 0; i < 10; i++)
            {
                document.Add(phrase);
            }

            document.Add(new Paragraph("This is an example of a Paragraph"));

            /* chapter04/FoxDogParagraph.java */
            String    text      = "Quick brown fox jumps over the lazy dog.";
            Phrase    phrase1   = new Phrase(text);
            Phrase    phrase2   = new Phrase(new Chunk(text, new iText.Font(iText.Font.FontFamily.TIMES_ROMAN)));
            Phrase    phrase3   = new Phrase(text, new iText.Font(iText.Font.FontFamily.COURIER));
            Paragraph paragraph = new Paragraph();

            paragraph.Add(phrase1);
            paragraph.Add(space);
            paragraph.Add(phrase2);
            paragraph.Add(space);
            paragraph.Add(phrase3);
            paragraph.Alignment       = Element.ALIGN_RIGHT;
            paragraph.IndentationLeft = 20;
            document.Add(paragraph);
            document.Add(paragraph);

            document.Add(new Paragraph("This is an example of a link. Click the text below."));

            /* chapter04/FoxDogAnchor1.java */
            Anchor anchor = new Anchor("Quick brown fox jumps over the lazy dog.");

            anchor.Reference = "http://en.wikipedia.org/wiki/The_quick_brown_fox_jumps_over_the_lazy_dog";
            document.Add(anchor);

            document.Add(new Paragraph("This is an example of some lists"));

            /* chapter04/FoxDogList1.java */
            List list1 = new List(List.ORDERED, 20);

            list1.Add(new ListItem("the lazy dog"));
            document.Add(list1);
            List list2 = new List(List.UNORDERED, 10);

            list2.Add("the lazy cat");
            document.Add(list2);
            List list3 = new List(List.ORDERED, List.ALPHABETICAL, 20);

            list3.Add(new ListItem("the fence"));
            document.Add(list3);
            List list4 = new List(List.UNORDERED, 30);

            list4.SetListSymbol("----->");
            list4.IndentationLeft = 10;
            list4.Add("the lazy dog");
            document.Add(list4);
            List list5 = new List(List.ORDERED, 20);

            list5.First = 11;
            list5.Add(new ListItem("the lazy cat"));
            document.Add(list5);
            List list = new List(List.UNORDERED, 10);

            list.SetListSymbol("*");
            list.Add(list1);
            list.Add(list3);
            list.Add(list5);
            document.Add(list);

            /* chapter04/FoxDogChapter1.java */
            Chapter chapter1 = new Chapter(new Paragraph("This is a sample sentence:", font), 1);

            chapter1.Add(new Paragraph(text));
            Section section1 = chapter1.AddSection("Quick", 0);

            section1.Add(new Paragraph(text));
            document.Add(chapter1);

            /* chapter04/FoxDogScale.java */
            Chunk     c = new Chunk("quick brown fox jumps over the lazy dog");
            float     w = c.GetWidthPoint();
            Paragraph p = new Paragraph("The width of the chunk: '");

            p.Add(c);
            p.Add("' is ");
            p.Add(w.ToString());
            p.Add(" points or ");
            p.Add((w / 72f).ToString());
            p.Add(" inches or ");
            p.Add((w / 72f * 2.54f).ToString());
            p.Add(" cm.");
            document.Add(p);

            document.Add(new Paragraph("SetGenericTag Example"));

            /* chapter04/FoxDogGeneric1.java */
            p   = new Paragraph();
            fox = new Chunk("Quick brown fox");
            fox.SetGenericTag("box");
            p.Add(fox);
            p.Add(" jumps over ");
            dog = new Chunk("the lazy dog.");
            dog.SetGenericTag("ellipse");
            p.Add(dog);
            document.Add(p);

            document.Close();

            string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

            webBrowser1.Navigate(string.Concat(appPath, "\\", @"HelloWorld.pdf"));
        }
Пример #11
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            /*
             *  Generate PDF - Creating Invoice Details
             *  Fake data - Invoice Num, Invoice Date and Description
             */
            string invoiceNum  = invoiceNumTB.Text;
            string date        = DateTime.Now.ToString("dd-MMMM-yyyy");
            string description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore";

            Document  doc  = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
            string    path = Server.MapPath("Invoices");
            PdfWriter wri  = PdfWriter.GetInstance(doc, new FileStream(path + "/" + invoiceNum + ".pdf", FileMode.Create));

            doc.Open();

            /*
             *  Creating Invoice - Insert Header (Logo at the top left & Billing Address at the Right)
             */
            PdfPTable header = new PdfPTable(3);

            header.TotalWidth  = 550f;
            header.LockedWidth = true;
            float[] headerWidths = new float[] { 2f, 1f, 2f };
            header.SetWidths(headerWidths);
            header.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;

            string imagePath = Server.MapPath("images");

            iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(imagePath + "/logo1.png");
            logo.ScalePercent(70);

            PdfPCell logoCell = new PdfPCell(logo, false);

            logoCell.Border              = 0;
            logoCell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            logoCell.HorizontalAlignment = Element.ALIGN_CENTER;
            header.AddCell(logoCell);

            Paragraph emptySpace = new Paragraph(" ");

            header.AddCell(emptySpace);


            PdfPTable addressTable = new PdfPTable(1);

            addressTable.TotalWidth  = 220f;
            addressTable.LockedWidth = true;
            PdfPCell companyName    = new PdfPCell(new Phrase("ABC Company Pte Ltd", getBigFontSize()));
            PdfPCell companyStreet  = new PdfPCell(new Phrase("1234 SomeStreet", getNormalFontSize()));
            PdfPCell companyAddress = new PdfPCell(new Phrase("Anywhere USA 21212", getNormalFontSize()));

            companyName.Border    = 0;
            companyStreet.Border  = 0;
            companyAddress.Border = 0;
            addressTable.AddCell(companyName);
            addressTable.AddCell(companyStreet);
            addressTable.AddCell(companyAddress);
            addressTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
            header.AddCell(addressTable);

            header.AddCell(emptySpace);

            iTextSharp.text.Font whiteFont = getInvoiceTextFontSize();
            whiteFont.SetColor(255, 255, 255);
            PdfPCell invoiceHeader = new PdfPCell(new Phrase("Invoice", whiteFont));

            invoiceHeader.Border = 0;
            invoiceHeader.HorizontalAlignment = Element.ALIGN_CENTER;
            invoiceHeader.VerticalAlignment   = Element.ALIGN_TOP;
            invoiceHeader.BackgroundColor     = new iTextSharp.text.BaseColor(102, 180, 51);

            header.AddCell(invoiceHeader);
            header.AddCell(emptySpace);

            doc.Add(header);

            /*
             *  Creating Invoice - Display Invoice information
             */
            PdfPTable paragraph = new PdfPTable(1);

            paragraph.TotalWidth  = 550f;
            paragraph.LockedWidth = true;

            PdfPCell invoiceNoCell = new PdfPCell(new Phrase("Invoice Number: " + invoiceNum));

            invoiceNoCell.BackgroundColor = new iTextSharp.text.BaseColor(222, 223, 222);

            invoiceNoCell.Border = 0;
            paragraph.AddCell(invoiceNoCell);

            PdfPCell invoiceDateCell = new PdfPCell(new Phrase("Date: " + date));

            invoiceDateCell.BackgroundColor = new iTextSharp.text.BaseColor(222, 223, 222);
            invoiceDateCell.Border          = 0;
            paragraph.AddCell(invoiceDateCell);

            PdfPCell invoiceDescriptionCell = new PdfPCell(new Phrase("\nDescription: \n" + description));

            invoiceDescriptionCell.BackgroundColor = new iTextSharp.text.BaseColor(222, 223, 222);
            invoiceDescriptionCell.Border          = 0;
            paragraph.AddCell(invoiceDescriptionCell);

            doc.Add(paragraph);
            doc.Add(emptySpace);    //Enter Spaace at the bottom


            /*
             *  Creating Invoice - Purchase Order Items
             *  For demo purposes, i have used ArrayList to store and display demo data.
             *  Data can also be displayed from Database
             */
            PdfPTable table = new PdfPTable(4);

            table.TotalWidth  = 550f;
            table.LockedWidth = true;
            float[] widths = new float[] { 6f, 1f, 1f, 1f };
            table.SetWidths(widths);

            PdfPCell cell1 = new PdfPCell(new Phrase("Product Name"));

            cell1.BackgroundColor = new iTextSharp.text.BaseColor(222, 223, 222);
            table.AddCell(cell1);
            PdfPCell cell2 = new PdfPCell(new Phrase("Unit Price"));

            cell2.BackgroundColor = new iTextSharp.text.BaseColor(222, 223, 222);
            table.AddCell(cell2);
            PdfPCell cell3 = new PdfPCell(new Phrase("Quantiy"));

            cell3.BackgroundColor = new iTextSharp.text.BaseColor(222, 223, 222);
            table.AddCell(cell3);
            PdfPCell cell4 = new PdfPCell(new Phrase("Sub-Total"));

            cell4.BackgroundColor = new iTextSharp.text.BaseColor(222, 223, 222);
            table.AddCell(cell4);

            double totalCost = 0;

            foreach (PurchasedItem pi in purchasedOrder)
            {
                double totalUnitPrice = Math.Round(pi.Qt * pi.UnitPrice, 2);
                totalCost += totalUnitPrice;
                table.AddCell(pi.ProductName);
                table.AddCell("$" + pi.UnitPrice.ToString("F"));
                table.AddCell(pi.Qt.ToString());
                table.AddCell("$" + totalUnitPrice.ToString("F"));
            }

            PdfPCell cellTotalDescription = new PdfPCell(new Phrase("Total Price"));

            cellTotalDescription.Colspan         = 3;
            cellTotalDescription.BackgroundColor = new iTextSharp.text.BaseColor(222, 223, 222);
            cellTotalDescription.PaddingRight    = 1;
            table.AddCell(cellTotalDescription);

            PdfPCell cellTotal = new PdfPCell(new Phrase("$" + totalCost.ToString("F")));

            cellTotal.BackgroundColor = new iTextSharp.text.BaseColor(222, 223, 222);
            table.AddCell(cellTotal);

            doc.Add(table);
            doc.Add(emptySpace);
            doc.Add(emptySpace);

            /*
             *  Creating Invoice - Display Invoice Footer
             */
            string    currentDate = System.DateTime.Today.ToShortDateString();
            Paragraph footer      = new Paragraph("PDF Generated on: " + currentDate);

            doc.Add(footer);
            doc.Close();

            /*
             *  // Sending Invoice PDF to Customer's Email
             *  string email = "*****@*****.**"; //Attach customer email address
             *  string fileName = path + "/" + invoiceNum + ".pdf"; // attach the invoice number
             *  SendEmail(email, fileName); // SendEmail Function
             */

            Response.Write("<script>alert('" + invoiceNumTB.Text + ".pdf has been generated in Invoices folder in the working directory!');</script>");
        }
Пример #12
0
        public void CreatePdfForDayRecomendations()
        {
            List <Tuple <string, string> > tuples = getAllProductsTupleNameKey();
            List <DayOfWeek> days = new List <DayOfWeek>();

            days.Add(DayOfWeek.Sunday);
            days.Add(DayOfWeek.Monday);
            days.Add(DayOfWeek.Tuesday);
            days.Add(DayOfWeek.Wednesday);
            days.Add(DayOfWeek.Thursday);
            days.Add(DayOfWeek.Friday);
            days.Add(DayOfWeek.Saturday);

            PdfPTable table = new PdfPTable(2);

            PdfPCell cell = new PdfPCell(new Phrase("Item Name"));

            cell.Colspan = 1;

            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right

            table.AddCell(cell);
            PdfPCell cell2 = new PdfPCell(new Phrase("Best Day"));

            cell2.Colspan = 1;

            cell2.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right

            table.AddCell(cell2);
            foreach (var tuple in tuples)
            {
                int       quantity    = 0;
                int       maxQuantity = 0;
                DayOfWeek dayOfWeek   = new DayOfWeek();
                foreach (DayOfWeek day in days)
                {
                    List <Item> items = idal.getAllItems(y => y.Date_of_purchase.DayOfWeek == day && y.SerialKey == tuple.Item1);
                    foreach (var item in items)
                    {
                        quantity += item.Quantity;
                    }
                    if (quantity > maxQuantity)
                    {
                        maxQuantity = quantity;
                        dayOfWeek   = day;
                    }
                }
                table.AddCell(tuple.Item2);
                table.AddCell(dayOfWeek.ToString());
            }
            Document doc = new Document(PageSize.A4, 7f, 5f, 5f, 0f);

            doc.AddTitle("Machine Learning results");
            PdfWriter.GetInstance(doc, new FileStream(AppDomain.CurrentDomain.BaseDirectory + "Recommended Days.pdf", FileMode.Create));
            doc.Open();
            //     Paragraph p1 = new Paragraph(text);
            //   doc.Add(p1);

            doc.Add(table);
            Font x = FontFactory.GetFont("nina fett");

            x.Size = 19;

            x.SetStyle("Italic");

            x.SetColor(0, 42, 255);


            Paragraph c2 = new Paragraph(@"Based on our recommendations for which products to buy on which  day", x);

            c2.IndentationLeft = 30;
            doc.Add(c2);


            doc.Close();
        }
Пример #13
0
        public void CreatePdfForStoreRecomendations()
        {
            List <string> storeNames = getAllStoreNames();
            List <Tuple <string, string> > tuples = getAllProductsTupleNameKey();
            string text = "";

            PdfPTable table = new PdfPTable(2);

            PdfPCell cell = new PdfPCell(new Phrase("Item Name"));

            cell.Colspan = 1;

            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right

            table.AddCell(cell);
            PdfPCell cell2 = new PdfPCell(new Phrase("Store Name"));

            cell2.Colspan = 1;

            cell2.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right

            table.AddCell(cell2);
            foreach (var tuple in tuples)
            {
                float  bestScore = 0;
                string storeName = "";
                foreach (var store in storeNames)
                {
                    ModelInput sampleData = new ModelInput()
                    {
                        Store_name = store,
                        SerialKey  = tuple.Item1,
                    };
                    var predictionResult = ConsumeModel.Predict(sampleData);
                    if (predictionResult.Score >= bestScore || bestScore == 0)
                    {
                        bestScore = predictionResult.Score;
                        storeName = store;
                    }
                }
                table.AddCell(tuple.Item2);
                table.AddCell(storeName);
            }
            Document doc = new Document(PageSize.A4, 7f, 5f, 5f, 0f);

            doc.AddTitle("Machine Learning results");
            PdfWriter.GetInstance(doc, new FileStream(AppDomain.CurrentDomain.BaseDirectory + "Recommended Stores.pdf", FileMode.Create));
            doc.Open();
            //     Paragraph p1 = new Paragraph(text);
            //   doc.Add(p1);

            doc.Add(table);
            Font x = FontFactory.GetFont("nina fett");

            x.Size = 19;

            x.SetStyle("Italic");

            x.SetColor(0, 42, 255);


            Paragraph c2 = new Paragraph(@"Based on our recommendations for which products to buy in which store", x);

            c2.IndentationLeft = 30;
            doc.Add(c2);


            doc.Close();
        }