protected void btnPdfExport_Click(object sender, EventArgs e)
    {
        try
        {
            string Heading = "", filename = "";


            dTable   = dtPdetails;
            Heading  = "PROJECT DETAILS REPORT GENERATED ON";
            filename = "Project_Details_Report_";

            Response.ContentType = "application/pdf";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            MemoryStream memoryStream = new MemoryStream();

            //creating pdf document
            iTextSharp.text.Document pdfDoc = new Document(PageSize.A4.Rotate(), 5f, 5f, 10f, 5f);
            // getting writer for pdf
            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

            PdfWriter.GetInstance(pdfDoc, memoryStream);

            Paragraph para  = new Paragraph();
            Paragraph para1 = new Paragraph();
            Paragraph para2 = new Paragraph();
            para.Alignment = 1;
            para.Font      = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 30f, BaseColor.BLACK);

            para.SpacingBefore = 50;
            para.SpacingAfter  = 50;
            para.Add("Project Management System");



            PdfPTable table = new PdfPTable(dTable.Columns.Count);  // -2 new
            //spacing before and after table
            table.TotalWidth          = 823f;
            table.LockedWidth         = true;
            table.SpacingBefore       = 5f;
            table.SpacingAfter        = 5f;
            table.HorizontalAlignment = 0;


            PdfPCell cell         = new PdfPCell(new Phrase());
            int      columnscount = dTable.Columns.Count;

            string login_ini_path = HttpRuntime.AppDomainAppPath + "Configuration\\machines_type.ini";

            string bank = null;

            string header1 = null;
            string header2 = null;

            header1 = Heading + " " + DateTime.Now.ToString("dd MMM yyyy, HH:mm tt");
            header2 = "REPORT";
            Response.AddHeader("content-disposition", "attachment;filename=" + filename + "" + DateTime.Now.ToString("dd-MM-yy_HH:mm") + ".pdf");

            table.AddCell(GetCell(header1, columnscount, 1));
            table.AddCell(GetCell(header2, columnscount, 2));


            for (int j = 1; j <= columnscount; j++)
            {
                table.AddCell(GetCell(dTable.Columns[j - 1].ColumnName.ToString(), 3));  //
            }


            foreach (DataRow row in dTable.Rows)
            {
                for (int i = 0; i < dTable.Columns.Count; i++)
                {
                    table.AddCell(GetCell(row[i].ToString(), 4));
                }
            }
            string imageLogo           = Server.MapPath(".") + "\\images\\logo1.png";
            iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(imageLogo);
            logo.SetAbsolutePosition(pdfDoc.Left, pdfDoc.Top - 40);
            logo.ScaleToFit(45f, 45f);
            logo.SpacingBefore = 10f;
            logo.SpacingAfter  = 1f;
            logo.Alignment     = Element.ALIGN_TOP;

            pdfDoc.Open();
            pdfDoc.Add(para);

            pdfDoc.Add(logo);
            pdfDoc.Add(table);


            pdfDoc.Close();
            byte[] bytes = memoryStream.ToArray();
            memoryStream.Close();
        }
        catch (Exception ex)
        {
            ex.ToString();
        }
    }
    private PdfPCell GetCell(string text, int colSpan, int i)
    {
        var whitefont = FontFactory.GetFont(FontFactory.TIMES_BOLD, 14, BaseColor.BLACK); //"Times New Roman"
        var blackfont = FontFactory.GetFont(FontFactory.TIMES_BOLD, 14, BaseColor.BLACK); //"Times New Roman"

        if (i < 3)
        {
            PdfPCell cell = new PdfPCell(new Phrase(text, whitefont));
            cell.HorizontalAlignment = 1;
            //cell.Rowspan = rowSpan;
            cell.Colspan = colSpan;
            //Header colour
            if (i == 1 || i == 2)
            {
                cell.BackgroundColor = BaseColor.LIGHT_GRAY;
            }
            //column name colour
            if (i == 3)
            {
                cell.BackgroundColor = BaseColor.CYAN;
            }
            return(cell);
        }
        else if (i == 3)
        {
            PdfPCell cell = new PdfPCell(new Phrase(text, blackfont));
            cell.HorizontalAlignment = 1;
            //cell.Rowspan = rowSpan;
            cell.Colspan = colSpan;
            //Header colour
            if (i == 1 || i == 2)
            {
                cell.BackgroundColor = BaseColor.BLUE;
            }
            //column name colour
            if (i == 3)
            {
                cell.BackgroundColor = BaseColor.CYAN;
            }
            return(cell);
        }
        else
        {
            PdfPCell cell = new PdfPCell(new Phrase(text));
            cell.HorizontalAlignment = 1;
            //cell.Rowspan = rowSpan;
            cell.Colspan = colSpan;
            //Header colour
            if (i == 1 || i == 2)
            {
                cell.BackgroundColor = BaseColor.BLUE;
            }
            //column name colour
            if (i == 3)
            {
                cell.BackgroundColor = BaseColor.CYAN;
            }
            string value = text.ToLower();
            if (value == "disconnected" || value.ToLower().Contains("jam") || value.ToLower().Contains("out") || value.ToLower().Contains("printererror") || value == "faulty")
            {
                cell.BackgroundColor = BaseColor.RED;
            }

            if (value.ToLower().Contains("low"))
            {
                cell.BackgroundColor = BaseColor.YELLOW;
            }
            return(cell);
        }
    }
        public void GenerateReport(string path)
        {
            Directory.CreateDirectory(path);

            var filePath = path + "/PlayerStats-Report.pdf";

            using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                Document doc = new Document();

                PdfWriter writer = PdfWriter.GetInstance(doc, stream);
                doc.Open();

                var      columns    = 4;
                var      titleFont  = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16);
                var      normalFont = FontFactory.GetFont(FontFactory.HELVETICA, 12);
                var      boldFont   = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12);
                var      table      = new PdfPTable(columns);
                PdfPCell cell       = new PdfPCell(new Phrase("Player report", titleFont));
                cell.Colspan             = 4;
                cell.HorizontalAlignment = 1;
                table.AddCell(cell);

                var tableHeaders = new List <string>()
                {
                    "Minutes", "SimplePossFor", "SimplePointsFor", "SimpleORebFor"
                };
                for (int i = 0; i < columns; i++)
                {
                    var headerCell = new PdfPCell(new Phrase(tableHeaders[i], boldFont));
                    headerCell.HorizontalAlignment = 1;
                    table.AddCell(headerCell);
                }

                i = 0;
                foreach (var pls in this.dbContext.PlayerStatistics)
                {
                    var minutes         = new PdfPCell();
                    var simpleposfor    = new PdfPCell();
                    var simplepointsfor = new PdfPCell();
                    var simpleorebfor   = new PdfPCell();

                    var min = pls.Minutes;
                    minutes.AddElement(new Phrase(min.ToString()));
                    var sposf = pls.SimplePossFor;
                    simpleposfor.AddElement(new Phrase(sposf.ToString()));
                    var spointsf = pls.SimplePointsFor;
                    simplepointsfor.AddElement(new Phrase(spointsf.ToString()));
                    var srebf = pls.SimpleORebFor;
                    simpleorebfor.AddElement(new Phrase(srebf.ToString()));

                    table.AddCell(minutes);
                    table.AddCell(simpleposfor);
                    table.AddCell(simplepointsfor);
                    table.AddCell(simpleorebfor);

                    i++;
                    if (i == 30)
                    {
                        break;
                    }
                }

                doc.Add(table);
                doc.Close();
            }
        }
        public ActionResult PurchaseOrder(Int32 POId)
        {
            // ==============================
            // PDF Settings and Customization
            // ==============================
            MemoryStream workStream = new MemoryStream();
            Rectangle    rectangle  = new Rectangle(PageSize.A3);
            Document     document   = new Document(rectangle, 72, 72, 72, 72);

            document.SetMargins(30f, 30f, 30f, 30f);
            PdfWriter.GetInstance(document, workStream).CloseStream = false;

            document.Open();

            // =====
            // Fonts
            // =====
            Font fontArial17Bold = FontFactory.GetFont("Arial", 17, Font.BOLD);
            Font fontArial11     = FontFactory.GetFont("Arial", 11);
            Font fontArial9Bold  = FontFactory.GetFont("Arial", 9, Font.BOLD);
            Font fontArial9      = FontFactory.GetFont("Arial", 9);
            Font fontArial10Bold = FontFactory.GetFont("Arial", 10, Font.BOLD);
            Font fontArial10     = FontFactory.GetFont("Arial", 10);
            Font fontArial11Bold = FontFactory.GetFont("Arial", 11, Font.BOLD);
            Font fontArial12Bold = FontFactory.GetFont("Arial", 12, Font.BOLD);
            Font fontArial13Bold = FontFactory.GetFont("Arial", 13, Font.BOLD);

            Paragraph line = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 4.5F)));

            var identityUserId   = User.Identity.GetUserId();
            var currentUser      = from d in db.MstUsers where d.UserId == identityUserId select d;
            var currentCompanyId = currentUser.FirstOrDefault().CompanyId;
            var currentBranchId  = currentUser.FirstOrDefault().BranchId;

            // ==============
            // Company Detail
            // ==============
            var companyName = (from d in db.MstCompanies where d.Id == Convert.ToInt32(currentCompanyId) select d.Company).FirstOrDefault();
            var address     = (from d in db.MstCompanies where d.Id == Convert.ToInt32(currentCompanyId) select d.Address).FirstOrDefault();
            var contactNo   = (from d in db.MstCompanies where d.Id == Convert.ToInt32(currentCompanyId) select d.ContactNumber).FirstOrDefault();
            var branch      = (from d in db.MstBranches where d.Id == Convert.ToInt32(currentBranchId) select d.Branch).FirstOrDefault();

            // ===========
            // Header Page
            // ===========
            PdfPTable headerPage = new PdfPTable(2);

            float[] widthsCellsHeaderPage = new float[] { 100f, 75f };
            headerPage.SetWidths(widthsCellsHeaderPage);
            headerPage.WidthPercentage = 100;
            headerPage.AddCell(new PdfPCell(new Phrase(companyName, fontArial17Bold))
            {
                Border = 0
            });
            headerPage.AddCell(new PdfPCell(new Phrase("Purchase Order", fontArial17Bold))
            {
                Border = 0, HorizontalAlignment = 2
            });
            headerPage.AddCell(new PdfPCell(new Phrase(address, fontArial11))
            {
                Border = 0, PaddingTop = 5f
            });
            headerPage.AddCell(new PdfPCell(new Phrase(branch, fontArial11))
            {
                Border = 0, PaddingTop = 5f, HorizontalAlignment = 2
            });
            headerPage.AddCell(new PdfPCell(new Phrase(contactNo, fontArial11))
            {
                Border = 0, PaddingTop = 5f
            });
            headerPage.AddCell(new PdfPCell(new Phrase("Printed " + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToString("hh:mm:ss tt"), fontArial11))
            {
                Border = 0, PaddingTop = 5f, HorizontalAlignment = 2
            });
            document.Add(headerPage);

            // =====
            // Space
            // =====
            PdfPTable spaceTable = new PdfPTable(1);

            float[] widthCellsSpaceTable = new float[] { 100f };
            spaceTable.SetWidths(widthCellsSpaceTable);
            spaceTable.WidthPercentage = 100;
            spaceTable.AddCell(new PdfPCell(new Phrase(" ", fontArial10Bold))
            {
                Border = 0, PaddingTop = 5f
            });

            document.Add(line);

            // ===================
            // Get Purchase Orders
            // ===================
            var purchaseOrders = from d in db.TrnPurchaseOrders
                                 where d.Id == Convert.ToInt32(POId) &&
                                 d.IsLocked == true
                                 select d;

            if (purchaseOrders.Any())
            {
                String supplier    = purchaseOrders.FirstOrDefault().MstArticle.Article;
                String PONumber    = purchaseOrders.FirstOrDefault().PONumber;
                String term        = purchaseOrders.FirstOrDefault().MstTerm.Term;
                String PODate      = purchaseOrders.FirstOrDefault().PODate.ToString("MM-dd-yyyy", CultureInfo.InvariantCulture);
                String dateNeeded  = purchaseOrders.FirstOrDefault().DateNeeded.ToString("MM-dd-yyyy", CultureInfo.InvariantCulture);
                String requestNo   = purchaseOrders.FirstOrDefault().ManualRequestNumber;
                String remarks     = purchaseOrders.FirstOrDefault().Remarks;
                String preparedBy  = purchaseOrders.FirstOrDefault().MstUser3.FullName;
                String checkedBy   = purchaseOrders.FirstOrDefault().MstUser1.FullName;
                String approvedBy  = purchaseOrders.FirstOrDefault().MstUser.FullName;
                String requestedBy = purchaseOrders.FirstOrDefault().MstUser4.FullName;

                PdfPTable tablePurchaseOrder            = new PdfPTable(4);
                float[]   widthscellsTablePurchaseOrder = new float[] { 40f, 150f, 70f, 50f };
                tablePurchaseOrder.SetWidths(widthscellsTablePurchaseOrder);
                tablePurchaseOrder.WidthPercentage = 100;

                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase("Supplier", fontArial11Bold))
                {
                    Border = 0, PaddingTop = 10f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase(supplier, fontArial11))
                {
                    Border = 0, PaddingTop = 10f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase("No.", fontArial11Bold))
                {
                    Border = 0, PaddingTop = 10f, PaddingLeft = 5f, PaddingRight = 5f, HorizontalAlignment = 2
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase(PONumber, fontArial11))
                {
                    Border = 0, PaddingTop = 10f, PaddingLeft = 5f, PaddingRight = 5f, HorizontalAlignment = 2
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase("Term", fontArial11Bold))
                {
                    Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase(term, fontArial11))
                {
                    Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase("Date", fontArial11Bold))
                {
                    Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f, HorizontalAlignment = 2
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase(PODate, fontArial11))
                {
                    Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f, HorizontalAlignment = 2
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase("Date Needed", fontArial11Bold))
                {
                    Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase(dateNeeded, fontArial11))
                {
                    Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase("Request No.", fontArial11Bold))
                {
                    Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f, HorizontalAlignment = 2
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase(requestNo, fontArial11))
                {
                    Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f, HorizontalAlignment = 2
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase("Remarks ", fontArial11Bold))
                {
                    Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase(remarks, fontArial11))
                {
                    Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tablePurchaseOrder.AddCell(new PdfPCell(new Phrase(" ", fontArial11))
                {
                    Colspan = 2, Border = 0, PaddingTop = 5f, PaddingLeft = 5f, PaddingRight = 5f
                });
                document.Add(tablePurchaseOrder);

                document.Add(spaceTable);

                // ========================
                // Get Purchase Order Items
                // ========================
                var purchaseOrderItems = from d in db.TrnPurchaseOrderItems
                                         where d.POId == POId &&
                                         d.TrnPurchaseOrder.IsLocked == true
                                         select new
                {
                    PO          = d.TrnPurchaseOrder.PONumber,
                    SKUCode     = d.MstArticle.ManualArticleOldCode,
                    Item        = d.MstArticle.Article,
                    Particulars = d.Particulars,
                    Unit        = d.MstUnit.Unit,
                    Quantity    = d.Quantity,
                    Cost        = d.Cost,
                    Amount      = d.Amount
                };

                if (purchaseOrderItems.Any())
                {
                    PdfPTable tablePurchaseOrderLines = new PdfPTable(7);
                    float[]   widthscellsPOLines      = new float[] { 50f, 100f, 70f, 200f, 150f, 100f, 100f };
                    tablePurchaseOrderLines.SetWidths(widthscellsPOLines);
                    tablePurchaseOrderLines.WidthPercentage = 100;
                    tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase("No.", fontArial11Bold))
                    {
                        HorizontalAlignment = 1, PaddingTop = 3f, PaddingBottom = 7f
                    });
                    tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase("Quantity", fontArial11Bold))
                    {
                        HorizontalAlignment = 1, PaddingTop = 3f, PaddingBottom = 7f
                    });
                    tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase("Unit", fontArial11Bold))
                    {
                        HorizontalAlignment = 1, PaddingTop = 3f, PaddingBottom = 7f
                    });
                    tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase("Item", fontArial11Bold))
                    {
                        HorizontalAlignment = 1, PaddingTop = 3f, PaddingBottom = 7f
                    });
                    tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase("Particulars", fontArial11Bold))
                    {
                        HorizontalAlignment = 1, PaddingTop = 3f, PaddingBottom = 7f
                    });
                    tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase("Price", fontArial11Bold))
                    {
                        HorizontalAlignment = 1, PaddingTop = 3f, PaddingBottom = 7f
                    });
                    tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase("Amount", fontArial11Bold))
                    {
                        HorizontalAlignment = 1, PaddingTop = 3f, PaddingBottom = 7f
                    });

                    Decimal totalAmount = 0;
                    Int32   count       = 0;

                    foreach (var purchaseOrderItem in purchaseOrderItems)
                    {
                        count       += 1;
                        totalAmount += purchaseOrderItem.Amount;

                        string SKUCode = purchaseOrderItem.SKUCode;
                        if (purchaseOrderItem.SKUCode.Equals("NA") || purchaseOrderItem.SKUCode.Equals("na"))
                        {
                            SKUCode = " ";
                        }

                        tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase(count.ToString("#,##0"), fontArial11))
                        {
                            HorizontalAlignment = 2, PaddingTop = 3f, PaddingBottom = 7f, PaddingLeft = 5f, PaddingRight = 5f
                        });
                        tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase(purchaseOrderItem.Quantity.ToString("#,##0.00"), fontArial11))
                        {
                            HorizontalAlignment = 2, PaddingTop = 3f, PaddingBottom = 7f, PaddingLeft = 5f, PaddingRight = 5f
                        });
                        tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase(purchaseOrderItem.Unit, fontArial11))
                        {
                            HorizontalAlignment = 0, PaddingTop = 3f, PaddingBottom = 7f, PaddingLeft = 5f, PaddingRight = 5f
                        });
                        tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase(purchaseOrderItem.Item + " " + SKUCode, fontArial11))
                        {
                            HorizontalAlignment = 0, PaddingTop = 3f, PaddingBottom = 7f, PaddingLeft = 5f, PaddingRight = 5f
                        });
                        tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase(purchaseOrderItem.Particulars, fontArial11))
                        {
                            HorizontalAlignment = 0, PaddingTop = 3f, PaddingBottom = 7f, PaddingLeft = 5f, PaddingRight = 5f
                        });
                        tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase(purchaseOrderItem.Cost.ToString("#,##0.00"), fontArial11))
                        {
                            HorizontalAlignment = 2, PaddingTop = 3f, PaddingBottom = 7f, PaddingLeft = 5f, PaddingRight = 5f
                        });
                        tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase(purchaseOrderItem.Amount.ToString("#,##0.00"), fontArial11))
                        {
                            HorizontalAlignment = 2, PaddingTop = 3f, PaddingBottom = 7f, PaddingLeft = 5f, PaddingRight = 5f
                        });
                    }

                    tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase("Total", fontArial11Bold))
                    {
                        Colspan = 6, HorizontalAlignment = 2, PaddingTop = 5f, PaddingBottom = 9f, PaddingLeft = 5f, PaddingRight = 5f
                    });
                    tablePurchaseOrderLines.AddCell(new PdfPCell(new Phrase(totalAmount.ToString("#,##0.00"), fontArial11Bold))
                    {
                        HorizontalAlignment = 2, PaddingTop = 5f, PaddingBottom = 9f, PaddingLeft = 5f, PaddingRight = 5f
                    });
                    document.Add(tablePurchaseOrderLines);

                    document.Add(spaceTable);
                }

                // ==============
                // User Signature
                // ==============
                PdfPTable tableUsers            = new PdfPTable(4);
                float[]   widthsCellsTableUsers = new float[] { 100f, 100f, 100f, 100f };
                tableUsers.WidthPercentage = 100;
                tableUsers.SetWidths(widthsCellsTableUsers);
                tableUsers.AddCell(new PdfPCell(new Phrase("Prepared by", fontArial11Bold))
                {
                    PaddingTop = 5f, PaddingBottom = 9f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase("Checked by", fontArial11Bold))
                {
                    PaddingTop = 5f, PaddingBottom = 9f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase("Approved by", fontArial11Bold))
                {
                    PaddingTop = 5f, PaddingBottom = 9f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase("Requested by", fontArial11Bold))
                {
                    PaddingTop = 5f, PaddingBottom = 9f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase(" "))
                {
                    PaddingBottom = 50f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase(" "))
                {
                    PaddingBottom = 50f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase(" "))
                {
                    PaddingBottom = 50f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase(" "))
                {
                    PaddingBottom = 50f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase(preparedBy, fontArial11))
                {
                    HorizontalAlignment = 1, PaddingTop = 5f, PaddingBottom = 9f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase(checkedBy, fontArial11))
                {
                    HorizontalAlignment = 1, PaddingTop = 5f, PaddingBottom = 9f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase(approvedBy, fontArial11))
                {
                    HorizontalAlignment = 1, PaddingTop = 5f, PaddingBottom = 9f, PaddingLeft = 5f, PaddingRight = 5f
                });
                tableUsers.AddCell(new PdfPCell(new Phrase(requestedBy, fontArial11))
                {
                    HorizontalAlignment = 1, PaddingTop = 5f, PaddingBottom = 9f, PaddingLeft = 5f, PaddingRight = 5f
                });
                document.Add(tableUsers);
            }

            document.Close();

            byte[] byteInfo = workStream.ToArray();
            workStream.Write(byteInfo, 0, byteInfo.Length);
            workStream.Position = 0;

            return(new FileStreamResult(workStream, "application/pdf"));
        }
