protected void CreatePage(IList <Student> students) { Section section = this.document.AddSection(); this.table = section.AddTable(); this.table.Style = "Table"; this.table.Borders.Color = Colors.Black; this.table.Borders.Width = 0.25; this.table.Borders.Left.Width = 0.5; this.table.Borders.Right.Width = 0.5; this.table.Rows.LeftIndent = 0; MigraDoc.DocumentObjectModel.Tables.Column column = this.table.AddColumn("4cm"); //first name, father initial, last name column.Format.Alignment = ParagraphAlignment.Center; column = this.table.AddColumn("3cm");//specialization column.Format.Alignment = ParagraphAlignment.Left; column = this.table.AddColumn("2cm"); //final grade column.Format.Alignment = ParagraphAlignment.Left; column = this.table.AddColumn("2cm"); //addmision grade column.Format.Alignment = ParagraphAlignment.Left; column = this.table.AddColumn("2cm"); //baccalaureat average grade column.Format.Alignment = ParagraphAlignment.Left; column = this.table.AddColumn("2cm"); //baccalaureat maximum grade column.Format.Alignment = ParagraphAlignment.Left; column = this.table.AddColumn("3cm"); //status column.Format.Alignment = ParagraphAlignment.Left; MigraDoc.DocumentObjectModel.Tables.Row row = this.table.AddRow(); row.HeadingFormat = true; row.Format.Alignment = ParagraphAlignment.Center; row.Format.Font.Bold = true; row.Borders.Bottom.Visible = true; row.Borders.Bottom.Width = 1; row.Cells[0].AddParagraph("Student"); row.Cells[1].AddParagraph("Specialization"); row.Cells[2].AddParagraph("Final Grade"); row.Cells[3].AddParagraph("Admission"); row.Cells[4].AddParagraph("Average"); row.Cells[5].AddParagraph("Maximum"); row.Cells[6].AddParagraph("Status"); for (int j = 0; j < 7; j++) { row.Cells[j].Format.Font.Bold = true; row.Cells[j].Format.Alignment = ParagraphAlignment.Justify; row.Cells[j].Borders.Bottom.Width = 0.25; } for (int i = 0; i < students.Count; i++) { row = this.table.AddRow(); Student current = students.ElementAt(i); row.Cells[0].AddParagraph(current.FirstName + " " + current.FatherInitial + " " + current.LastName); row.Cells[1].AddParagraph(current.Specialization); row.Cells[2].AddParagraph(current.FinalGrade.ToString()); row.Cells[3].AddParagraph(current.AdmissionExamGrade.ToString()); row.Cells[4].AddParagraph(current.BaccalaureatAverageGrade.ToString()); row.Cells[5].AddParagraph(current.BaccalaureatMaximumGrade.ToString()); row.Cells[6].AddParagraph(current.Status); row.Borders.Bottom.Visible = true; row.Borders.Bottom.Width = 0.25; } }
public Document CriaRelatorio() { Document relatorio = new Document(); Section section = relatorio.AddSection(); MigraDoc.DocumentObjectModel.Shapes.Image img = section.Headers.Primary.AddImage("gustavo2.png"); img.Height = "15cm"; img.LockAspectRatio = true; img.RelativeVertical = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Page; img.RelativeHorizontal = MigraDoc.DocumentObjectModel.Shapes.RelativeHorizontal.Page; img.Top = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center; img.Left = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center; img.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through; section.PageSetup.TopMargin = 25; section.PageSetup.LeftMargin = 25; section.PageSetup.RightMargin = 25; section.PageSetup.BottomMargin = 25; section.PageSetup.PageFormat = PageFormat.A4; #region HeaderRelatorio Paragraph primeira_linha = section.AddParagraph("RELATÓRIO DE ENTRADA DÍZIMOS E OFERTAS - IGREJA BATISTA RENOVO"); primeira_linha.Format.Alignment = ParagraphAlignment.Center; MigraDoc.DocumentObjectModel.Tables.Table tabela_header = new MigraDoc.DocumentObjectModel.Tables.Table(); MigraDoc.DocumentObjectModel.Tables.Row linha_header; tabela_header.Borders.Width = 0.5; MigraDoc.DocumentObjectModel.Tables.Column coluna_header = tabela_header.AddColumn("18cm"); coluna_header.Format.Font.Name = "Calibri"; coluna_header.Shading.Color = Colors.WhiteSmoke; linha_header = tabela_header.AddRow(); linha_header.Format.Alignment = ParagraphAlignment.Center; linha_header.Format.Font.Bold = true; linha_header.Cells[0].AddParagraph(System.DateTime.Now.ToString("dd/MM/yyyy") + " - " + Util.Funcoes.RetornaDia() + "(" + Util.Funcoes.RetornaPeriodo() + ")"); tabela_header.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black); relatorio.LastSection.Add(tabela_header); #endregion Paragraph quebra_linha_headerReport = section.AddParagraph(""); #region HeaderTabela MigraDoc.DocumentObjectModel.Tables.Table tabela_dizimistas; MigraDoc.DocumentObjectModel.Tables.Row linha_dizimistas; tabela_dizimistas = new MigraDoc.DocumentObjectModel.Tables.Table(); tabela_dizimistas.Borders.Width = 0.5; MigraDoc.DocumentObjectModel.Tables.Column coluna1 = tabela_dizimistas.AddColumn("14cm"); coluna1.Format.Font.Name = "Calibri"; MigraDoc.DocumentObjectModel.Tables.Column coluna2 = tabela_dizimistas.AddColumn("4cm"); coluna2.Format.Font.Name = "Calibri"; linha_dizimistas = tabela_dizimistas.AddRow(); linha_dizimistas.Shading.Color = Colors.Black; linha_dizimistas.Format.Font.Color = Colors.White; linha_dizimistas.Format.Font.Bold = true; linha_dizimistas.Format.Alignment = ParagraphAlignment.Center; linha_dizimistas.Cells[0].AddParagraph("DIZIMISTA"); linha_dizimistas.Cells[1].AddParagraph("VALOR"); #endregion #region ItensTabela decimal total_dizimos = 0; var listaDetalhes = _unitOfWork.CabecalhosEntradas.ListaDetalhes(Convert.ToInt32(Util.DataCript.Decriptar(HttpContext.Session.GetString("_hash")))); EntradaResponse total = new EntradaResponse { VlTotalDizimo = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 1).Sum(s => s.Valor), VlTotalOferta = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 2).Sum(s => s.Valor), VlTotalMissoes = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 3).Sum(s => s.Valor), VlTotalReforma = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 4).Sum(s => s.Valor), VlTotalNotas = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 1).Sum(s => s.Valor), VlTotalMoedas = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 2).Sum(s => s.Valor), VlTotalCheque = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 3).Sum(s => s.Valor), VlTotalDebito = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 4).Sum(s => s.Valor), VlTotalCredito = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 5).Sum(s => s.Valor), VlTotalTransf = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 6).Sum(s => s.Valor), }; total.VlTotalCategoria = total.VlTotalDizimo + total.VlTotalOferta + total.VlTotalMissoes + total.VlTotalReforma; total.VlTotalTipo = total.VlTotalNotas + total.VlTotalMoedas + total.VlTotalCheque + total.VlTotalDebito + total.VlTotalCredito + total.VlTotalTransf; var lista = _unitOfWork.CabecalhosEntradas.ListarResponse(Convert.ToInt32(Util.DataCript.Decriptar(HttpContext.Session.GetString("_hash")))); RetornoResponse retorno = new RetornoResponse { retornoTotais = total, retornoLista = lista }; foreach (var linha in retorno.retornoLista.Where(w => w.Dizimo > 0)) { linha_dizimistas = tabela_dizimistas.AddRow(); linha_dizimistas.Format.Font.Size = 9; //linha_dizimistas.Cells[0].AddParagraph(Util.DataCript.Decriptar(linha.Pessoa.Nome).ToUpper()); linha_dizimistas.Cells[0].AddParagraph(linha.Pessoa.Nome.ToUpper()); linha_dizimistas.Cells[1].AddParagraph(linha.Dizimo.ToString()); total_dizimos += linha.Dizimo; } tabela_dizimistas.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black); relatorio.LastSection.Add(tabela_dizimistas); #endregion Paragraph quebra_linha_totalizadores = section.AddParagraph(""); Paragraph quebra_linha_totalizadores2 = section.AddParagraph(""); #region Totalizadores decimal total_ofertas = 0; decimal total_missoes = 0; decimal total_infantil = 0; decimal total_reforma = 0; total_ofertas = retorno.retornoTotais.VlTotalOferta; total_missoes = retorno.retornoTotais.VlTotalMissoes; total_infantil = 0; total_reforma = retorno.retornoTotais.VlTotalReforma; MigraDoc.DocumentObjectModel.Tables.Table tabela_total; MigraDoc.DocumentObjectModel.Tables.Row linha_total; tabela_total = new MigraDoc.DocumentObjectModel.Tables.Table(); tabela_total.Borders.Width = 0.5; MigraDoc.DocumentObjectModel.Tables.Column coluna_total1 = tabela_total.AddColumn("14cm"); coluna_total1.Format.Font.Name = "Calibri"; MigraDoc.DocumentObjectModel.Tables.Column coluna_total2 = tabela_total.AddColumn("4cm"); coluna_total2.Format.Font.Name = "Calibri"; linha_total = tabela_total.AddRow(); linha_total.Shading.Color = Colors.Gray; linha_total.Format.Alignment = ParagraphAlignment.Center; linha_total.Cells[0].AddParagraph("TOTAL DIZIMOS"); linha_total.Cells[1].AddParagraph(total_dizimos.ToString()); linha_total = tabela_total.AddRow(); linha_total.Shading.Color = Colors.Gray; linha_total.Format.Alignment = ParagraphAlignment.Center; linha_total.Cells[0].AddParagraph("TOTAL OFERTAS"); linha_total.Cells[1].AddParagraph(total_ofertas.ToString()); linha_total = tabela_total.AddRow(); linha_total.Shading.Color = Colors.Gray; linha_total.Format.Alignment = ParagraphAlignment.Center; linha_total.Cells[0].AddParagraph("TOTAL MISSÕES"); linha_total.Cells[1].AddParagraph(total_missoes.ToString()); linha_total = tabela_total.AddRow(); linha_total.Shading.Color = Colors.Gray; linha_total.Format.Alignment = ParagraphAlignment.Center; linha_total.Cells[0].AddParagraph("TOTAL REFORMA"); linha_total.Cells[1].AddParagraph(total_reforma.ToString()); linha_total = tabela_total.AddRow(); linha_total.Shading.Color = Colors.Gray; linha_total.Format.Alignment = ParagraphAlignment.Center; linha_total.Cells[0].AddParagraph("TOTAL INFANTIL"); linha_total.Cells[1].AddParagraph(total_infantil.ToString()); linha_total = tabela_total.AddRow(); linha_total.Shading.Color = Colors.DarkGray; linha_total.Format.Font.Bold = true; linha_total.Format.Alignment = ParagraphAlignment.Center; linha_total.Cells[0].AddParagraph("TOTAL"); var totalCateg = total_dizimos + total_ofertas + total_missoes + total_reforma + total_infantil; linha_total.Cells[1].AddParagraph(totalCateg.ToString()); tabela_total.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black); relatorio.LastSection.Add(tabela_total); #endregion Paragraph quebra_linha_tipo = section.AddParagraph(""); Paragraph quebra_linha_tipo2 = section.AddParagraph(""); #region RelatorioTipo MigraDoc.DocumentObjectModel.Tables.Table tabela_tipo; MigraDoc.DocumentObjectModel.Tables.Row linha_tipo; tabela_tipo = new MigraDoc.DocumentObjectModel.Tables.Table(); tabela_tipo.Borders.Width = 0.5; MigraDoc.DocumentObjectModel.Tables.Column coluna_nota = tabela_tipo.AddColumn("3cm"); MigraDoc.DocumentObjectModel.Tables.Column coluna_moeda = tabela_tipo.AddColumn("3cm"); MigraDoc.DocumentObjectModel.Tables.Column coluna_cheque = tabela_tipo.AddColumn("3cm"); MigraDoc.DocumentObjectModel.Tables.Column coluna_debito = tabela_tipo.AddColumn("3cm"); MigraDoc.DocumentObjectModel.Tables.Column coluna_credito = tabela_tipo.AddColumn("3cm"); MigraDoc.DocumentObjectModel.Tables.Column coluna_transf = tabela_tipo.AddColumn("3cm"); coluna_nota.Format.Font.Name = "Calibri"; coluna_moeda.Format.Font.Name = "Calibri"; coluna_cheque.Format.Font.Name = "Calibri"; coluna_debito.Format.Font.Name = "Calibri"; coluna_credito.Format.Font.Name = "Calibri"; coluna_transf.Format.Font.Name = "Calibri"; linha_tipo = tabela_tipo.AddRow(); linha_tipo.Shading.Color = Colors.Black; linha_tipo.Format.Font.Color = Colors.White; linha_tipo.Format.Font.Bold = true; linha_tipo.Cells[0].AddParagraph("Notas"); linha_tipo.Cells[1].AddParagraph("Moedas"); linha_tipo.Cells[2].AddParagraph("Cheques"); linha_tipo.Cells[3].AddParagraph("C. Déb."); linha_tipo.Cells[4].AddParagraph("C. Créd."); linha_tipo.Cells[5].AddParagraph("Transf."); decimal total_notas = 0; decimal total_moedas = 0; decimal total_cheques = 0; decimal total_debito = 0; decimal total_credito = 0; decimal total_transf = 0; total_notas = retorno.retornoTotais.VlTotalNotas; total_moedas = retorno.retornoTotais.VlTotalMoedas; total_cheques = retorno.retornoTotais.VlTotalCheque; total_debito = retorno.retornoTotais.VlTotalDebito; total_credito = retorno.retornoTotais.VlTotalCredito; total_transf = retorno.retornoTotais.VlTotalTransf; linha_tipo = tabela_tipo.AddRow(); linha_tipo.Cells[0].AddParagraph(total_notas.ToString()); linha_tipo.Cells[1].AddParagraph(total_moedas.ToString()); linha_tipo.Cells[2].AddParagraph(total_cheques.ToString()); linha_tipo.Cells[3].AddParagraph(total_debito.ToString()); linha_tipo.Cells[4].AddParagraph(total_credito.ToString()); linha_tipo.Cells[5].AddParagraph(total_transf.ToString()); Paragraph quebra_linha5 = section.AddParagraph(""); tabela_tipo.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black); relatorio.LastSection.Add(tabela_tipo); #endregion Paragraph quebra_linha_conferidoPor = section.AddParagraph(""); Paragraph quebra_linha_conferidoPor2 = section.AddParagraph(""); Paragraph quebra_linha_conferidoPor3 = section.AddParagraph(""); #region ConferidoPor MigraDoc.DocumentObjectModel.Tables.Table tabela_conferidoPor; MigraDoc.DocumentObjectModel.Tables.Row linha_conferidoPor; tabela_conferidoPor = new MigraDoc.DocumentObjectModel.Tables.Table(); tabela_conferidoPor.Borders.Width = 0; MigraDoc.DocumentObjectModel.Tables.Column coluna_conferidoPor = tabela_conferidoPor.AddColumn("3cm"); coluna_conferidoPor.Format.Font.Name = "Calibri"; MigraDoc.DocumentObjectModel.Tables.Column coluna_conferidoPor1 = tabela_conferidoPor.AddColumn("7cm"); coluna_conferidoPor1.Format.Font.Name = "Calibri"; MigraDoc.DocumentObjectModel.Tables.Column coluna_conferidoPor2 = tabela_conferidoPor.AddColumn("7cm"); coluna_conferidoPor2.Format.Font.Name = "Calibri"; linha_conferidoPor = tabela_conferidoPor.AddRow(); linha_conferidoPor.Format.Alignment = ParagraphAlignment.Center; linha_conferidoPor.Cells[0].AddParagraph("CONFERIDO POR:"); linha_conferidoPor.Cells[1].AddParagraph(Util.DataCript.Decriptar(HttpContext.Session.GetString("_header1"))); linha_conferidoPor.Cells[1].Format.Borders.Top.Width = 0.5; linha_conferidoPor.Cells[2].AddParagraph(Util.DataCript.Decriptar(HttpContext.Session.GetString("_header2"))); linha_conferidoPor.Cells[2].Format.Borders.Top.Width = 0.5; tabela_conferidoPor.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black); relatorio.LastSection.Add(tabela_conferidoPor); #endregion return(relatorio); }
public void MakeGiftCert(int itemID) { try { GiftCertificateInfo item; //load the item GiftCertificateController controller = new GiftCertificateController(); item = controller.GetGiftCert(itemId); string CertAmountWords = ""; string MailToAddressField = ""; string CertAmountNumber = ""; if (item != null) { if (item.PaypalPaymentState.ToString().Length == 0) { Response.Redirect(Globals.NavigateURL("Access Denied"), true); } TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; CertAmountWords = textInfo.ToTitleCase(NumberToWords(Int32.Parse(item.CertAmount.ToString())).ToString()).ToString() + " Dollars" + Environment.NewLine; CertAmountNumber = "$" + String.Format("{0:f2}", item.CertAmount).ToString(); MailToAddressField = item.MailTo.ToString() + Environment.NewLine + item.MailToAddress.ToString() + Environment.NewLine + item.MailToCity.ToString() + ", " + item.MailToState.ToString() + " " + item.MailToZip.ToString(); _CertNotes = item.Notes.ToString(); } string myPortalName = this.PortalSettings.PortalName.ToString(); Document document = new Document(); document.Info.Author = "Joseph Aucoin"; document.Info.Keywords = "Gift Certificate"; document.Info.Title = myPortalName.ToString() + " Gift Certificate"; // Get the A4 page size MigraDoc.DocumentObjectModel.Unit width, height; PageSetup.GetPageSize(PageFormat.Letter, out width, out height); // Add a section to the document and configure it such that it will be in the centre // of the page Section section = document.AddSection(); section.PageSetup.PageHeight = height; section.PageSetup.PageWidth = width; section.PageSetup.LeftMargin = 20; section.PageSetup.RightMargin = 10; section.PageSetup.TopMargin = 20; // height / 2; //++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++ // ADD LOGO string myLogo = PortalSettings.HomeDirectoryMapPath + _CertLogo.ToString(); // "Images\\Chapins-Logo.png"; MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(myLogo.ToString()); image.LockAspectRatio = true; image.RelativeVertical = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Line; image.RelativeHorizontal = MigraDoc.DocumentObjectModel.Shapes.RelativeHorizontal.Margin; image.Top = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Top; image.Left = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Right; image.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through; MigraDoc.DocumentObjectModel.Tables.Table HeaderTable = new MigraDoc.DocumentObjectModel.Tables.Table(); HeaderTable.Borders.Width = 0; // Default to show borders 1 pixel wide Column HeaderTable.LeftPadding = 10; HeaderTable.RightPadding = 10; HeaderTable.Borders.Left.Visible = false; HeaderTable.Borders.Right.Visible = false; // Add 1 columns float myColumnWidth = ((section.PageSetup.PageWidth - section.PageSetup.LeftMargin - section.PageSetup.RightMargin) / 2); // ((width / 2) - 10); MigraDoc.DocumentObjectModel.Tables.Column column0 = HeaderTable.AddColumn(myColumnWidth); MigraDoc.DocumentObjectModel.Tables.Row row1 = HeaderTable.AddRow(); row1.Cells[0].Elements.AddParagraph(_CertReturnAddress.ToString()); row1.Cells[0].Format.Alignment = ParagraphAlignment.Left; section.Add(HeaderTable); /// SPACING MigraDoc.DocumentObjectModel.Paragraph paragraph = section.AddParagraph(); paragraph.Format.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Exactly; paragraph.Format.LineSpacing = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(30.0); // section.Add(paragraph); //++++++++++++++++++++++++++++++ // ADD ANOTHER TABLE FOR MAIL TO ADDRESS // Create a table so that we can draw the horizontal lines MigraDoc.DocumentObjectModel.Tables.Table tableMailToAddress = new MigraDoc.DocumentObjectModel.Tables.Table(); tableMailToAddress.Borders.Width = 0; // Default to show borders 1 pixel wide Column tableMailToAddress.LeftPadding = 20; tableMailToAddress.RightPadding = 10; // float myColumnWidth100percent = (width - 10); var column = tableMailToAddress.AddColumn((section.PageSetup.PageWidth - section.PageSetup.LeftMargin - section.PageSetup.RightMargin)); double fontHeight = 20; Font font = new Font("Times New Roman", fontHeight); // Add a row with a single cell for the first line MigraDoc.DocumentObjectModel.Tables.Row row = tableMailToAddress.AddRow(); MigraDoc.DocumentObjectModel.Tables.Cell cell = row.Cells[0]; cell = row.Cells[0]; cell.Format.Font.Color = Colors.Black; cell.Format.Alignment = ParagraphAlignment.Left; cell.Format.Font.ApplyFont(font); cell.AddParagraph(MailToAddressField.ToString()); section.Add(tableMailToAddress); // ADD SPACER+++++++++++++++++++++++++++++++++++++++ MigraDoc.DocumentObjectModel.Paragraph paragraph1 = section.AddParagraph(); paragraph1.Format.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Exactly; paragraph1.Format.LineSpacing = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(20.0); // ADD ANOTHER TABLE FOR CERT // Create a table so that we can draw the horizontal lines MigraDoc.DocumentObjectModel.Tables.Table tableCert = new MigraDoc.DocumentObjectModel.Tables.Table(); tableCert.Borders.Width = 0; // Default to show borders 1 pixel wide Column tableCert.LeftPadding = 10; tableCert.RightPadding = 10; tableCert.Borders.Right.Visible = true; // float myColumnWidth100percent = (width - 10); float sectionWidth = section.PageSetup.PageWidth - section.PageSetup.LeftMargin - section.PageSetup.RightMargin; float columnWidth = sectionWidth; var columnCert = tableCert.AddColumn(columnWidth); columnCert.Format.Alignment = ParagraphAlignment.Center; double fontHeightCert = 30; Font fontCert = new Font("Times New Roman", fontHeightCert); // Add a row with a single cell for the first line MigraDoc.DocumentObjectModel.Tables.Row rowCert = tableCert.AddRow(); MigraDoc.DocumentObjectModel.Tables.Cell cellCert = rowCert.Cells[0]; cellCert.Format.Font.Color = Colors.Black; cellCert.Format.Font.ApplyFont(fontCert); cellCert.Borders.Left.Visible = false; cellCert.Borders.Right.Visible = false; cellCert.Borders.Bottom.Visible = false; cellCert.AddParagraph(_CertBannerText.ToString()); // Add a row with a single cell for the second line rowCert = tableCert.AddRow(); cellCert = rowCert.Cells[0]; cellCert.Format.Font.Color = Colors.Black; cellCert.Format.Alignment = ParagraphAlignment.Center; cellCert.Format.Font.ApplyFont(fontCert); cellCert.Borders.Left.Visible = false; cellCert.Borders.Right.Visible = false; cellCert.Borders.Top.Visible = false; cellCert.AddParagraph(CertAmountWords.ToString()); // 3RD LINE // Add a row with a single cell for the third line rowCert = tableCert.AddRow(); cellCert = rowCert.Cells[0]; Font fontCertDetails = new Font("Times New Roman", 20); cellCert.Format.Font.Color = Colors.Black; cellCert.Format.Alignment = ParagraphAlignment.Left; cellCert.Format.Font.ApplyFont(fontCertDetails); cellCert.Borders.Left.Visible = false; cellCert.Borders.Right.Visible = false; cellCert.Borders.Top.Visible = false; cellCert.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(10.0); cellCert.Format.LeftIndent = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(15.0); cellCert.AddParagraph("Date:" + item.CreatedDate.ToShortDateString() + Environment.NewLine + "Presented to: " + item.ToName.ToString() + Environment.NewLine + "From: " + item.FromName.ToString() + Environment.NewLine + "Amount: " + CertAmountNumber.ToString()); //////////////////////////////// // 4th LINE // Add a row with a single cell for the forth line rowCert = tableCert.AddRow(); cellCert = rowCert.Cells[0]; Font fontCertSignature = new Font("Arial", 12); cellCert.Format.Font.Color = Colors.Black; cellCert.Format.Alignment = ParagraphAlignment.Left; cellCert.Format.Font.ApplyFont(fontCertSignature); cellCert.Borders.Left.Visible = false; cellCert.Borders.Right.Visible = false; cellCert.Borders.Top.Visible = false; cellCert.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(10.0); cellCert.Format.LeftIndent = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(15.0); cellCert.AddParagraph("Authorized Signature: __________________________________________________"); //////////////////////////////// // 5th LINE // Add a row with a single cell for the fifth line rowCert = tableCert.AddRow(); cellCert = rowCert.Cells[0]; Font fontCertInvoiceNumber = new Font("Arial", 10); cellCert.Format.Font.Color = Colors.Black; cellCert.Format.Alignment = ParagraphAlignment.Center; cellCert.Format.Font.ApplyFont(fontCertInvoiceNumber); cellCert.Borders.Left.Visible = false; cellCert.Borders.Right.Visible = false; cellCert.Borders.Top.Visible = false; // cellCert.Format.AddTabStop("16cm", TabAlignment.Right); cellCert.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(3.0); //cellCert.Format.LeftIndent = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(15.0); cellCert.AddParagraph("Certificate Number 00" + item.ItemId.ToString()); document.LastSection.Add(tableCert); if (item.Notes.ToString().Trim().Length > 0) { //+++++++++ ADD PARAGRAPH FOR BUYER NOTES MigraDoc.DocumentObjectModel.Paragraph paragraphFooter = section.AddParagraph(); paragraphFooter.Format.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Exactly; paragraphFooter.Format.LineSpacing = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(8.0); paragraphFooter.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(10.0); paragraphFooter.AddText("NOTES:" + Environment.NewLine + _CertNotes.ToString()); } Paragraph footerText = new Paragraph(); footerText.Format.Alignment = ParagraphAlignment.Center; footerText.AddText(_CertFooterText.ToString()); section.Footers.Primary.Add(footerText); // Create a renderer PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(); // Associate the MigraDoc document with a renderer pdfRenderer.Document = document; // Layout and render document to PDF pdfRenderer.RenderDocument(); string pdfFilename = PortalSettings.HomeDirectoryMapPath + _PdfFilesFolder.ToString() + "Cert" + itemId.ToString() + ".pdf"; if (File.Exists(pdfFilename)) { File.Delete(pdfFilename); } pdfRenderer.PdfDocument.Save(pdfFilename); bool watermarkIsNeeded = false; if (_CertWatermark.ToString().Trim().Length > 1) { watermarkIsNeeded = true; } if (watermarkIsNeeded) { PdfDocument pdfIn = PdfReader.Open(pdfFilename, PdfDocumentOpenMode.Import); PdfDocument pdfOut = new PdfDocument(); for (int i = 0; i < pdfIn.PageCount; i++) { PdfPage pg = pdfIn.Pages[i]; pg = pdfOut.AddPage(pg); // WATERMARK TEXT string draftFlagStr = _CertWatermark.ToString(); // Get an XGraphics object for drawing beneath the existing content XGraphics gfx = XGraphics.FromPdfPage(pg, XGraphicsPdfPageOptions.Prepend); // Get the size (in point) of the text XFont fontWM = new XFont("Verdana", 62, XFontStyle.Bold); XSize size = gfx.MeasureString(draftFlagStr, fontWM); // Define a rotation transformation at the center of the page gfx.TranslateTransform(pg.Width / 2, pg.Height / 2); gfx.RotateTransform(-Math.Atan(pg.Height / pg.Width) * 180 / Math.PI); gfx.TranslateTransform(-pg.Width / 2, -pg.Height / 2); // Create a string format XStringFormat format = new XStringFormat(); format.Alignment = XStringAlignment.Near; format.LineAlignment = XLineAlignment.Near; // Create a dimmed red brush XBrush brush = new XSolidBrush(XColor.FromArgb(32, 0, 0, 255)); // Draw the string gfx.DrawString(draftFlagStr, fontWM, brush, new XPoint((pg.Width - size.Width) / 2, (pg.Height - size.Height) / 2), format); } pdfOut.Save(pdfFilename); } // Save and show the document // pdfRenderer.PdfDocument.Save("TestDocument.pdf"); Process.Start("explorer.exe", pdfFilename); HyperLinkPDF.Visible = true; HyperLinkPDF.NavigateUrl = PortalSettings.HomeDirectory + _PdfFilesFolder.ToString() + "Cert" + itemId.ToString() + ".pdf"; } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }