public void Write(string outputPath, FlowDocument doc) { Document pdfDoc = new Document(PageSize.A4, 50, 50, 50, 50); Font textFont = new Font(baseFont, DEFAULT_FONTSIZE, Font.NORMAL, BaseColor.BLACK); Font headingFont = new Font(baseFont, DEFAULT_HEADINGSIZE, Font.BOLD, BaseColor.BLACK); using (FileStream stream = new FileStream(outputPath, FileMode.Create)) { PdfWriter writer = PdfWriter.GetInstance(pdfDoc, stream); pdfDoc.Open(); foreach (Block i in doc.Blocks) { if (i is System.Windows.Documents.Paragraph) { TextRange range = new TextRange(i.ContentStart, i.ContentEnd); Console.WriteLine(i.Tag); switch (i.Tag as string) { case "Paragraph": iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(range.Text, textFont); par.Alignment = Element.ALIGN_JUSTIFIED; pdfDoc.Add(par); break; case "Heading": iTextSharp.text.Paragraph head = new iTextSharp.text.Paragraph(range.Text, headingFont); head.Alignment = Element.ALIGN_CENTER; head.SpacingAfter = 10; pdfDoc.Add(head); break; default: iTextSharp.text.Paragraph def = new iTextSharp.text.Paragraph(range.Text, textFont); def.Alignment = Element.ALIGN_JUSTIFIED; pdfDoc.Add(def); break; } } else if (i is System.Windows.Documents.List) { iTextSharp.text.List list = new iTextSharp.text.List(iTextSharp.text.List.UNORDERED, 10f); list.SetListSymbol("\u2022"); list.IndentationLeft = 15f; foreach (var li in (i as System.Windows.Documents.List).ListItems) { iTextSharp.text.ListItem listitem = new iTextSharp.text.ListItem(); TextRange range = new TextRange(li.Blocks.ElementAt(0).ContentStart, li.Blocks.ElementAt(0).ContentEnd); string text = range.Text.Substring(1); iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(text, textFont); listitem.SpacingAfter = 10; listitem.Add(par); list.Add(listitem); } pdfDoc.Add(list); } } if (pdfDoc.PageNumber == 0) { iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(" "); par.Alignment = Element.ALIGN_JUSTIFIED; pdfDoc.Add(par); } pdfDoc.Close(); } }
// --------------------------------------------------------------------------- /** * Creates the PDF. * @return the bytes of a PDF file. */ public byte[] CreatePdf() { using (MemoryStream ms = new MemoryStream()) { using (Document document = new Document()) { PdfWriter writer = PdfWriter.GetInstance(document, ms); document.Open(); document.Add(new Paragraph( "This is a list of Kubrick movies available in DVD stores." )); IEnumerable<Movie> movies = PojoFactory.GetMovies(1) .Concat(PojoFactory.GetMovies(4)) ; List list = new List(); string RESOURCE = Utility.ResourcePosters; foreach (Movie movie in movies) { PdfAnnotation annot = PdfAnnotation.CreateFileAttachment( writer, null, movie.GetMovieTitle(false), null, Path.Combine(RESOURCE, movie.Imdb + ".jpg"), string.Format("{0}.jpg", movie.Imdb) ); ListItem item = new ListItem(movie.GetMovieTitle(false)); item.Add("\u00a0\u00a0"); Chunk chunk = new Chunk("\u00a0\u00a0\u00a0\u00a0"); chunk.SetAnnotation(annot); item.Add(chunk); list.Add(item); } document.Add(list); } return ms.ToArray(); } }
// =========================================================================== public void Write(Stream stream) { // step 1 using (Document document = new Document()) { // step 2 PdfWriter.GetInstance(document, stream); // step 3 document.Open(); // step 4 var SQL = @"SELECT DISTINCT mc.country_id, c.country, count(*) AS c FROM film_country c, film_movie_country mc WHERE c.id = mc.country_id GROUP BY mc.country_id, country ORDER BY c DESC"; // Create a list for the countries List list = new RomanList(); // loop over the countries using (var c = AdoDB.Provider.CreateConnection()) { c.ConnectionString = AdoDB.CS; using (DbCommand cmd = c.CreateCommand()) { cmd.CommandText = SQL; c.Open(); using (var r = cmd.ExecuteReader()) { while (r.Read()) { // create a list item for the country ListItem item = new ListItem( string.Format("{0}: {1} movies", r["country"].ToString(), r["c"].ToString() ) ); // Create a list for the movies List movielist = new GreekList(); movielist.Lowercase = List.LOWERCASE; // Loop over the movies foreach (Movie movie in PojoFactory.GetMovies(r["country_id"].ToString()) ) { ListItem movieitem = new ListItem(movie.MovieTitle); // Create a list for the directors List directorlist = new ZapfDingbatsNumberList(0); // Loop over the directors foreach (Director director in movie.Directors) { directorlist.Add(String.Format("{0}, {1}", director.Name, director.GivenName )); } movieitem.Add(directorlist); movielist.Add(movieitem); } item.Add(movielist); list.Add(item); } document.Add(list); } } } } }
/* (non-Javadoc) * @see com.itextpdf.tool.xml.ITagProcessor#endElement(com.itextpdf.tool.xml.Tag, java.util.List) */ public override IList<IElement> End(IWorkerContext ctx, Tag tag, IList<IElement> currentContent) { IList<IElement> l = new List<IElement>(1); ListItem li = new ListItem(); foreach (IElement e in currentContent) { li.Add(e); } l.Add(li); // css applying is handled in the OrderedUnorderedList Class. return l; }
/* (non-Javadoc) * @see com.itextpdf.tool.xml.ITagProcessor#endElement(com.itextpdf.tool.xml.Tag, java.util.List) */ public override IList<IElement> End(IWorkerContext ctx, Tag tag, IList<IElement> currentContent) { IList<IElement> l = new List<IElement>(1); ListItem li = new ListItem(); float maxSize = -1; foreach (IElement e in currentContent) { li.Add(e); //finding max leading among list item elements foreach (Chunk chunk in e.Chunks) { // here we use 4f/3 multiplied leading value to simulate leading which is used with default font size float currFontSize = chunk.Font.GetCalculatedLeading(4f/3); if (maxSize < currFontSize) { maxSize = currFontSize; } } } if (li.Leading < maxSize) li.Leading = maxSize; if (li.Trim()) { l.Add(li); // css applying is handled in the OrderedUnorderedList Class. } return l; }
// --------------------------------------------------------------------------- public void Write(Stream stream) { // step 1 using (Document document = new Document()) { // step 2 PdfWriter writer = PdfWriter.GetInstance(document, stream); // step 3 document.Open(); // step 4 Image img = Image.GetInstance(IMG_BOX); document.Add(img); List list = new List(List.UNORDERED, 20); PdfDestination dest = new PdfDestination(PdfDestination.FIT); dest.AddFirst(new PdfNumber(1)); IEnumerable<Movie> box = PojoFactory.GetMovies(1) .Concat(PojoFactory.GetMovies(4)) ; foreach (Movie movie in box) { if (movie.Year > 1960) { PdfFileSpecification fs = PdfFileSpecification.FileEmbedded( writer, null, String.Format("kubrick_{0}.pdf", movie.Imdb), CreateMoviePage(movie) ); fs.AddDescription(movie.Title, false); writer.AddFileAttachment(fs); ListItem item = new ListItem(movie.MovieTitle); PdfTargetDictionary target = new PdfTargetDictionary(true); target.EmbeddedFileName = movie.Title; PdfAction action = PdfAction.GotoEmbedded(null, target, dest, true); Chunk chunk = new Chunk(" (see info)"); chunk.SetAction(action); item.Add(chunk); list.Add(item); } } document.Add(list); } }
/** * Fills a java.util.List with all elements found in currentContent. Places elements that are not a {@link ListItem} or {@link com.itextpdf.text.List} in a new ListItem object. * * @param currentContent * @return java.util.List with only {@link ListItem}s or {@link com.itextpdf.text.List}s in it. */ private IList<IElement> PopulateList(IList<IElement> currentContent) { IList<IElement> listElements = new List<IElement>(); foreach (IElement e in currentContent) { if (e is ListItem || e is List) { listElements.Add(e); } else { ListItem listItem = new ListItem(); listItem.Add(e); listElements.Add(listItem); } } return listElements; }
private void GeneratePDF1() { log4net.ILog log = log4net.LogManager.GetLogger("ServiceRowDataBound"); log4net.Config.XmlConfigurator.Configure(); try { /*CustomSessionClass objCustomSessionClass = new CustomSessionClass(); System.Web.UI.HtmlControls.HtmlTable objtbl = objCustomSessionClass._Session; */ System.Web.UI.HtmlControls.HtmlTable objtbl = (System.Web.UI.HtmlControls.HtmlTable)Cache["table"]; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "inline;filename=results.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); //tblBusinessBankingOnline.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 7f, 7f, 7f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); //Set Header //iTextSharp.text.Image imgStlogo = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath(@"StG_Master_Logo_RGBold.jpg"))); //imgStlogo.SetAbsolutePosition(0, pdfDoc.PageSize.Height - imgStlogo.Height); //imgStlogo.ScaleToFit(200f, 90f); //imgStlogo.SetAbsolutePosition(0, 750f); // pdfDoc.Add(imgStlogo); // iTextSharp.text.Image imgStlogo = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath(@"StG_Master_Logo_RGBold.jpg"))); PdfPTable pdfTable = new PdfPTable(1); // pdfTable.DefaultCell.Border = Rectangle.NO_BORDER; // pdfTable.SplitRows = false; imgStlogo.ScaleToFit(183f, 66f); PdfPCell imageCell = new PdfPCell(imgStlogo); imageCell.Border = 0; pdfTable.AddCell(imageCell); pdfTable.HorizontalAlignment = Element.ALIGN_LEFT; pdfDoc.Add(pdfTable); pdfDoc.Add(new Paragraph("")); /* pdfDoc.Add(new Paragraph(" ")); pdfDoc.Add(new Paragraph(" ")); pdfDoc.Add(new Paragraph(" "));*/ iTextSharp.text.Font font18 = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8); iTextSharp.text.Chunk bullet = new iTextSharp.text.Chunk("\u2022", font18); iTextSharp.text.List list = new iTextSharp.text.List(false, 4); // true= ordered, false= unordered iTextSharp.text.List list1 = new iTextSharp.text.List(false, 4); // true= ordered, false= unordered string amt = "8"; string atm = "Freedom Business Account"; var get = Request.QueryString["item"]; var phrase = new Phrase(); string strTextData = Environment.NewLine + "Thank you for completing the Business Account Selector tool. You’ll find your results below." + Environment.NewLine + "We understand that no two businesses are the same and we want to help you make the right decisions for your business to be successful." + Environment.NewLine + "Like every great relationship, it starts with a conversation. So if you have any questions or want to take the next steps:" + Environment.NewLine; iTextSharp.text.Font FontTypeBold = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.BOLD); iTextSharp.text.Font FontTypeBoldlarge = FontFactory.GetFont("Arial", 10f, iTextSharp.text.Font.BOLD); iTextSharp.text.Font FontType = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.NORMAL); iTextSharp.text.Font FontTypeSmall = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL); phrase = new Phrase(); phrase.Add(new Chunk("Business Account and Product Selector Results", FontTypeBoldlarge)); phrase.Add(new Chunk(Environment.NewLine + "Hello " + Request.QueryString["Name"], FontTypeBold)); phrase.Add(new Chunk(strTextData, FontType)); pdfDoc.Add(phrase); PdfPTable tblCall = new PdfPTable(1); tblCall.WidthPercentage = 30f; tblCall.HorizontalAlignment = Element.ALIGN_LEFT; tblCall.DefaultCell.Border = Rectangle.NO_BORDER; iTextSharp.text.Image imgCall = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath(@"pdfCTA-1.png"))); tblCall.AddCell(imgCall); pdfDoc.Add(tblCall); phrase = new Phrase(); phrase.Add(new Chunk("To find out what information is needed to become a customer, visit ", FontType)); pdfDoc.Add(phrase); Font link = FontFactory.GetFont("Arial", 8, Font.UNDERLINE, new Color(0, 0, 255)); Anchor anchor = new Anchor("http://www.stgeorge.com.au/idchecklist", link); anchor.Reference = "http://www.stgeorge.com.au/idchecklist"; pdfDoc.Add(anchor); pdfDoc.Add(new Phrase(Environment.NewLine + Environment.NewLine, FontType)); #region CodeForLastFiveProduct PdfPTable pdfpTableAdditionalProduct = new PdfPTable(2); pdfpTableAdditionalProduct.WidthPercentage = 100f; int[] TableAdditionalProductwidth = { 30, 70 }; pdfpTableAdditionalProduct.SetWidths(TableAdditionalProductwidth); phrase = new Phrase(" " + Environment.NewLine); phrase.Add(new Chunk("Business Products", FontTypeBold)); phrase.Add(Environment.NewLine + " "); PdfPCell cellAdditionalProduct = new PdfPCell(phrase); cellAdditionalProduct.Colspan = 3; //Used to checked Last Five product is selected bool isLastFiveProductSelected = false; if (get.Contains("f")) { // pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "EFTPOS and merchant facilities", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Customers being able to pay with a debit card?", FontTypeBold)); phrase.Add(new Chunk(" and/or", FontType)); phrase.Add(new Chunk(Environment.NewLine + "Customers being able to pay with a credit card?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("To accept debit and credit cards from customers, whether it’s in person, over the phone or online, St.George has a range of EFTPOS and merchant solutions", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Get same-day settlement (when the terminal is settled before 9pm Sydney time) on debit and credit card sales, 7 days a week, when linked to a St.George business transaction account", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 2; pdfpTableAdditionalProduct.AddCell(objCell); } if (get.Contains("g")) { if (!isLastFiveProductSelected) { //pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Equipment finance", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Purchasing a vehicle?", FontTypeBold)); phrase.Add(new Chunk(" and/or", FontType)); phrase.Add(new Chunk(Environment.NewLine + "Purchasing equipment or machinery?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Finance up to 100% of the purchase price for vehicles or equipment", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Frees up money to run a business, rather than tying up working capital", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); // phrase.Add(new Chunk(Environment.NewLine + "Equipment Finance is offered by St.George Finance Limited ACL 387944."+Environment.NewLine+" Automotive Finance is offered by St.George Finance Limited ACL 387944 and St.George Motor Finance Limited ACL 387946.",FontType)); // objCell.AddElement(new Phrase("Equipment Finance by St.George Finance Limited Australian credit licence 387944.The Automotive Finance by St.George Finance Limited and St.George Motor Finance Limited Australian credit licence 387946")); var phBecauseText1 = new Phrase(); phBecauseText1.Add(new Chunk(Environment.NewLine + "Equipment Finance by St.George Finance Limited Australian credit licence 387944.", FontType)); //phBecauseText1.Add(new Chunk(Environment.NewLine + "Automotive Finance by St.George Finance Limited Australian credit licence 387944 and St.George Motor Finance Limited Australian credit licence 387946.", FontType)); objCell.AddElement(phBecauseText1); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProduct.AddCell(objCell); } if (get.Contains("h")) { if (!isLastFiveProductSelected) { // pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Lending for a Business", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Purchasing a business?", FontTypeBold)); phrase.Add(new Chunk(" and/or", FontType)); phrase.Add(new Chunk(Environment.NewLine + "Expanding a business?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("St.George has a number of lending options to give a business a cash injection", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("This includes both residentially and commercially secured loans or a combination of these", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProduct.AddCell(objCell); } if (get.Contains("i")) { if (!isLastFiveProductSelected) { // pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Bank guarantee", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Provide a landlord a guarantee of payment when renting premises?", FontTypeBold)); phrase.Add(new Chunk(" and/or", FontType)); phrase.Add(new Chunk(Environment.NewLine + "Provide customers or suppliers a guarantee of payment to secure a contract?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Allows a business to offer customers and suppliers a surety of payment without having to provide them a cash deposit upfront", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Where security other than cash is provided, this can free up money for other investment opportunities, and helps manage the highs and lows of cash flow", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProduct.AddCell(objCell); } if (get.Contains("j")) { if (!isLastFiveProductSelected) { // pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Online legal and tax advice", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Legal and tax advice?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); //list.Add(new iTextSharp.text.ListItem(new Chunk("St.George provides business customers with access to free online legal and taxation advice",FontType))); iTextSharp.text.ListItem LstItm = new iTextSharp.text.ListItem(); LstItm.Add(new Chunk("St.George provides business customers with access to free online legal and taxation advice", FontType)); LstItm.Add(new Chunk("3", FontFactory.GetFont(FontFactory.HELVETICA, 5)).SetTextRise(4)); list.Add(LstItm); list.Add(new iTextSharp.text.ListItem(new Chunk("Access this service by sending a confidential email to the third party provider", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("For more information, visit http://www.stgeorge.com.au/business/business-tools/legal-tax-advice", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProduct.AddCell(objCell); } /* if (freetax.Checked) { if (!isLastFiveProductSelected) { pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Online legal and tax advice", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Legal and tax advice?", FontTypeBold)); phrase.Add(new Chunk(Environment.NewLine + "St.George provides customers with access to free online legal and taxation advice." + Environment.NewLine + "Accessing this service is easy, existing customers can access this service by sending a confidential email to Legal Access Services." + Environment.NewLine + "Legal and accountancy services are not provided by St.George. St.George accepts no responsibility for any advice provided by these third parties. Advice is available by email only.",FontType)); phrase.Add(Environment.NewLine + "For more information,"); link = FontFactory.GetFont("Arial", 12, Font.UNDERLINE, new Color(0, 0, 255)); anchor = new Anchor("http://www.stgeorge.com.au/business/business-tools/legal-tax-advice", link); anchor.Reference = "http://www.stgeorge.com.au/business/business-tools/legal-tax-advice"; phrase.Add(anchor); phrase.Add(Environment.NewLine + " "); PdfPCell cell2 = new PdfPCell(phrase); pdfpTableAdditionalProduct.AddCell(cell2); list = new iTextSharp.text.List(false, 12); list.ListSymbol = bullet; list.Add(new iTextSharp.text.ListItem("St.George provides customers with access to free online legal and taxation advice")); list.Add(new iTextSharp.text.ListItem("Accessing this service is easy, existing customers can access this service by sending a confidential email to Legal Access Services")); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); phrase = new Phrase(); phrase.Add(Environment.NewLine + "For more information,"); link = FontFactory.GetFont("Arial", 12, Font.UNDERLINE, new Color(0, 0, 255)); anchor = new Anchor("http://www.stgeorge.com.au/business/business-tools/legal-tax-advice", link); anchor.Reference = "http://www.stgeorge.com.au/business/business-tools/legal-tax-advice"; phrase.Add(anchor); objCell.AddElement(phrase); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 2; pdfpTableAdditionalProduct.AddCell(objCell); }*/ pdfDoc.Add(pdfpTableAdditionalProduct); #endregion CodeForLastFiveProduct var phraseTermAndConditionkalu = new Phrase(); phraseTermAndConditionkalu.Add(new Chunk(Environment.NewLine + "", FontTypeBold)); pdfDoc.Add(phraseTermAndConditionkalu); #region CodeForTopFiveProduct PdfPTable pdftblAllData = new PdfPTable(2); pdftblAllData.WidthPercentage = 100f; int[] firstTablecellwidth = { 30, 70 }; pdftblAllData.SetWidths(firstTablecellwidth); phrase = new Phrase(" " + Environment.NewLine); phrase.Add(new Chunk("BizPack Essentials", FontTypeBold)); phrase.Add(Environment.NewLine + " "); PdfPCell cellBizPack = new PdfPCell(phrase); cellBizPack.Colspan = 2; //Used to checked topfive product is selected bool IsTopFiveProductSelected = false; if (get.Contains("z")) { amt = "18"; atm = "Business Cheque Account Plus"; pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Business Cheque Account Plus", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk(" An everyday account used to pay suppliers and have funds paid into?", FontTypeBold)); list = new iTextSharp.text.List(false, 4); list.ListSymbol = bullet; /* phrase = new Phrase(); phrase.Add(new Chunk("Day-to-day electronic transactions are fee-free")); phrase.Add(new Chunk("1", FontFactory.GetFont(FontFactory.HELVETICA, 6)).SetTextRise(4)); phrase.Add(new Chunk(",TestTestTest")); */ //list.Add(new iTextSharp.text.ListItem("With this account, all day-to-day electronic transactions are fee-free1")); iTextSharp.text.ListItem LstItm = new iTextSharp.text.ListItem(); LstItm.Add(new Chunk("With this account, all day-to-day electronic transactions are fee-free", FontType)); LstItm.Add(new Chunk("1", FontFactory.GetFont(FontFactory.HELVETICA, 5)).SetTextRise(4)); list.Add(LstItm); list.Add(new iTextSharp.text.ListItem(new Chunk("Plus, get 55 free in-branch transactions (over the counter) or cheque withdrawals every month", FontType))); /*list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("1",FontType).SetTextRise(4))); list.Add(new iTextSharp.text.ListItem(new Chunk("Plus, get 50 free in-branch transactions (over the counter) or cheque withdrawals every month",FontType))); */ /* iTextSharp.text.ListItem LstItm =new iTextSharp.text.ListItem(); LstItm.Add(new Chunk("With this account, the day-to-day electronic transactions are fee-free")); LstItm.Add(new Chunk("1", FontFactory.GetFont(FontFactory.HELVETICA, 6)).SetTextRise(4)); list.Add(LstItm); list.Add(new iTextSharp.text.ListItem(new Chunk("no matter how many are made"))); */ //list.Add(new iTextSharp.text.ListItem("Plus, get 50 free in-branch transactions (over the counter) or cheque withdrawals every month")); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if (get.Contains("a")) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } amt = "8"; atm = "Freedom Business Account"; PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Freedom Business Account", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk(" An everyday account used to pay suppliers and have funds paid into?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; //list.Add(new iTextSharp.text.ListItem("With this account, all day-to-day electronic transactions are fee-free1")); //list.Add(new iTextSharp.text.ListItem("Plus, get 20 free in-branch transactions (over the counter) or cheque withdrawals every month")); /*list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("1",FontType).SetTextRise(4))); list.Add(new iTextSharp.text.ListItem(new Chunk("Plus, get 20 free in-branch transactions (over the counter) or cheque withdrawals every month",FontType))); */ iTextSharp.text.ListItem LstItm = new iTextSharp.text.ListItem(); LstItm.Add(new Chunk("With this account, all day-to-day electronic transactions are fee-free", FontType)); LstItm.Add(new Chunk("1", FontFactory.GetFont(FontFactory.HELVETICA, 5)).SetTextRise(4)); list.Add(LstItm); list.Add(new iTextSharp.text.ListItem(new Chunk("Plus, get 20 free in-branch transactions (over the counter) or cheque withdrawals every month", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if (get.Contains("b")) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Business Visa Debit Card", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); //phrase.Add(new Chunk("Business Visa Debit Card", FontTypeBold)); phrase.Add(new Chunk("Access cash from an ATM?", FontTypeBold)); phrase.Add(new Chunk(" and/or", FontType)); phrase.Add(new Chunk(Environment.NewLine + "Make purchases in person, over the phone or online?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; //list.Add(new iTextSharp.text.ListItem(new Chunk("Plus, get 20 free in-branch transactions (over the counter) or cheque withdrawals every month",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Access funds from the " + atm + " at ATMs", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Make purchases in person, over the phone and online, wherever Visa is accepted (that's over 32 million locations worldwide)", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if (get.Contains("c")) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Business Access Saver", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Put money away for tax and other future payments?", FontTypeBold)); phrase.Add(new Chunk(" and/or", FontType)); phrase.Add(new Chunk(Environment.NewLine + "Earn interest on this money?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; //list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Enables money to be parked for future payments (like GST and regular bills), while also earning interest along the way", FontType))); iTextSharp.text.ListItem LstItm = new iTextSharp.text.ListItem(); LstItm.Add(new Chunk("Day-to-day electronic transactions are fee-free", FontType)); LstItm.Add(new Chunk("1", FontFactory.GetFont(FontFactory.HELVETICA, 5)).SetTextRise(4)); LstItm.Add(new Chunk(", as are 4 in-branch deposits (over the counter) every month", FontType)); list.Add(LstItm); // list.Add(new iTextSharp.text.ListItem(new Chunk("Day-to-day electronic transactions are fee-free1, as are 4 in-branch deposits (over the counter) every month",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if (get.Contains("d")) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Business Banking Online", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); //phrase.Add(new Chunk("Business Visa Debit Card", FontTypeBold)); phrase.Add(new Chunk("Manage money 24/7?", FontTypeBold)); phrase.Add(new Chunk(" and/or", FontType)); phrase.Add(new Chunk(Environment.NewLine + "Manage money when on the move?", FontTypeBold)); /*phrase.Add(new Chunk(Environment.NewLine +"Business Banking Online won the 2013 Best Internet Business Bank, in the AB+F Corporate and Business Banking Awards.",FontType)); phrase.Add(new Chunk(Environment.NewLine +" Take control of business banking:",FontType)); phrase.Add(new Chunk(Environment.NewLine +" Ability to set daily payment limits",FontType)); phrase.Add(new Chunk(Environment.NewLine +" Allow multiple users to have access to business accounts",FontType)); phrase.Add(new Chunk(Environment.NewLine +" Nominate which users can authorise transactions using authentication device",FontType)); phrase.Add(new Chunk(Environment.NewLine +" Get ultimate portability with Business Banking Mobile",FontType)); phrase.Add(Environment.NewLine + " "); PdfPCell cell2 = new PdfPCell(phrase); pdftblAllData.AddCell(cell2); */ list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; list1 = new iTextSharp.text.List(false, 8); list1.ListSymbol = bullet; ////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Business Banking Online won the 2013 Best Internet Business Bank, in the AB+F Corporate and Business Banking Awards", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Take control of business banking:", FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Ability to set daily payment limits", FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Allow multiple users to have access to business accounts", FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Nominate which users can authorise transactions using authentication device", FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Get ultimate portability with Business Banking Mobile", FontType))); list.Add(list1); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if (get.Contains("e")) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "BusinessVantage Visa Credit Card", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); //phrase.Add(new Chunk("Business Visa Debit Card", FontTypeBold)); phrase.Add(new Chunk("A credit card to help manage business expenses and cash flow?", FontTypeBold)); phrase.Add(new Chunk(" and/or", FontType)); phrase.Add(new Chunk(Environment.NewLine + "Separate business and personal expenses?", FontTypeBold)); /*phrase.Add(new Chunk(Environment.NewLine +"Low variable purchase rate (currently 9.99% p.a.) and up to 55 days interest free on purchases when closing balance paid by the due date",FontType)); phrase.Add(new Chunk(Environment.NewLine +"A dedicated business credit card keeps business and personal expenses separate",FontType)); phrase.Add(new Chunk(Environment.NewLine +"Provides peace of mind knowing extra working capital is at hand to help manage the highs and lows of cash flow",FontType)); phrase.Add(Environment.NewLine + " "); PdfPCell cell2 = new PdfPCell(phrase); pdftblAllData.AddCell(cell2);*/ list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; //////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Low variable purchase rate (currently 9.99% p.a.) and up to 55 days interest free on purchases when closing balance paid by the due date", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("A dedicated business credit card keeps business and personal expenses separate", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Provides peace of mind knowing extra working capital is at hand to help manage the highs and lows of cash flow", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if ((get.Contains("z") || get.Contains("a")) && get.Contains("c") && get.Contains("d") ) { var phBecauseText = new Phrase(); phBecauseText.Add(new Chunk("All the BizPack Essentials for only $" + amt + " per month in account keeping fees*." + Environment.NewLine + Environment.NewLine + "BizPack-ed full of savings:", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Business Banking Online monthly access fee (currently $30 a month) waived, saving $360 annually", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("BusinessVantage Visa Credit Card annual fee (currently $55 per card) waived for up to 3 cards, saving up to $165 annually", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Establishment fee for each new EFTPOS and merchant terminal waived, current saving of $77 per terminal", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phBecauseText); objCell.AddElement(list); var phBecauseText1 = new Phrase(); phBecauseText1.Add(new Chunk(Environment.NewLine + "*Transaction fees and special service fees may also apply.", FontType)); objCell.AddElement(phBecauseText1); // objCell.AddElement(new Phrase("*Transaction fees and special service fees may also apply.")); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); //pdfDoc.Add(pdftblAllData); } else { //Business%20Access%20Saver var biznt = Request.QueryString["bizpacknameneshat"]; Phrase phBecauseText = new Phrase(); phBecauseText.Add(new Chunk("Because the following have not been selected, BizPack has not been unlocked:", FontType)); Phrase phBecauseText2 = new Phrase(); phBecauseText2.Add(new Chunk(Environment.NewLine + "BizPack", FontTypeBold)); phBecauseText2.Add(new Chunk(Environment.NewLine + "Pay only $" + amt + " per month in account keeping fees* for the BizPack Essentials.", FontType)); phBecauseText2.Add(new Chunk(Environment.NewLine + "BizPack-ed full of savings:", FontType)); list1 = new iTextSharp.text.List(false, 8); list1.ListSymbol = bullet; if(biznt.Contains("Freedom Business Account")){ list1.Add(new iTextSharp.text.ListItem(new Chunk("Freedom Business Account", FontType))); } if(biznt.Contains("Business Access Saver")){ list1.Add(new iTextSharp.text.ListItem(new Chunk("Business Access Saver", FontType))); } if(biznt.Contains("Business Banking Online")){ list1.Add(new iTextSharp.text.ListItem(new Chunk("Business Banking Online", FontType))); } list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Business Banking Online monthly access fee (currently $30 a month) waived, saving $360 annually", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("BusinessVantage Visa Credit Card annual fee (currently $55 per card) waived for up to 3 cards, saving up to $165 annually", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Establishment fee for each new EFTPOS and merchant terminal waived, current saving of $77 per terminal", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phBecauseText); objCell.AddElement(list1); objCell.AddElement(phBecauseText2); objCell.AddElement(list); var phBecauseText1 = new Phrase(); phBecauseText1.Add(new Chunk(Environment.NewLine + "*Transaction fees and special service fees may also apply.", FontType)); objCell.AddElement(phBecauseText1); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); //pdfDoc.Add(pdftblAllData); } pdfDoc.Add(pdftblAllData); #endregion CodeForTopFiveProduct #region TermAndCondition // pdfDoc.NewPage(); FontTypeBold = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.BOLD); FontType = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.NORMAL); var phraseTermAndCondition = new Phrase(); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "Things you should know", FontTypeBold)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "Information is current as at 31 March 2014 This offer may be withdrawn at any time, visit stgeorge.com.au for up-to-date information.", FontType)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "No personal information is stored by using this tool. This tool does not take into account your objectives, financial situation or needs. Before making any decision, consider its appropriateness having regard to your objectives, financial situation and needs. Before you acquire a product, read the Product Disclosure Statement or other disclosure document available at stgeorge.com.au and consider whether the product is appropriate for you. Credit criteria applies to all credit, lending, merchant and bank guarantee products and services selected. Terms and Conditions, fees and charges apply.", FontType)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "1. Electronic transactions are phone and internet banking deposits, withdrawals and transfers, direct debits and credits, St.George/BankSA/Bank of Melbourne/ Westpac ATM withdrawals in Australia, St.George/BankSA/Bank of Melbourne ATM deposits and mini transaction history and EFTPOS withdrawals and Business Visa Debit Card transactions. Daily limits apply.", FontType)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "2. The account keeping fee for the Transaction Account selected in BizPack is payable monthly. The monthly online access fee, annual card fee (for up to 3 cards) and facility establishment fee applicable to the other eligible products in BizPack are waived for as long as customer holds a Transaction Account, Savings Account, and online banking facility in the same name. Internet Banking may replace Business Banking Online as the online banking facility held in BizPack. Transaction fees may also apply if you exceed the monthly fee-free transaction allowance on eligible products in the BizPack Essentials. Other transactions and special service fees may also apply.", FontType)); //phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "3. Customers can access the online legal and accountancy services by sending an email to Legal Access Services. These services are not provided by St.George and St.George accepts no responsibility for any advice provided by the third party. Advice is available by email only. All products and services in this tool (other than equipment finance and automotive finance) are issued by St.George Bank – A Division of Westpac Banking Corporation ABN 33 007 457 141 AFSL and Australian credit licence 233714. ", FontType)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "Equipment Finance by St.George Finance Limited ABN 99 001 094 471 Australian credit licence 387944.", FontType)); // phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "Automotive Finance by St.George Finance Limited ABN 99 001 094 471.", FontType)); // phraseTermAndCondition.Add(new Chunk(" Australian credit licence 387944 and St.George Motor Finance Limited ABN 53 007 656 555 Australian credit licence 387946.", FontType)); // phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "St.George Bank – A Division of Westpac Banking Corporation. ABN 33 007 457 141 AFSL and Australian credit licence 233714", FontType)); pdfDoc.Add(phraseTermAndCondition); #endregion TermAndCondition //Image and Text for Call //PdfPTable pdfTable = new PdfPTable(2); //pdfTable.HorizontalAlignment = Element.ALIGN_LEFT; //pdfTable.DefaultCell.Border = Rectangle.NO_BORDER; //pdfTable.SplitRows = false; //iTextSharp.text.Image image1 = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath("~/george.JPG"))); //image1.ScaleToFit(750f, 750f); //Chunk imageChunk1 = new Chunk(image1, 0, -30); //phrase = new Phrase(new Chunk(image1, 0, -30)); //PdfPCell imageCell = new PdfPCell(phrase); //imageCell.Border = 0; //imageCell.HorizontalAlignment = Element.ALIGN_LEFT; ; //PdfPCell fcell1 = new PdfPCell(new Phrase((": Call 13000"), FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.NORMAL))); //fcell1.Border = 0; //fcell1.HorizontalAlignment = Element.ALIGN_LEFT; //pdfTable.AddCell(imageCell); //pdfTable.AddCell(fcell1); //pdfTable.SetWidthPercentage(new float[2] { 20f, 10f }, PageSize.LETTER); //pdfTable.HorizontalAlignment = Element.ALIGN_LEFT; //pdfDoc.Add(pdfTable); //Header Part //iTextSharp.text.Image logoHeader = iTextSharp.text.Image.GetInstance(Server.MapPath("~/PDF.jpg")); //logoHeader.ScaleAbsolute(500, 300); //pdfDoc.Add(logoHeader); //PdfPCell cell = new PdfPCell(phrase); //tblFirstData.AddCell(cell); //pdfDoc.Add(tblFirstData); //AddDataInPDFTable objAddDataInPDFTable = new AddDataInPDFTable(); //objAddDataInPDFTable.AddTableInDoc(pdfDoc); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); } catch (Exception ex) { log.Fatal("Error in Submitbtn_Click() function." + ex.Message, ex); } }
/// <summary> /// Creates the document. /// </summary> /// <param name="reservationSummaryList"></param> /// <param name="logoFileUrl"></param> /// <param name="font"></param> /// <param name="filterStartDate"></param> /// <param name="filterEndDate"></param> /// <returns></returns> public override byte[] GenerateReport(List <ReservationService.ReservationSummary> reservationSummaryList, string logoFileUrl, string font, DateTime?filterStartDate, DateTime?filterEndDate, string lavaTemplate = "") { //Fonts var titleFont = FontFactory.GetFont(font, 16, Font.BOLD); var listHeaderFont = FontFactory.GetFont(font, 12, Font.BOLD, Color.DARK_GRAY); var listSubHeaderFont = FontFactory.GetFont(font, 10, Font.BOLD, Color.DARK_GRAY); var listItemFontNormal = FontFactory.GetFont(font, 8, Font.NORMAL); var listItemFontUnapproved = FontFactory.GetFont(font, 8, Font.ITALIC, Color.MAGENTA); var noteFont = FontFactory.GetFont(font, 8, Font.NORMAL, Color.GRAY); // Bind to Grid var reservationSummaries = reservationSummaryList.Select(r => new { Id = r.Id, ReservationName = r.ReservationName, ApprovalState = r.ApprovalState.ConvertToString(), Locations = r.ReservationLocations.ToList(), Resources = r.ReservationResources.ToList(), CalendarDate = r.EventStartDateTime.ToLongDateString(), EventStartDateTime = r.EventStartDateTime, EventEndDateTime = r.EventEndDateTime, ReservationStartDateTime = r.ReservationStartDateTime, ReservationEndDateTime = r.ReservationEndDateTime, EventDateTimeDescription = r.EventTimeDescription, ReservationDateTimeDescription = r.ReservationTimeDescription, Ministry = r.ReservationMinistry, ContactInfo = String.Format("{0} {1}", r.EventContactPersonAlias.Person.FullName, r.EventContactPhoneNumber), SetupPhotoId = r.SetupPhotoId, Note = r.Note }) .OrderBy(r => r.EventStartDateTime) .GroupBy(r => r.EventStartDateTime.Date) .Select(r => r.ToList()) .ToList(); //Setup the document var document = new Document(PageSize.A4.Rotate(), 25, 25, 25, 25); var outputStream = new MemoryStream(); var writer = PdfWriter.GetInstance(document, outputStream); // Our custom Header and Footer is done using Event Handler SPACTwoColumnHeaderFooter PageEventHandler = new SPACTwoColumnHeaderFooter(); writer.PageEvent = PageEventHandler; // Define the page header PageEventHandler.HeaderFont = listHeaderFont; PageEventHandler.SubHeaderFont = listSubHeaderFont; PageEventHandler.HeaderLeft = "Group"; PageEventHandler.HeaderRight = "1"; document.Open(); // Add logo try { iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(logoFileUrl); logo.Alignment = iTextSharp.text.Image.RIGHT_ALIGN; logo.ScaleToFit(300, 55); document.Add(logo); } catch { } // Write the document var today = RockDateTime.Today; var filterStartDateTime = filterStartDate.HasValue ? filterStartDate.Value : today; var filterEndDateTime = filterEndDate.HasValue ? filterEndDate.Value : today.AddMonths(1); String title = String.Format("Reservations for: {0} - {1}", filterStartDateTime.ToString("MMMM d"), filterEndDateTime.ToString("MMMM d")); document.Add(new Paragraph(title, titleFont)); Font zapfdingbats = new Font(Font.ZAPFDINGBATS); // Populate the Lists foreach (var reservationDay in reservationSummaries) { var firstReservation = reservationDay.FirstOrDefault(); if (firstReservation != null) { //Build Header document.Add(Chunk.NEWLINE); String listHeader = PageEventHandler.CalendarDate = firstReservation.CalendarDate; document.Add(new Paragraph(listHeader, listHeaderFont)); //Build Subheaders var listSubHeaderTable = new PdfPTable(8); listSubHeaderTable.LockedWidth = true; listSubHeaderTable.TotalWidth = PageSize.A4.Rotate().Width - document.LeftMargin - document.RightMargin; listSubHeaderTable.HorizontalAlignment = 0; listSubHeaderTable.SpacingBefore = 10; listSubHeaderTable.SpacingAfter = 0; listSubHeaderTable.DefaultCell.BorderWidth = 0; listSubHeaderTable.DefaultCell.BorderWidthBottom = 1; listSubHeaderTable.DefaultCell.BorderColorBottom = Color.DARK_GRAY; listSubHeaderTable.AddCell(new Phrase("Name", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Event Time", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Reservation Time", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Locations: NC, Unlock", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Resources", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Has Layout", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Status", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Contact Info", listSubHeaderFont)); PageEventHandler.IsHeaderShown = true; document.Add(listSubHeaderTable); foreach (var reservationSummary in reservationDay) { if (reservationSummary == reservationDay.Last()) { PageEventHandler.IsHeaderShown = false; } //Build the list item table var listItemTable = new PdfPTable(8); listItemTable.LockedWidth = true; listItemTable.TotalWidth = PageSize.A4.Rotate().Width - document.LeftMargin - document.RightMargin; listItemTable.HorizontalAlignment = 0; listItemTable.SpacingBefore = 0; listItemTable.SpacingAfter = 1; listItemTable.DefaultCell.BorderWidth = 0; //if ( string.IsNullOrWhiteSpace( reservationSummary.Note ) || // reservationLocation != reservationSummary.Locations.First() ) //{ // listItemTable.DefaultCell.BorderWidthBottom = 1; // listItemTable.DefaultCell.BorderColorBottom = Color.DARK_GRAY; //} //Add the list items listItemTable.AddCell(new Phrase(reservationSummary.ReservationName, listItemFontNormal)); listItemTable.AddCell(new Phrase(reservationSummary.EventDateTimeDescription, listItemFontNormal)); listItemTable.AddCell(new Phrase(reservationSummary.ReservationDateTimeDescription, listItemFontNormal)); List locationList = new List(List.UNORDERED, 8f); locationList.SetListSymbol("\u2022"); foreach (var reservationLocation in reservationSummary.Locations) { var listItem = new iTextSharp.text.ListItem(reservationLocation.Location.Name, listItemFontNormal); if (reservationLocation.ApprovalState == ReservationLocationApprovalState.Approved) { listItem.Add(new Phrase("\u0034", zapfdingbats)); } locationList.Add(listItem); } PdfPCell locationCell = new PdfPCell(); locationCell.Border = 0; locationCell.PaddingTop = -2; locationCell.PaddingBottom = 2; locationCell.AddElement(locationList); locationCell.BorderWidth = 0; //if ( string.IsNullOrWhiteSpace( reservationSummary.Note ) || // reservationLocation != reservationSummary.Locations.First() ) //{ // locationCell.BorderWidthBottom = 1; // locationCell.BorderColorBottom = Color.DARK_GRAY; //} listItemTable.AddCell(locationCell); List resourceList = new List(List.UNORDERED, 8f); resourceList.SetListSymbol("\u2022"); foreach (var reservationResource in reservationSummary.Resources) { reservationResource.LoadReservationResourceAttributes(); var resourceListItem = new iTextSharp.text.ListItem(string.Format("{0} ({1})", reservationResource.Resource.Name, reservationResource.Resource.Quantity), listItemFontNormal); resourceList.Add(resourceListItem); } PdfPCell resourceCell = new PdfPCell(); resourceCell.Border = 0; resourceCell.PaddingTop = -2; resourceCell.PaddingBottom = 2; resourceCell.AddElement(resourceList); resourceCell.BorderWidth = 0; // resources listItemTable.AddCell(resourceCell); // Has Layout listItemTable.AddCell(new Phrase((reservationSummary.SetupPhotoId.HasValue) ? "Yes" : "No", listItemFontNormal)); // approval status listItemTable.AddCell(new Phrase(reservationSummary.ApprovalState, listItemFontNormal)); PdfPCell contactCell = new PdfPCell(); contactCell.Border = 0; contactCell.PaddingTop = -2; contactCell.PaddingBottom = 2; contactCell.AddElement(new Phrase(reservationSummary.Ministry != null ? reservationSummary.Ministry.Name : string.Empty, listItemFontNormal)); contactCell.AddElement(new Phrase(reservationSummary.ContactInfo, listItemFontNormal)); contactCell.BorderWidth = 0; //if ( string.IsNullOrWhiteSpace( reservationSummary.Note ) || // reservationLocation != reservationSummary.Locations.First() ) //{ // contactCell.BorderWidthBottom = 1; // contactCell.BorderColorBottom = Color.DARK_GRAY; //} listItemTable.AddCell(contactCell); document.Add(listItemTable); if (!string.IsNullOrWhiteSpace(reservationSummary.Note)) { //document.Add( Chunk.NEWLINE ); var listNoteTable = new PdfPTable(8); listNoteTable.LockedWidth = true; listNoteTable.TotalWidth = PageSize.A4.Rotate().Width - document.LeftMargin - document.RightMargin; listNoteTable.HorizontalAlignment = 1; listNoteTable.SpacingBefore = 0; listNoteTable.SpacingAfter = 1; listNoteTable.DefaultCell.BorderWidth = 0; listNoteTable.DefaultCell.BorderWidthBottom = 1; listNoteTable.DefaultCell.BorderColorBottom = Color.DARK_GRAY; listNoteTable.AddCell(new Phrase(string.Empty, noteFont)); var noteCell = new PdfPCell(new Phrase(reservationSummary.Note, noteFont)); noteCell.Border = 0; noteCell.Colspan = 7; listNoteTable.AddCell(noteCell); document.Add(listNoteTable); } } } document.NewPage(); } document.Close(); return(outputStream.ToArray()); }
// =========================================================================== public void Write(Stream stream) { // step 1 using (Document document = new Document()) { // step 2 PdfWriter.GetInstance(document, stream); // step 3 document.Open(); // step 4 var SQL = @"SELECT DISTINCT mc.country_id, c.country, count(*) AS c FROM film_country c, film_movie_country mc WHERE c.id = mc.country_id GROUP BY mc.country_id, country ORDER BY c DESC"; // Create a new list List list = new List(List.ORDERED); list.Autoindent = false; list.SymbolIndent = 36; // loop over the countries using (var c = AdoDB.Provider.CreateConnection()) { c.ConnectionString = AdoDB.CS; using (DbCommand cmd = c.CreateCommand()) { cmd.CommandText = SQL; c.Open(); using (var r = cmd.ExecuteReader()) { while (r.Read()) { // create a list item for the country ListItem item = new ListItem( string.Format("{0}: {1} movies", r["country"].ToString(), r["c"].ToString() ) ); item.ListSymbol = new Chunk(r["country_id"].ToString()); // Create a list for the movies produced in the current country List movielist = new List(List.ORDERED, List.ALPHABETICAL); movielist.Alignindent = false; foreach (Movie movie in PojoFactory.GetMovies(r["country_id"].ToString()) ) { ListItem movieitem = new ListItem(movie.MovieTitle); List directorlist = new List(List.ORDERED); directorlist.PreSymbol = "Director "; directorlist.PostSymbol = ": "; foreach (Director director in movie.Directors) { directorlist.Add(String.Format("{0}, {1}", director.Name, director.GivenName )); } movieitem.Add(directorlist); movielist.Add(movieitem); } item.Add(movielist); list.Add(item); } document.Add(list); } } } } }
// --------------------------------------------------------------------------- public void Write(Stream stream) { // step 1 using (Document document = new Document()) { // step 2 PdfWriter writer = PdfWriter.GetInstance(document, stream); // step 3 document.Open(); // step 4 PdfCollection collection = new PdfCollection(PdfCollection.HIDDEN); PdfCollectionSchema schema = _collectionSchema(); collection.Schema = schema; PdfCollectionSort sort = new PdfCollectionSort(KEYS); collection.Sort = sort; writer.Collection = collection; PdfCollectionItem collectionitem = new PdfCollectionItem(schema); PdfFileSpecification fs = PdfFileSpecification.FileEmbedded( writer, IMG_KUBRICK, "kubrick.jpg", null ); fs.AddDescription("Stanley Kubrick", false); collectionitem.AddItem(TYPE_FIELD, "JPEG"); fs.AddCollectionItem(collectionitem); writer.AddFileAttachment(fs); Image img = Image.GetInstance(IMG_BOX); document.Add(img); List list = new List(List.UNORDERED, 20); PdfDestination dest = new PdfDestination(PdfDestination.FIT); dest.AddFirst(new PdfNumber(1)); PdfTargetDictionary intermediate; PdfTargetDictionary target; Chunk chunk; ListItem item; PdfAction action = null; IEnumerable<Movie> box = PojoFactory.GetMovies(1) .Concat(PojoFactory.GetMovies(4)) ; StringBuilder sb = new StringBuilder(); foreach (Movie movie in box) { if (movie.Year > 1960) { sb.AppendLine(String.Format( "{0};{1};{2}", movie.MovieTitle, movie.Year, movie.Duration )); item = new ListItem(movie.MovieTitle); if (!"0278736".Equals(movie.Imdb)) { target = new PdfTargetDictionary(true); target.EmbeddedFileName = movie.Title; intermediate = new PdfTargetDictionary(true); intermediate.FileAttachmentPage = 1; intermediate.FileAttachmentIndex = 1; intermediate.AdditionalPath = target; action = PdfAction.GotoEmbedded(null, intermediate, dest, true); chunk = new Chunk(" (see info)"); chunk.SetAction(action); item.Add(chunk); } list.Add(item); } } document.Add(list); fs = PdfFileSpecification.FileEmbedded( writer, null, "kubrick.txt", Encoding.UTF8.GetBytes(sb.ToString()) ); fs.AddDescription("Kubrick box: the movies", false); collectionitem.AddItem(TYPE_FIELD, "TXT"); fs.AddCollectionItem(collectionitem); writer.AddFileAttachment(fs); PdfPTable table = new PdfPTable(1); table.SpacingAfter = 10; PdfPCell cell = new PdfPCell(new Phrase("All movies by Kubrick")); cell.Border = PdfPCell.NO_BORDER; fs = PdfFileSpecification.FileEmbedded( writer, null, KubrickMovies.FILENAME, Utility.PdfBytes(new KubrickMovies()) //new KubrickMovies().createPdf() ); collectionitem.AddItem(TYPE_FIELD, "PDF"); fs.AddCollectionItem(collectionitem); target = new PdfTargetDictionary(true); target.FileAttachmentPagename = "movies"; target.FileAttachmentName = "The movies of Stanley Kubrick"; cell.CellEvent = new PdfActionEvent( writer, PdfAction.GotoEmbedded(null, target, dest, true) ); cell.CellEvent = new FileAttachmentEvent( writer, fs, "The movies of Stanley Kubrick" ); cell.CellEvent = new LocalDestinationEvent(writer, "movies"); table.AddCell(cell); writer.AddFileAttachment(fs); cell = new PdfPCell(new Phrase("Kubrick DVDs")); cell.Border = PdfPCell.NO_BORDER; fs = PdfFileSpecification.FileEmbedded( writer, null, KubrickDvds.RESULT, new KubrickDvds().CreatePdf() ); collectionitem.AddItem(TYPE_FIELD, "PDF"); fs.AddCollectionItem(collectionitem); cell.CellEvent = new FileAttachmentEvent(writer, fs, "Kubrick DVDs"); table.AddCell(cell); writer.AddFileAttachment(fs); cell = new PdfPCell(new Phrase("Kubrick documentary")); cell.Border = PdfPCell.NO_BORDER; fs = PdfFileSpecification.FileEmbedded( writer, null, KubrickDocumentary.RESULT, new KubrickDocumentary().CreatePdf() ); collectionitem.AddItem(TYPE_FIELD, "PDF"); fs.AddCollectionItem(collectionitem); cell.CellEvent = new FileAttachmentEvent( writer, fs, "Kubrick Documentary" ); table.AddCell(cell); writer.AddFileAttachment(fs); document.NewPage(); document.Add(table); } }
private void GeneratePDFAndMail() { log4net.ILog log = log4net.LogManager.GetLogger("ServiceRowDataBound"); log4net.Config.XmlConfigurator.Configure(); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 7f, 7f, 7f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); MemoryStream memoryStream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream); pdfDoc.Open(); /* iTextSharp.text.Image imgStlogo = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath(@"StG_Master_Logo_RGB.jpg"))); imgStlogo.SetAbsolutePosition(0, pdfDoc.PageSize.Height - imgStlogo.Height); pdfDoc.Add(imgStlogo); pdfDoc.Add(new Paragraph(" ")); pdfDoc.Add(new Paragraph(" ")); pdfDoc.Add(new Paragraph(" "));*/ iTextSharp.text.Image imgStlogo = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath(@"StG_Master_Logo_RGBold.jpg"))); PdfPTable pdfTable = new PdfPTable(1); // pdfTable.DefaultCell.Border = Rectangle.NO_BORDER; // pdfTable.SplitRows = false; imgStlogo.ScaleToFit(183f, 66f); PdfPCell imageCell = new PdfPCell(imgStlogo); imageCell.Border = 0; pdfTable.AddCell(imageCell); pdfTable.HorizontalAlignment = Element.ALIGN_LEFT; pdfDoc.Add(pdfTable); pdfDoc.Add(new Paragraph("")); iTextSharp.text.Font font18 = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8); iTextSharp.text.Chunk bullet = new iTextSharp.text.Chunk("\u2022", font18); iTextSharp.text.List list = new iTextSharp.text.List(false, 4); // true= ordered, false= unordered iTextSharp.text.List list1 = new iTextSharp.text.List(false, 4); // true= ordered, false= unordered string amt = "8"; string atm = "Freedom Business Account"; var phrase = new Phrase(); string strTextData = Environment.NewLine + "Thank you for completing the Business Account Selector tool. You’ll find your results below." + Environment.NewLine + "We understand that no two businesses are the same and we want to help you make the right decisions for your business to be successful." + Environment.NewLine + "Like every great relationship, it starts with a conversation. So if you have any questions or want to take the next steps:" + Environment.NewLine; iTextSharp.text.Font FontTypeBold = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.BOLD); iTextSharp.text.Font FontTypeBoldlarge = FontFactory.GetFont("Arial", 10f, iTextSharp.text.Font.BOLD); iTextSharp.text.Font FontType = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.NORMAL); iTextSharp.text.Font FontTypeSmall = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.NORMAL); phrase = new Phrase(); phrase.Add(new Chunk("Business Account and Product Selector Results", FontTypeBoldlarge)); phrase.Add(new Chunk(Environment.NewLine +"Hello " + txtName.Text, FontTypeBold)); phrase.Add(new Chunk(strTextData, FontType)); pdfDoc.Add(phrase); PdfPTable tblCall = new PdfPTable(1); tblCall.WidthPercentage = 30f; tblCall.HorizontalAlignment = Element.ALIGN_LEFT; tblCall.DefaultCell.Border = Rectangle.NO_BORDER; iTextSharp.text.Image imgCall = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath(@"pdfCTA-1.png"))); tblCall.AddCell(imgCall); pdfDoc.Add(tblCall); phrase = new Phrase(); phrase.Add(new Chunk("To find out what information is needed to become a customer, visit ", FontType)); pdfDoc.Add(phrase); Font link = FontFactory.GetFont("Arial", 8, Font.UNDERLINE, new Color(0, 0, 255)); Anchor anchor = new Anchor("http://www.stgeorge.com.au/idchecklist", link); anchor.Reference = "http://www.stgeorge.com.au/idchecklist"; pdfDoc.Add(anchor); pdfDoc.Add(new Phrase(Environment.NewLine + Environment.NewLine, FontType)); #region CodeFonewFourProduct PdfPTable pdfpTableAdditionalProductnew = new PdfPTable(2); pdfpTableAdditionalProductnew.WidthPercentage = 100f; int[] TableAdditionalProductwidthnew = { 30, 70 }; pdfpTableAdditionalProductnew.SetWidths(TableAdditionalProductwidthnew); phrase = new Phrase(" " + Environment.NewLine); phrase.Add(new Chunk("My Business Connect", FontTypeBold)); phrase.Add(Environment.NewLine + " "); PdfPCell cellAdditionalProductnew = new PdfPCell(phrase); cellAdditionalProductnew.Colspan = 3; //Used to checked Last Five product is selected bool isLastFourProductSelected = false; if (fifteenid.Checked) { // pdfDoc.NewPage(); pdfpTableAdditionalProductnew.AddCell(cellAdditionalProductnew); isLastFourProductSelected = true; PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Planning and Setup", FontTypeBold)); pdfpTableAdditionalProductnew.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Make a business plan?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Follow the PlanHQ business plan wizard to produce a personalised business plan",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Understand and manage the tasks associated with setting up a business",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 2; pdfpTableAdditionalProductnew.AddCell(objCell); } if (sixteenid.Checked) { if (!isLastFourProductSelected) { // pdfDoc.NewPage(); pdfpTableAdditionalProductnew.AddCell(cellAdditionalProductnew); isLastFourProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Manage Finances", FontTypeBold)); pdfpTableAdditionalProductnew.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Track money coming in and out of the business?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine + "Keep track of receipts without the data entry?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Saasu helps make managing and monitoring business cash flow and finances simpler and more straightforward",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Receipt Bank is the quick and easy way of recording receipts and invoices. No more entering data manually – just take a photo of a receipt and send it for processing in the click of a button",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); // phrase.Add(new Chunk(Environment.NewLine + "Equipment Finance is offered by St.George Finance Limited ACL 387944."+Environment.NewLine+" Automotive Finance is offered by St.George Finance Limited ACL 387944 and St.George Motor Finance Limited ACL 387946.",FontType)); // objCell.AddElement(new Phrase("Equipment Finance by St.George Finance Limited Australian credit licence 387944.The Automotive Finance by St.George Finance Limited and St.George Motor Finance Limited Australian credit licence 387946")); var phBecauseText1 = new Phrase(); phBecauseText1.Add(new Chunk(Environment.NewLine + "Equipment Finance by St.George Finance Limited Australian credit licence 387944.",FontType)); // phBecauseText1.Add(new Chunk(Environment.NewLine + "Automotive Finance by St.George Finance Limited Australian credit licence 387944 and St.George Motor Finance Limited Australian credit licence 387946.",FontType)); objCell.AddElement(phBecauseText1); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProductnew.AddCell(objCell); } if (seventeenid.Checked) { if (!isLastFourProductSelected) { //pdfDoc.NewPage(); pdfpTableAdditionalProductnew.AddCell(cellAdditionalProductnew); isLastFourProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Grow Online", FontTypeBold)); pdfpTableAdditionalProductnew.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Create a mobile friendly website to promote online?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine + "Create email campaigns to engage customers?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Online includes an easy to use website builder, ongoing hosting, an e-commerce shop and a business domain name",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Act! Cloud helps businesses manage their customer data and build professional e-marketing campaigns to turn opportunities into sales",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProductnew.AddCell(objCell); } if (eighteenid.Checked) { if (!isLastFourProductSelected) { // pdfDoc.NewPage(); pdfpTableAdditionalProductnew.AddCell(cellAdditionalProductnew); isLastFourProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Business Protection", FontTypeBold)); pdfpTableAdditionalProductnew.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Protect the business from data loss?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine + "Create legal documents and contract?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("MozyPro helps safeguard business data by providing secure, automated, highly encrypted data backup. Lost, damaged or stolen files can be restored from MozyPro on demand",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Law Central helps businesses to create the legal documents they need using a simple question-and-answer system. All documents are written and maintained by an Australian lawyer",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProductnew.AddCell(objCell); } if (eighteenid.Checked && seventeenid.Checked && sixteenid.Checked ) { } else { //Business%20Access%20Saver var bizntu = bizpacknameneshatnewproduct.Text; Phrase phBecauseTextu = new Phrase(); phBecauseTextu.Add(new Chunk("Because the following have not been selected, 'My Business Connect' savings have not been unlocked:", FontType)); Phrase phBecauseText21 = new Phrase(); phBecauseText21.Add(new Chunk(Environment.NewLine + "My Business Connect", FontTypeBold)); phBecauseText21.Add(new Chunk(Environment.NewLine + "Choose from four packages with market leading applications geared towards managing finances growing online, protecting business against risk and planning and setup"+bizntu, FontType)); //phBecauseText2.Add(new Chunk(Environment.NewLine + "BizPack-ed full of savings:", FontType)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; if(bizntu.Contains("Manage Finances")){ list.Add(new iTextSharp.text.ListItem(new Chunk("Manage Finances",FontType))); } if(bizntu.Contains("Grow Online")){ list.Add(new iTextSharp.text.ListItem(new Chunk("Grow Online",FontType))); } if(bizntu.Contains("Business Protection")){ list.Add(new iTextSharp.text.ListItem(new Chunk("Business Protection",FontType))); } list1 = new iTextSharp.text.List(false, 8); list1.ListSymbol = bullet; list1.Add(new iTextSharp.text.ListItem(new Chunk("Apps are accessible from any device with an internet connection.",FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Only one username and password is required to access all purchased applications.",FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Get one simple monthly bill for all applications.",FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Customer support is available to help with questions on how to use the apps.",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phBecauseTextu); objCell.AddElement(list); objCell.AddElement(phBecauseText21); objCell.AddElement(list1); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProductnew.AddCell(objCell); //pdfDoc.Add(pdftblAllData); } pdfDoc.Add(pdfpTableAdditionalProductnew); #endregion CodeFornewFourProduct var phraseTermAndConditionkalunew = new Phrase(); phraseTermAndConditionkalunew.Add(new Chunk(Environment.NewLine + "", FontTypeBold)); pdfDoc.Add(phraseTermAndConditionkalunew); #region CodeForLastFiveProduct PdfPTable pdfpTableAdditionalProduct = new PdfPTable(2); pdfpTableAdditionalProduct.WidthPercentage = 100f; int[] TableAdditionalProductwidth = { 30, 70 }; pdfpTableAdditionalProduct.SetWidths(TableAdditionalProductwidth); phrase = new Phrase(" " + Environment.NewLine); phrase.Add(new Chunk("Business Products", FontTypeBold)); phrase.Add(Environment.NewLine + " "); PdfPCell cellAdditionalProduct = new PdfPCell(phrase); cellAdditionalProduct.Colspan = 3; //Used to checked Last Five product is selected bool isLastFiveProductSelected = false; if (Eftposandmerchantfacilities.Checked) { // pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"EFTPOS and merchant facilities", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Customers being able to pay with a debit card?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine + "Customers being able to pay with a credit card?",FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("To accept debit and credit cards from customers, whether it’s in person, over the phone or online, St.George has a range of EFTPOS and merchant solutions",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Get same-day settlement (when the terminal is settled before 9pm Sydney time) on debit and credit card sales, 7 days a week, when linked to a St.George business transaction account",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 2; pdfpTableAdditionalProduct.AddCell(objCell); } if (EquipmentFinance.Checked) { if (!isLastFiveProductSelected) { // pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Equipment finance", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Purchasing a vehicle?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine + "Purchasing equipment or machinery?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Finance up to 100% of the purchase price for vehicles or equipment",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Frees up money to run a business, rather than tying up working capital",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); // phrase.Add(new Chunk(Environment.NewLine + "Equipment Finance is offered by St.George Finance Limited ACL 387944."+Environment.NewLine+" Automotive Finance is offered by St.George Finance Limited ACL 387944 and St.George Motor Finance Limited ACL 387946.",FontType)); // objCell.AddElement(new Phrase("Equipment Finance by St.George Finance Limited Australian credit licence 387944.The Automotive Finance by St.George Finance Limited and St.George Motor Finance Limited Australian credit licence 387946")); var phBecauseText1 = new Phrase(); phBecauseText1.Add(new Chunk(Environment.NewLine + "Equipment Finance by St.George Finance Limited Australian credit licence 387944.",FontType)); // phBecauseText1.Add(new Chunk(Environment.NewLine + "Automotive Finance by St.George Finance Limited Australian credit licence 387944 and St.George Motor Finance Limited Australian credit licence 387946.",FontType)); objCell.AddElement(phBecauseText1); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProduct.AddCell(objCell); } if (LendingfortheBusiness.Checked) { if (!isLastFiveProductSelected) { //pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Lending for a Business", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Purchasing a business?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine + "Expanding a business?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("St.George has a number of lending options to give a business a cash injection",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("This includes both residentially and commercially secured loans or a combination of these",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProduct.AddCell(objCell); } if (BankGuarantee.Checked) { if (!isLastFiveProductSelected) { // pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Bank guarantee", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Provide a landlord a guarantee of payment when renting premises?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine + "Provide customers or suppliers a guarantee of payment to secure a contract?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Allows a business to offer customers and suppliers a surety of payment without having to provide them a cash deposit upfront",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Where security other than cash is provided, this can free up money for other investment opportunities, and helps manage the highs and lows of cash flow",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProduct.AddCell(objCell); } if (freetax.Checked) { if (!isLastFiveProductSelected) { // pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Online legal and tax advice", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Legal and tax advice?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); //list.Add(new iTextSharp.text.ListItem(new Chunk("St.George provides business customers with access to free online legal and taxation advice",FontType))); iTextSharp.text.ListItem LstItm =new iTextSharp.text.ListItem(); LstItm.Add(new Chunk("St.George provides business customers with access to free online legal and taxation advice",FontType)); LstItm.Add(new Chunk("3", FontFactory.GetFont(FontFactory.HELVETICA, 5)).SetTextRise(4)); list.Add(LstItm); list.Add(new iTextSharp.text.ListItem(new Chunk("Access this service by sending a confidential email to the third party provider",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("For more information, visit http://www.stgeorge.com.au/business/business-tools/legal-tax-advice",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdfpTableAdditionalProduct.AddCell(objCell); } /* if (freetax.Checked) { if (!isLastFiveProductSelected) { pdfDoc.NewPage(); pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct); isLastFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Online legal and tax advice", FontTypeBold)); pdfpTableAdditionalProduct.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Legal and tax advice?", FontTypeBold)); phrase.Add(new Chunk(Environment.NewLine + "St.George provides customers with access to free online legal and taxation advice." + Environment.NewLine + "Accessing this service is easy, existing customers can access this service by sending a confidential email to Legal Access Services." + Environment.NewLine + "Legal and accountancy services are not provided by St.George. St.George accepts no responsibility for any advice provided by these third parties. Advice is available by email only.",FontType)); phrase.Add(Environment.NewLine + "For more information,"); link = FontFactory.GetFont("Arial", 12, Font.UNDERLINE, new Color(0, 0, 255)); anchor = new Anchor("http://www.stgeorge.com.au/business/business-tools/legal-tax-advice", link); anchor.Reference = "http://www.stgeorge.com.au/business/business-tools/legal-tax-advice"; phrase.Add(anchor); phrase.Add(Environment.NewLine + " "); PdfPCell cell2 = new PdfPCell(phrase); pdfpTableAdditionalProduct.AddCell(cell2); list = new iTextSharp.text.List(false, 12); list.ListSymbol = bullet; list.Add(new iTextSharp.text.ListItem("St.George provides customers with access to free online legal and taxation advice")); list.Add(new iTextSharp.text.ListItem("Accessing this service is easy, existing customers can access this service by sending a confidential email to Legal Access Services")); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); phrase = new Phrase(); phrase.Add(Environment.NewLine + "For more information,"); link = FontFactory.GetFont("Arial", 12, Font.UNDERLINE, new Color(0, 0, 255)); anchor = new Anchor("http://www.stgeorge.com.au/business/business-tools/legal-tax-advice", link); anchor.Reference = "http://www.stgeorge.com.au/business/business-tools/legal-tax-advice"; phrase.Add(anchor); objCell.AddElement(phrase); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 2; pdfpTableAdditionalProduct.AddCell(objCell); }*/ pdfDoc.Add(pdfpTableAdditionalProduct); #endregion CodeForLastFiveProduct var phraseTermAndConditionkalu = new Phrase(); phraseTermAndConditionkalu.Add(new Chunk(Environment.NewLine + "", FontTypeBold)); pdfDoc.Add(phraseTermAndConditionkalu); #region CodeForTopFiveProduct PdfPTable pdftblAllData = new PdfPTable(2); pdftblAllData.WidthPercentage = 100f; int[] firstTablecellwidth = { 30, 70}; pdftblAllData.SetWidths(firstTablecellwidth); phrase = new Phrase(" " + Environment.NewLine); phrase.Add(new Chunk("BizPack Essentials", FontTypeBold)); phrase.Add(Environment.NewLine + " "); PdfPCell cellBizPack = new PdfPCell(phrase); cellBizPack.Colspan = 2; //Used to checked topfive product is selected bool IsTopFiveProductSelected = false; if (BusinessChequeAccountPlus.Checked) { amt ="18"; atm ="Business Cheque Account Plus"; pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Business Cheque Account Plus", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("An everyday account used to pay suppliers and have funds paid into?", FontTypeBold)); list = new iTextSharp.text.List(false, 4); list.ListSymbol = bullet; /* phrase = new Phrase(); phrase.Add(new Chunk("Day-to-day electronic transactions are fee-free")); phrase.Add(new Chunk("1", FontFactory.GetFont(FontFactory.HELVETICA, 6)).SetTextRise(4)); phrase.Add(new Chunk(",TestTestTest")); */ //list.Add(new iTextSharp.text.ListItem("With this account, all day-to-day electronic transactions are fee-free1")); iTextSharp.text.ListItem LstItm =new iTextSharp.text.ListItem(); LstItm.Add(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType)); LstItm.Add(new Chunk("1", FontFactory.GetFont(FontFactory.HELVETICA, 5)).SetTextRise(4)); list.Add(LstItm); list.Add(new iTextSharp.text.ListItem(new Chunk("Plus, get 55 free in-branch transactions (over the counter) or cheque withdrawals every month",FontType))); /*list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("1",FontType).SetTextRise(4))); list.Add(new iTextSharp.text.ListItem(new Chunk("Plus, get 50 free in-branch transactions (over the counter) or cheque withdrawals every month",FontType))); */ /* iTextSharp.text.ListItem LstItm =new iTextSharp.text.ListItem(); LstItm.Add(new Chunk("With this account, the day-to-day electronic transactions are fee-free")); LstItm.Add(new Chunk("1", FontFactory.GetFont(FontFactory.HELVETICA, 6)).SetTextRise(4)); list.Add(LstItm); list.Add(new iTextSharp.text.ListItem(new Chunk("no matter how many are made"))); */ //list.Add(new iTextSharp.text.ListItem("Plus, get 50 free in-branch transactions (over the counter) or cheque withdrawals every month")); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if (FreedomBusinessAccount.Checked) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } amt ="8"; atm ="Freedom Business Account"; PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Freedom Business Account", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("An everyday account used to pay suppliers and have funds paid into?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; //list.Add(new iTextSharp.text.ListItem("With this account, all day-to-day electronic transactions are fee-free1")); //list.Add(new iTextSharp.text.ListItem("Plus, get 20 free in-branch transactions (over the counter) or cheque withdrawals every month")); /*list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("1",FontType).SetTextRise(4))); list.Add(new iTextSharp.text.ListItem(new Chunk("Plus, get 20 free in-branch transactions (over the counter) or cheque withdrawals every month",FontType))); */ iTextSharp.text.ListItem LstItm =new iTextSharp.text.ListItem(); LstItm.Add(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType)); LstItm.Add(new Chunk("1", FontFactory.GetFont(FontFactory.HELVETICA, 5)).SetTextRise(4)); list.Add(LstItm); list.Add(new iTextSharp.text.ListItem(new Chunk("Plus, get 20 free in-branch transactions (over the counter) or cheque withdrawals every month",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if (BusinessVisaDebitCard.Checked) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Business Visa Debit Card", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); //phrase.Add(new Chunk("Business Visa Debit Card", FontTypeBold)); phrase.Add(new Chunk("Access cash from an ATM?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine +"Make purchases in person, over the phone or online?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; //list.Add(new iTextSharp.text.ListItem(new Chunk("Plus, get 20 free in-branch transactions (over the counter) or cheque withdrawals every month",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Access funds from the "+atm+" at ATMs",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Make purchases in person, over the phone and online, wherever Visa is accepted (that's over 32 million locations worldwide)",FontType))); PdfPCell objCell = new PdfPCell(); //objCell.PaddingTop = -5; //objCell1.PaddingBottom = 1; //objCell1.PaddingTop = 1; objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if (BusinessAccessSaver.Checked) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Business Access Saver", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); phrase.Add(new Chunk("Put money away for tax and other future payments?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine +"Earn interest on this money?", FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; //list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Enables money to be parked for future payments (like GST and regular bills), while also earning interest along the way",FontType))); iTextSharp.text.ListItem LstItm =new iTextSharp.text.ListItem(); LstItm.Add(new Chunk("Day-to-day electronic transactions are fee-free",FontType)); LstItm.Add(new Chunk("1", FontFactory.GetFont(FontFactory.HELVETICA, 5)).SetTextRise(4)); LstItm.Add(new Chunk(", as are 4 in-branch deposits (over the counter) every month",FontType)); list.Add(LstItm); // list.Add(new iTextSharp.text.ListItem(new Chunk("Day-to-day electronic transactions are fee-free1, as are 4 in-branch deposits (over the counter) every month",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if (BusinessBankingOnline.Checked) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Business Banking Online", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); //phrase.Add(new Chunk("Business Visa Debit Card", FontTypeBold)); phrase.Add(new Chunk("Manage money 24/7?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine +"Manage money when on the move?", FontTypeBold)); /*phrase.Add(new Chunk(Environment.NewLine +"Business Banking Online won the 2013 Best Internet Business Bank, in the AB+F Corporate and Business Banking Awards.",FontType)); phrase.Add(new Chunk(Environment.NewLine +" Take control of business banking:",FontType)); phrase.Add(new Chunk(Environment.NewLine +" Ability to set daily payment limits",FontType)); phrase.Add(new Chunk(Environment.NewLine +" Allow multiple users to have access to business accounts",FontType)); phrase.Add(new Chunk(Environment.NewLine +" Nominate which users can authorise transactions using authentication device",FontType)); phrase.Add(new Chunk(Environment.NewLine +" Get ultimate portability with Business Banking Mobile",FontType)); phrase.Add(Environment.NewLine + " "); PdfPCell cell2 = new PdfPCell(phrase); pdftblAllData.AddCell(cell2); */ list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; list1 = new iTextSharp.text.List(false, 8); list1.ListSymbol = bullet; ////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Business Banking Online won the 2013 Best Internet Business Bank, in the AB+F Corporate and Business Banking Awards",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Take control of business banking:",FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Ability to set daily payment limits",FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Allow multiple users to have access to business accounts",FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Nominate which users can authorise transactions using authentication device",FontType))); list1.Add(new iTextSharp.text.ListItem(new Chunk("Get ultimate portability with Business Banking Mobile",FontType))); list.Add(list1); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } var v1 = cardintwo.Text; if (v1.Contains("Vantage")) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"BusinessVantage Visa Credit Card", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); //phrase.Add(new Chunk("Business Visa Debit Card", FontTypeBold)); phrase.Add(new Chunk("A credit card to help manage business expenses and cash flow?", FontTypeBold)); phrase.Add(new Chunk(" and/or",FontType)); phrase.Add(new Chunk(Environment.NewLine +"Separate business and personal expenses?", FontTypeBold)); /*phrase.Add(new Chunk(Environment.NewLine +"Low variable purchase rate (currently 9.99% p.a.) and up to 55 days interest free on purchases when closing balance paid by the due date",FontType)); phrase.Add(new Chunk(Environment.NewLine +"A dedicated business credit card keeps business and personal expenses separate",FontType)); phrase.Add(new Chunk(Environment.NewLine +"Provides peace of mind knowing extra working capital is at hand to help manage the highs and lows of cash flow",FontType)); phrase.Add(Environment.NewLine + " "); PdfPCell cell2 = new PdfPCell(phrase); pdftblAllData.AddCell(cell2);*/ list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; //////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Low variable purchase rate (currently 9.99% p.a.) and up to 55 days interest free on purchases when closing balance paid by the due date",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("A dedicated business credit card keeps business and personal expenses separate",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Provides peace of mind knowing extra working capital is at hand to help manage the highs and lows of cash flow",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } var v2 = cardintwo.Text; if (v2.Contains("Amplify")) { if (!IsTopFiveProductSelected) { pdftblAllData.AddCell(cellBizPack); IsTopFiveProductSelected = true; } PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Amplify Business Credit Card", FontTypeBold)); pdftblAllData.AddCell(Cell1); phrase = new Phrase(); //phrase.Add(new Chunk("Business Visa Debit Card", FontTypeBold)); phrase.Add(new Chunk("A credit card to help manage business expenses and cash flow?", FontTypeBold)); phrase.Add(new Chunk(" and/or", FontType)); phrase.Add(new Chunk(Environment.NewLine + "Separate business and personal expenses?", FontTypeBold)); /*phrase.Add(new Chunk(Environment.NewLine +"Low variable purchase rate (currently 9.99% p.a.) and up to 55 days interest free on purchases when closing balance paid by the due date",FontType)); phrase.Add(new Chunk(Environment.NewLine +"A dedicated business credit card keeps business and personal expenses separate",FontType)); phrase.Add(new Chunk(Environment.NewLine +"Provides peace of mind knowing extra working capital is at hand to help manage the highs and lows of cash flow",FontType)); phrase.Add(Environment.NewLine + " "); PdfPCell cell2 = new PdfPCell(phrase); pdftblAllData.AddCell(cell2);*/ list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; //////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Earn uncapped rewards points", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Choose between two great reward programs - Amplify Rewards or Amplify Qantas", FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Enjoy a range of complimentary insurance covers", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phrase); objCell.AddElement(list); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } if(BusinessAccessSaver.Checked && BusinessBankingOnline.Checked && (FreedomBusinessAccount.Checked || BusinessChequeAccountPlus.Checked)){ var v3 = cardintwo.Text; var phBecauseText = new Phrase(); phBecauseText.Add(new Chunk("All the BizPack Essentials for only $"+amt+" per month in account keeping fees*." + Environment.NewLine + Environment.NewLine + "BizPack-ed full of savings:",FontTypeBold)); list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Business Banking Online monthly access fee (currently $30 a month) waived, saving $360 annually",FontType))); //new product if (v3.Contains("Vantage")){ list.Add(new iTextSharp.text.ListItem(new Chunk("BusinessVantage Visa Credit Card annual fee (currently $55 per card) waived for up to 3 cards, saving up to $165 annually", FontType))); }else{ list.Add(new iTextSharp.text.ListItem(new Chunk("Business Credit Card annual fee waived for up to 3 cards, saving up to $165 annually", FontType))); } //end new product list.Add(new iTextSharp.text.ListItem(new Chunk("Establishment fee for each new EFTPOS and merchant terminal waived, current saving of $77 per terminal",FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phBecauseText); objCell.AddElement(list); var phBecauseText1 = new Phrase(); phBecauseText1.Add(new Chunk(Environment.NewLine + "*Transaction fees and special service fees may also apply.",FontType)); objCell.AddElement(phBecauseText1); // objCell.AddElement(new Phrase("*Transaction fees and special service fees may also apply.")); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); //pdfDoc.Add(pdftblAllData); }else{ var biznt = bizpacknameneshat.Text; var v4 = cardintwo.Text; Phrase phBecauseText = new Phrase(); phBecauseText.Add(new Chunk("Because the following have not been selected, BizPack has not been unlocked:", FontType)); Phrase phBecauseText2 = new Phrase(); phBecauseText2.Add(new Chunk(Environment.NewLine + "BizPack", FontTypeBold)); phBecauseText2.Add(new Chunk(Environment.NewLine + "Pay only $" + amt + " per month in account keeping fees* for the BizPack Essentials.", FontType)); phBecauseText2.Add(new Chunk(Environment.NewLine + "BizPack-ed full of savings:", FontType)); list1 = new iTextSharp.text.List(false, 8); list1.ListSymbol = bullet; if(biznt.Contains("Freedom Business Account")){ list1.Add(new iTextSharp.text.ListItem(new Chunk("Freedom Business Account", FontType))); } if(biznt.Contains("Business Access Saver")){ list1.Add(new iTextSharp.text.ListItem(new Chunk("Business Access Saver", FontType))); } if(biznt.Contains("Business Banking Online")){ list1.Add(new iTextSharp.text.ListItem(new Chunk("Business Banking Online", FontType))); } list = new iTextSharp.text.List(false, 8); list.ListSymbol = bullet; ////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType))); list.Add(new iTextSharp.text.ListItem(new Chunk("Business Banking Online monthly access fee (currently $30 a month) waived, saving $360 annually", FontType))); //new product if (v4.Contains("Vantage")){ list.Add(new iTextSharp.text.ListItem(new Chunk("BusinessVantage Visa Credit Card annual fee (currently $55 per card) waived for up to 3 cards, saving up to $165 annually", FontType))); }else{ list.Add(new iTextSharp.text.ListItem(new Chunk("Business Credit Card annual fee waived for up to 3 cards, saving up to $165 annually", FontType))); } //end new product list.Add(new iTextSharp.text.ListItem(new Chunk("Establishment fee for each new EFTPOS and merchant terminal waived, current saving of $77 per terminal", FontType))); PdfPCell objCell = new PdfPCell(); objCell.AddElement(phBecauseText); objCell.AddElement(list1); objCell.AddElement(phBecauseText2); objCell.AddElement(list); var phBecauseText1 = new Phrase(); phBecauseText1.Add(new Chunk(Environment.NewLine + "*Transaction fees and special service fees may also apply.", FontType)); objCell.AddElement(phBecauseText1); objCell.AddElement(new Phrase(" ")); objCell.Colspan = 3; pdftblAllData.AddCell(objCell); } pdfDoc.Add(pdftblAllData); #endregion CodeForTopFiveProduct #region TermAndCondition // pdfDoc.NewPage(); FontTypeBold = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.BOLD); FontType = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.NORMAL); var phraseTermAndCondition = new Phrase(); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "Things you should know", FontTypeBold)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "Information is current as at 13 November 2014. This offer may be withdrawn at any time, visit stgeorge.com.au and mybusinessconnect.com.au for up-to-date information.", FontType)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "No personal information is stored by using this tool. This tool does not take into account your objectives, financial situation or needs. Before making any decision, consider its appropriateness having regard to your objectives, financial situation and needs. Before you acquire a product, read the Product Disclosure Statement or other disclosure document available at stgeorge.com.au and mybusinessconnect.com.au and consider whether the product is appropriate for you. Credit criteria apply to all credit, lending, merchant and bank guarantee products and services selected. Terms and Conditions, fees and charges apply.", FontType)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "1. Electronic transactions are phone and internet banking deposits, withdrawals and transfers, direct debits and credits, St.George/BankSA/Bank of Melbourne/ Westpac ATM withdrawals in Australia, St.George/BankSA/Bank of Melbourne ATM deposits and mini transaction history and EFTPOS withdrawals and Business Visa Debit Card transactions. Daily limits apply.", FontType)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "2. The account keeping fee for the Transaction Account selected in BizPack is payable monthly. The monthly online access fee, annual card fee (for up to 3 cards) and facility establishment fee applicable to the other eligible products in BizPack are waived for as long as customer holds a Transaction Account, Savings Account, and online banking facility in the same name. Internet Banking may replace Business Banking Online as the online banking facility held in BizPack. Transaction fees may also apply if you exceed the monthly fee-free transaction allowance on eligible products in the BizPack Essentials. Other transactions and special service fees may also apply.", FontType)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "3. Equipment Finance by St.George Finance Limited ABN 99 001 094 471 Australian credit licence 387944.", FontType)); //phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "3. Customers can access the online legal and accountancy services by sending an email to Legal Access Services. These services are not provided by St.George and St.George accepts no responsibility for any advice provided by the third party. Advice is available by email only. All products and services in this tool (other than equipment finance and automotive finance) are issued by St.George Bank – A Division of Westpac Banking Corporation ABN 33 007 457 141 AFSL and Australian credit licence 233714. ", FontType)); phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "4. MyBusinessConnect Planning and Setup, Manage Finances, Grow Online and Business Protection packages are managed by Business Centric Services Group (BCSG) Australia Pty Ltd ACN 160 840 899. MyBusinessConnect subscription fees are payable monthly in advance directly to BCSG. The amount payable will depend on the choice of products that you select from within MyBusinessConnect. The payment due may increase if any additional products are ordered at a later date. You may terminate your subscription to MyBusinessConnect at any time by providing at least 30 days prior notice of termination.", FontType)); // phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "Automotive Finance by St.George Finance Limited ABN 99 001 094 471.", FontType)); // phraseTermAndCondition.Add(new Chunk(" Australian credit licence 387944 and St.George Motor Finance Limited ABN 53 007 656 555 Australian credit licence 387946.", FontType)); // phraseTermAndCondition.Add(new Chunk(Environment.NewLine + "St.George Bank – A Division of Westpac Banking Corporation. ABN 33 007 457 141 AFSL and Australian credit licence 233714", FontType)); pdfDoc.Add(phraseTermAndCondition); #endregion TermAndCondition //Image and Text for Call //PdfPTable pdfTable = new PdfPTable(2); //pdfTable.HorizontalAlignment = Element.ALIGN_LEFT; //pdfTable.DefaultCell.Border = Rectangle.NO_BORDER; //pdfTable.SplitRows = false; //iTextSharp.text.Image image1 = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath("~/george.JPG"))); //image1.ScaleToFit(750f, 750f); //Chunk imageChunk1 = new Chunk(image1, 0, -30); //phrase = new Phrase(new Chunk(image1, 0, -30)); //PdfPCell imageCell = new PdfPCell(phrase); //imageCell.Border = 0; //imageCell.HorizontalAlignment = Element.ALIGN_LEFT; ; //PdfPCell fcell1 = new PdfPCell(new Phrase((": Call 13000"), FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.NORMAL))); //fcell1.Border = 0; //fcell1.HorizontalAlignment = Element.ALIGN_LEFT; //pdfTable.AddCell(imageCell); //pdfTable.AddCell(fcell1); //pdfTable.SetWidthPercentage(new float[2] { 20f, 10f }, PageSize.LETTER); //pdfTable.HorizontalAlignment = Element.ALIGN_LEFT; //pdfDoc.Add(pdfTable); //Header Part //iTextSharp.text.Image logoHeader = iTextSharp.text.Image.GetInstance(Server.MapPath("~/PDF.jpg")); //logoHeader.ScaleAbsolute(500, 300); //pdfDoc.Add(logoHeader); //PdfPCell cell = new PdfPCell(phrase); //tblFirstData.AddCell(cell); //pdfDoc.Add(tblFirstData); //AddDataInPDFTable objAddDataInPDFTable = new AddDataInPDFTable(); //objAddDataInPDFTable.AddTableInDoc(pdfDoc); htmlparser.Parse(sr); writer.CloseStream = false; //set the closestream property pdfDoc.Close(); //close the document without closing the underlying stream memoryStream.Position = 0; MailAddress to = new MailAddress (txtemail.Text); MailAddress from = new MailAddress (ConfigurationManager.AppSettings ["smtpUser"]); System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(from, to); // mail.Attachments.Add(new Attachment(memoryStream, to + DateTime.Now.ToString("MMM-dd HH:mm") + ".pdf")); mail.Attachments.Add(new Attachment(memoryStream, "results.pdf")); mail.IsBodyHtml = true; mail.Subject = "St.George Business Account Selector results"; // mail.Body = "Here are your Business Account Selector results. " + "<a href='" + txturl.Text + "'>Please click here to see your result on Stgeorge Website</a>"; mail.Body = "<div style='width:50%;margin:auto;border:20px solid #f8f6e9;'><div style='width:100%;top:0px;height: 66px;background: #f8f6e9;margin-bottom: 0.12px;'></div><div style='border-top:0px;padding:20px;padding-top:40px;border-bottom:0px;padding-bottom:0px;'><p style='font-weight:bold;'>Hello " + txtName.Text + " </p><p>Thank you for completing the Business Account Selector tool. You'll find your results attached to this email.</p><p>We understand that no two businesses are the same and we want to help you make the right decisions for your business to be successful. </p><p>Like every great relationship, it starts with a conversation. So if you have any questions or want to take the next steps, drop into your local St.George branch or call us on 133 800.</p><p>Thanks,<br />St.George</p></div></div>"; SmtpClient client = new SmtpClient(); var smtpSection = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp"); client.Credentials = new System.Net.NetworkCredential(smtpSection.Network.UserName, smtpSection.Network.Password); client.Port = smtpSection.Network.Port; client.Host = smtpSection.Network.Host; //if (mainFunctions.Production() == true) //{ //client.EnableSsl = true; //} client.EnableSsl = true; try { client.Send(mail); lblFirst.Text="Mail sent.."; txtName.Text=""; txtemail.Text=""; } catch (Exception ex) { lblFirst.Text="Error : Server down"; txtName.Text=""; txtemail.Text=""; log.Fatal("Error in Submitbtn_Click() function." + ex.Message, ex); } }
// --------------------------------------------------------------------------- /** * Creates a PDF with information about the movies * @param filename the name of the PDF file that will be created. */ public byte[] CreatePdf(int compression) { using (MemoryStream ms = new MemoryStream()) { // step 1 using (Document document = new Document()) { // step 2 PdfWriter writer = PdfWriter.GetInstance(document, ms); switch(compression) { case -1: Document.Compress = false; break; case 0: writer.CompressionLevel = 0; break; case 2: writer.CompressionLevel = 9; break; case 3: writer.SetFullCompression(); break; } // step 3 document.Open(); // step 4 // Create database connection and statement var SQL = @"SELECT DISTINCT mc.country_id, c.country, count(*) AS c FROM film_country c, film_movie_country mc WHERE c.id = mc.country_id GROUP BY mc.country_id, country ORDER BY c DESC"; // Create a new list List list = new List(List.ORDERED); DbProviderFactory dbp = AdoDB.Provider; using (var c = dbp.CreateConnection()) { c.ConnectionString = AdoDB.CS; using (DbCommand cmd = c.CreateCommand()) { cmd.CommandText = SQL; c.Open(); using (var r = cmd.ExecuteReader()) { while (r.Read()) { // create a list item for the country ListItem item = new ListItem( String.Format("{0}: {1} movies", r["country"], r["c"]), FilmFonts.BOLDITALIC ); // create a movie list for each country List movielist = new List(List.ORDERED, List.ALPHABETICAL); movielist.Lowercase = List.LOWERCASE; foreach (Movie movie in PojoFactory.GetMovies(r["country_id"].ToString())) { ListItem movieitem = new ListItem(movie.MovieTitle); List directorlist = new List(List.UNORDERED); foreach (Director director in movie.Directors) { directorlist.Add(String.Format( "{0}, {1}", director.Name, director.GivenName )); } movieitem.Add(directorlist); movielist.Add(movieitem); } item.Add(movielist); list.Add(item); } } } } document.Add(list); } Document.Compress = true; return ms.ToArray(); } }
protected void lbPrint_Click(object sender, EventArgs e) { //Fonts String font = GetAttributeValue("ReportFont"); var titleFont = FontFactory.GetFont(font, 16, Font.BOLD); var listHeaderFont = FontFactory.GetFont(font, 12, Font.BOLD, Color.DARK_GRAY); var listSubHeaderFont = FontFactory.GetFont(font, 10, Font.BOLD, Color.DARK_GRAY); var listItemFontNormal = FontFactory.GetFont(font, 8, Font.NORMAL); var listItemFontUnapproved = FontFactory.GetFont(font, 8, Font.ITALIC, Color.MAGENTA); var noteFont = FontFactory.GetFont(font, 8, Font.NORMAL, Color.GRAY); List <ReservationService.ReservationSummary> reservationSummaryList = GetReservationSummaries(); // Bind to Grid var reservationSummaries = reservationSummaryList.Select(r => new { Id = r.Id, ReservationName = r.ReservationName, ApprovalState = r.ApprovalState.ConvertToString(), Locations = r.ReservationLocations.ToList(), Resources = r.ReservationResources.ToList(), CalendarDate = r.EventStartDateTime.ToLongDateString(), EventStartDateTime = r.EventStartDateTime, EventEndDateTime = r.EventEndDateTime, ReservationStartDateTime = r.ReservationStartDateTime, ReservationEndDateTime = r.ReservationEndDateTime, EventDateTimeDescription = r.EventTimeDescription, ReservationDateTimeDescription = r.ReservationTimeDescription, SetupPhotoId = r.SetupPhotoId, Note = r.Note }) .OrderBy(r => r.EventStartDateTime) .GroupBy(r => r.EventStartDateTime.Date) .Select(r => r.ToList()) .ToList(); //Setup the document var document = new Document(PageSize.A4, 25, 50, 0, 0); { document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());; } var output = new MemoryStream(); var writer = PdfWriter.GetInstance(document, output); document.Open(); // Add logo try { string logoUri = GetAttributeValue("ReportLogo"); string fileUrl = string.Empty; iTextSharp.text.Image logo; if (logoUri.ToLower().StartsWith("http")) { logo = iTextSharp.text.Image.GetInstance(new Uri(logoUri)); } else { fileUrl = Server.MapPath(ResolveRockUrl(logoUri)); logo = iTextSharp.text.Image.GetInstance(fileUrl); } logo.Alignment = iTextSharp.text.Image.RIGHT_ALIGN; logo.ScaleToFit(100, 55); document.Add(logo); } catch { } // Write the document var today = RockDateTime.Today; var filterStartDateTime = FilterStartDate.HasValue ? FilterStartDate.Value : today; var filterEndDateTime = FilterEndDate.HasValue ? FilterEndDate.Value : today.AddMonths(1); String title = String.Format("Reservations for: {0} - {1}", filterStartDateTime.ToString("MMMM d"), filterEndDateTime.ToString("MMMM d")); document.Add(new Paragraph(title, titleFont)); var fontAwesomeUrl = Server.MapPath(ResolveRockUrl(GetAttributeValue("FontAwesomeTtf"))); var fontAwesome = BaseFont.CreateFont(fontAwesomeUrl, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font fontAwe = new Font(fontAwesome, 8); // Populate the Lists foreach (var reservationDay in reservationSummaries) { var firstReservation = reservationDay.FirstOrDefault(); if (firstReservation != null) { //Build Header document.Add(Chunk.NEWLINE); String listHeader = firstReservation.CalendarDate; document.Add(new Paragraph(listHeader, listHeaderFont)); //Build Subheaders var listSubHeaderTable = new PdfPTable(7); listSubHeaderTable.LockedWidth = true; listSubHeaderTable.TotalWidth = PageSize.A4.Width - document.LeftMargin - document.RightMargin; listSubHeaderTable.HorizontalAlignment = 0; listSubHeaderTable.SpacingBefore = 10; listSubHeaderTable.SpacingAfter = 0; listSubHeaderTable.DefaultCell.BorderWidth = 0; listSubHeaderTable.DefaultCell.BorderWidthBottom = 1; listSubHeaderTable.DefaultCell.BorderColorBottom = Color.DARK_GRAY; listSubHeaderTable.AddCell(new Phrase("Name", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Event Time", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Reservation Time", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Locations", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Resources", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Has Layout?", listSubHeaderFont)); listSubHeaderTable.AddCell(new Phrase("Status", listSubHeaderFont)); document.Add(listSubHeaderTable); foreach (var reservationSummary in reservationDay) { //Build the list item table var listItemTable = new PdfPTable(7); listItemTable.LockedWidth = true; listItemTable.TotalWidth = PageSize.A4.Width - document.LeftMargin - document.RightMargin; listItemTable.HorizontalAlignment = 0; listItemTable.SpacingBefore = 0; listItemTable.SpacingAfter = 1; listItemTable.DefaultCell.BorderWidth = 0; //Add the list items listItemTable.AddCell(new Phrase(reservationSummary.ReservationName, listItemFontNormal)); listItemTable.AddCell(new Phrase(reservationSummary.EventDateTimeDescription, listItemFontNormal)); listItemTable.AddCell(new Phrase(reservationSummary.ReservationDateTimeDescription, listItemFontNormal)); List locationList = new List(List.UNORDERED, 8f); locationList.SetListSymbol("\u2022"); foreach (var reservationLocation in reservationSummary.Locations) { var listItem = new iTextSharp.text.ListItem(reservationLocation.Location.Name, listItemFontNormal); if (reservationLocation.ApprovalState == ReservationLocationApprovalState.Approved) { listItem.Add(new Phrase("\uf00c", fontAwe)); } locationList.Add(listItem); } PdfPCell locationCell = new PdfPCell(); locationCell.Border = 0; locationCell.PaddingTop = -2; locationCell.AddElement(locationList); listItemTable.AddCell(locationCell); List resourceList = new List(List.UNORDERED, 8f); resourceList.SetListSymbol("\u2022"); foreach (var reservationResource in reservationSummary.Resources) { var listItem = new iTextSharp.text.ListItem(String.Format("{0}({1})", reservationResource.Resource.Name, reservationResource.Quantity), listItemFontNormal); if (reservationResource.ApprovalState == ReservationResourceApprovalState.Approved) { listItem.Add(new Phrase("\uf00c", fontAwe)); } resourceList.Add(listItem); } PdfPCell resourceCell = new PdfPCell(); resourceCell.Border = 0; resourceCell.PaddingTop = -2; resourceCell.AddElement(resourceList); listItemTable.AddCell(resourceCell); listItemTable.AddCell(new Phrase(reservationSummary.SetupPhotoId.HasValue.ToYesNo(), listItemFontNormal)); var listItemFont = (reservationSummary.ApprovalState == "Unapproved") ? listItemFontUnapproved : listItemFontNormal; listItemTable.AddCell(new Phrase(reservationSummary.ApprovalState, listItemFont)); document.Add(listItemTable); if (!string.IsNullOrWhiteSpace(reservationSummary.Note)) { //document.Add( Chunk.NEWLINE ); var listNoteTable = new PdfPTable(1); listNoteTable.LockedWidth = true; listNoteTable.TotalWidth = PageSize.A4.Width - document.LeftMargin - document.RightMargin - 50; listNoteTable.HorizontalAlignment = 1; listNoteTable.SpacingBefore = 0; listNoteTable.SpacingAfter = 1; listNoteTable.DefaultCell.BorderWidth = 0; listNoteTable.AddCell(new Phrase(reservationSummary.Note, noteFont)); document.Add(listNoteTable); } } } } document.Close(); Response.ClearHeaders(); Response.ClearContent(); Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", string.Format("attachment;filename=Reservation Schedule for {0} - {1}.pdf", filterStartDateTime.ToString("MMMM d"), filterEndDateTime.ToString("MMMM d"))); Response.BinaryWrite(output.ToArray()); Response.Flush(); Response.End(); return; }
// --------------------------------------------------------------------------- public void Write(Stream stream) { // step 1 using (Document document = new Document()) { // step 2 PdfWriter.GetInstance(document, stream); // step 3 document.Open(); // step 4 Director director; using (var c = AdoDB.Provider.CreateConnection()) { c.ConnectionString = AdoDB.CS; using (DbCommand cmd = c.CreateCommand()) { cmd.CommandText = SQL; c.Open(); using (var r = cmd.ExecuteReader()) { while (r.Read()) { // create a paragraph for the director director = PojoFactory.GetDirector(r); Paragraph p = new Paragraph( PojoToElementFactory.GetDirectorPhrase(director)); // add a dotted line separator p.Add(new Chunk(new DottedLineSeparator())); // adds the number of movies of this director p.Add(string.Format("movies: {0}", Convert.ToInt32(r["c"]))); document.Add(p); // Creates a list List list = new List(List.ORDERED); list.IndentationLeft = 36; list.IndentationRight = 36; // Gets the movies of the current director var director_id = Convert.ToInt32(r["id"]); ListItem movieitem; // LINQ allows us to on sort any movie object property inline; // let's sort by Movie.Year, Movie.Title var by_year = from m in PojoFactory.GetMovies(director_id) orderby m.Year, m.Title select m; // loops over the movies foreach (Movie movie in by_year) { // creates a list item with a movie title movieitem = new ListItem(movie.MovieTitle); // adds a vertical position mark as a separator movieitem.Add(new Chunk(new VerticalPositionMark())); var yr = movie.Year; // adds the year the movie was produced movieitem.Add(new Chunk(yr.ToString())); // add an arrow to the right if the movie dates from 2000 or later if (yr > 1999) { movieitem.Add(PositionedArrow.RIGHT); } // add the list item to the list list.Add(movieitem); } // add the list to the document document.Add(list); } } } } } }