//creates ticket and returns its path public string createTicket(string firstName, string lastName, string company, string format, string eventName, string date, int monthNumber, string location1Row, string location2Row, string barcode, System.Drawing.Color barcodeColor, string savingName, string firmImagePath, string eventImagePath, string sponsorsImagePath, string savingPath) { string encodedBarcode = StringEncoder.ReturnEncryptedString(barcode); System.Drawing.Image barcodeImage = barcodeGenerator.generateQrBarcodeZXing(encodedBarcode, barcodeColor); string localSavingPath = @"docs\"; if (savingPath.Replace(" ", "").Length > 0) { localSavingPath = savingPath + @"\"; } using (DocX document = DocX.Create(localSavingPath + savingName + ".docx")) { document.InsertParagraph(); document.InsertParagraph(); System.Drawing.Color borderColor = System.Drawing.ColorTranslator.FromHtml("#00A86B"); // Set document margins document.MarginBottom = 0.7F; document.MarginTop = 0.7F; document.MarginRight = 35F; document.MarginLeft = 35F; document.InsertParagraph(); //add logo image Picture eventpic = null; Picture sponsorspic = null; if (eventImagePath.Length > 0) { Image image = document.AddImage(eventImagePath); eventpic = image.CreatePicture(); } if (sponsorsImagePath.Length > 0) { Image image = document.AddImage(sponsorsImagePath); sponsorspic = image.CreatePicture(); } if (eventImagePath.Length > 0 && sponsorsImagePath.Length > 0) { Table table = document.AddTable(1, 2); float[] widthsPercentage = { 40F, 60F }; table.SetWidthsPercentage(widthsPercentage, document.PageWidth - 20F); table.Design = TableDesign.TableGrid; Border emptyBorder = new Border(BorderStyle.Tcbs_none, BorderSize.one, 0, System.Drawing.Color.Transparent); table.SetBorder(TableBorderType.Top, emptyBorder); table.SetBorder(TableBorderType.Right, emptyBorder); table.SetBorder(TableBorderType.Left, emptyBorder); table.SetBorder(TableBorderType.Bottom, emptyBorder); Border notEmptyBorder = new Border(BorderStyle.Tcbs_single, BorderSize.one, 1, borderColor); table.SetBorder(TableBorderType.InsideV, notEmptyBorder); if (eventpic != null) { table.Rows[0].Cells[0].VerticalAlignment = VerticalAlignment.Center; table.Rows[0].Cells[0].Paragraphs[0].AppendPicture(resizePicture(eventpic, 300, 200)); } if (sponsorspic != null) { table.Rows[0].Cells[1].VerticalAlignment = VerticalAlignment.Center; table.Rows[0].Cells[1].MarginLeft = 20F; table.Rows[0].Cells[1].Paragraphs[0].AppendPicture(resizePicture(sponsorspic, 600, 200)); } table.SetBorder(TableBorderType.Bottom, emptyBorder); //table.AutoFit = AutoFit.Contents; document.InsertTable(table); table.SetBorder(TableBorderType.Bottom, emptyBorder); } else if (eventImagePath.Length > 0) { addImageToDocument(document, 150, 500, eventImagePath, Alignment.center); } else if (sponsorsImagePath.Length > 0) { addImageToDocument(document, 150, 500, sponsorsImagePath, Alignment.center); } //addImageToDocument(document, 145, 473, LogoFinalImage, Alignment.center); float pageWidth = document.PageWidth * 18; //add line through all page document.InsertParagraph(); addLineToDocument(document, Xceed.Document.NET.BorderStyle.Tcbs_dashed, pageWidth, borderColor); document.InsertParagraph(); System.Drawing.Color headerColor = System.Drawing.ColorTranslator.FromHtml("#9E9E9E"); System.Drawing.Color paragraphColor = System.Drawing.ColorTranslator.FromHtml("#404040"); System.Drawing.Color linkColor = System.Drawing.ColorTranslator.FromHtml("#E36C0A"); //Add text to document addTextToDocument(document, "Name", Alignment.left, "Calibri", 14, headerColor); addTextToDocument(document, firstName + " " + lastName, Alignment.left, "Calibri", 28, paragraphColor); document.InsertParagraph(); addTextToDocument(document, "Company", Alignment.left, "Calibri", 14, headerColor); addTextToDocument(document, company, Alignment.left, "Calibri", 16, paragraphColor); document.InsertParagraph(); addTextToDocument(document, "Format", Alignment.left, "Calibri", 14, headerColor); addTextToDocument(document, format, Alignment.left, "Calibri", 16, paragraphColor); document.InsertParagraph(); addTextToDocument(document, "Event", Alignment.left, "Calibri", 14, headerColor); addTextToDocument(document, eventName, Alignment.left, "Calibri", 16, paragraphColor); document.InsertParagraph(); string dateLocation = "Date\t\t\t\t\t\t\t\t\tLocation"; string tabs = "\t\t\t\t\t"; if (monthNumber >= 11 || monthNumber == 9) { tabs = "\t\t\t\t"; } string datePlace = date + tabs + location1Row; string TimeLocation = "\t\t\t\t\t\t\t\t\t" + location2Row; //string calendarMap = "Add to calendar\t\t\t\t\t\t\t\t\t\t\tView map"; addTextToDocument(document, dateLocation, Alignment.left, "Calibri", 14, headerColor); addTextToDocument(document, datePlace, Alignment.left, "Calibri", 16, paragraphColor); addTextToDocument(document, TimeLocation, Alignment.left, "Calibri", 16, paragraphColor); document.InsertParagraph(); addImageToDocument(document, 250, 250, barcodeImage, Alignment.center); //addTextToDocument(document, calendarMap, Alignment.left, "Calibri", 11, linkColor); document.InsertParagraph(); addLineToDocument(document, Xceed.Document.NET.BorderStyle.Tcbs_dashed, pageWidth, borderColor); document.InsertParagraph(); addTextToDocument(document, "ORGANIZER", Alignment.left, "Calibri", 14, headerColor); string companyImagePath = Directory.GetParent(workingDirectory).Parent.FullName + @"\UI\Images\" + "mergedImage" + ".png"; if (firmImagePath.Replace(" ", "").Length < 1) { addTwoImagesToText("\t\t\t\t\t\t", companyImagePath, iliniumImage, document, Alignment.right, "Calibri", 14, System.Drawing.Color.Black); } else { addTwoImagesToText("\t\t\t\t\t\t", companyImagePath, firmImagePath, document, Alignment.right, "Calibri", 14, System.Drawing.Color.Black); } // Save this document. document.Save(); } string targetPath = Directory.GetParent(workingDirectory).Parent.FullName + @"\bin\Debug\docs\"; if (savingPath.Replace(" ", "").Length > 0) { targetPath = savingPath + @"\"; } string targetFile = targetPath + savingName + ".pdf"; convertWordToPdf(targetPath + savingName + ".docx", targetFile); return(targetFile); }