Example #5
0
 private void ReportHeader(Verhuren verhuur)
 {
     _fontstyle                   = FontFactory.GetFont("Tahoma", 11f, 1);
     _pdfCell                     = new PdfPCell(new Phrase("Aan:", _fontstyle));
     _pdfCell.Colspan             = 3;
     _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfCell                     = new PdfPCell(new Phrase("Van:", _fontstyle));
     _pdfCell.Colspan             = 1;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _fontstyle                   = FontFactory.GetFont("Tahoma", 11f, 0);
     _pdfCell                     = new PdfPCell(new Phrase(verhuur.Klanten.voornaam + " " + verhuur.Klanten.tussenvoegsel + " " + verhuur.Klanten.achternaam, _fontstyle));
     _pdfCell.Colspan             = 3;
     _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfCell                     = new PdfPCell(new Phrase("Autoverhuur Jansen", _fontstyle));
     _pdfCell.Colspan             = 1;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase(verhuur.Klanten.adres, _fontstyle));
     _pdfCell.Colspan             = 3;
     _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfCell                     = new PdfPCell(new Phrase("Patatlaan 21", _fontstyle));
     _pdfCell.Colspan             = 1;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase(verhuur.Klanten.postcode + " " + verhuur.Klanten.woonplaats, _fontstyle));
     _pdfCell.Colspan             = 3;
     _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfCell                     = new PdfPCell(new Phrase("2490BS Den Haag", _fontstyle));
     _pdfCell.Colspan             = 1;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("Tel. 021 1234567", _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("Web: www.lhhamming-001-site2.etempurl.com", _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("Mail: [email protected]", _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("\n", _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("\n", _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("\n", _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _fontstyle                   = FontFactory.GetFont("Tahoma", 11f, 1);
     _pdfCell                     = new PdfPCell(new Phrase("Factuurgegevens", _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _fontstyle                   = FontFactory.GetFont("Tahoma", 11f, 0);
     _pdfCell                     = new PdfPCell(new Phrase("Factuurnummer: " + verhuur.VerhuurId, _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("Begindatum verhuur: " + verhuur.beginDatum.ToString().Remove(verhuur.beginDatum.ToString().Length - 9), _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("Eindddatum verhuur: " + verhuur.eindDatum.ToString().Remove(verhuur.eindDatum.ToString().Length - 9), _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("\n"));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("\n"));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("\n", _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("\n", _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
     _pdfCell                     = new PdfPCell(new Phrase("\n", _fontstyle));
     _pdfCell.Colspan             = 4;
     _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
     _pdfCell.Border              = 0;
     _pdfCell.BackgroundColor     = BaseColor.WHITE;
     _pdfCell.ExtraParagraphSpace = 0;
     _pdfTable.AddCell(_pdfCell);
     _pdfTable.CompleteRow();
 }