コード例 #1
0
    private void CreatePDFFile()
    {
        // CREATE A DOCUMENT OBJECT
        var document = new Document(PageSize.A4, 10, 10, 10, 0);

        // CREATE A NEW PDFWRITE OBJECT, WRITING THE OUTPUT TO A MEMORYSTREAM
        var output = new MemoryStream();
        var writer = PdfWriter.GetInstance(document, output);

        // OPEN THE DOCUMENT FOR WRITING

        PDFHeaderFooter PageEventHandler = new PDFHeaderFooter();
        writer.PageEvent = PageEventHandler;

        document.Open();

        // FIRST, CREATE OUR FONTS... (FOR MORE ON WORKING W/FONTS IN ITEXTSHARP, see: http://www.mikesdotnetting.com/Article/81/iTextSharp-Working-with-Fonts
        var titleFont = FontFactory.GetFont("Arial", 18, Font.BOLD);
        titleFont.SetColor(201, 38, 0);

        var subTitleFont = FontFactory.GetFont("Arial", 12, Font.BOLD);
        subTitleFont.SetColor(1, 107, 165);

        var SubbodyFont = FontFactory.GetFont("Arial", 10, Font.NORMAL);
        var SubbodyFont1 = FontFactory.GetFont("Arial", 10, Font.BOLD);

        var boldTableFont = FontFactory.GetFont("Arial", 12, Font.BOLD);
        var endingMessageFont = FontFactory.GetFont("Arial", 10, Font.ITALIC);
        var bodyFont = FontFactory.GetFont("Arial", 12, Font.NORMAL);
        var anchorFont = FontFactory.GetFont("Arial", 10, Font.NORMAL);
        //---------------------------------------------------------------------
        strSql = @"SELECT INSTA_MST_SOLUTION.SOLUTION_ID,
                          INSTA_MST_SOLUTION.SOLUTION_NAME,
                          INSTA_MST_SIZE.SIZE_DESCRIPTION,
                          INSTA_MST_EXHIBIT_TYPE_DETAIL.EXHIBIT_DETAILS,
                          INSTA_PAR_MOD_PORT_TYPE.MOD_PORT_DESCRIPTION,
                          INSTA_MST_PRODUCT.PRODUCT_ID,
                          INSTA_MST_PRODUCT.PRODUCT_NAME,
                          INSTA_MST_PRODUCT.PRODUCT_DESCRIPTION,
                          INSTA_MST_CURRENCY.CURRENCY_DESCRIPTION,
                          INSTA_MST_CURRENCY.CURRENCY_SYMBOL,
                          INSTA_MST_DISCOUNT.DISCOUNT_RATE,
                          CAST(INSTA_MST_SOLUTION.PRICE AS VARCHAR(10)) AS PRICE,
                          INSTA_MST_SOLUTION.SHIPPING_DAYS,
                          INSTA_MST_SOLUTION.SHIPPING_DISPLAY_FLAG,
                          INSTA_MST_SOLUTION.SOLUTION_TEXT,
                          INSTA_MST_SOLUTION.PRODUCT_FEATURE_DISPLAY_FLAG
                   FROM INSTA_MST_SOLUTION
                   LEFT JOIN INSTA_MST_SIZE
                   ON INSTA_MST_SOLUTION.SIZE_ID = INSTA_MST_SIZE.SIZE_ID
                   LEFT JOIN INSTA_MST_EXHIBIT_TYPE_DETAIL
                   ON INSTA_MST_SOLUTION.EXHIBIT_DETAIL_ID = INSTA_MST_EXHIBIT_TYPE_DETAIL.EXHIBIT_DETAIL_ID
                   LEFT JOIN INSTA_PAR_MOD_PORT_TYPE
                   ON INSTA_MST_SOLUTION.MOD_PORT_ID = INSTA_PAR_MOD_PORT_TYPE.MOD_PORT_ID
                   LEFT JOIN  INSTA_MST_PRODUCT
                   ON INSTA_MST_SOLUTION.PRODUCT_ID = INSTA_MST_PRODUCT.PRODUCT_ID
                   LEFT JOIN INSTA_MST_DISCOUNT
                   ON INSTA_MST_SOLUTION.DISCOUNT_ID = INSTA_MST_DISCOUNT.DISCOUNT_ID
                   LEFT JOIN INSTA_MST_CURRENCY
                   ON INSTA_MST_SOLUTION.CURRENCY_ID = INSTA_MST_CURRENCY.CURRENCY_ID
                   WHERE INSTA_MST_SOLUTION.SOLUTION_ID =" + Convert.ToString(ViewState["SOLUTION_ID"]);
        //------------------------------------------------------------------------------------------------------------
        PdfContentByte cb = writer.DirectContent;

        var para = new Paragraph();
        ColumnText ct = new iTextSharp.text.pdf.ColumnText(cb);

        float intYaxis = 150f;

        int intProductId = 0;
        int intProdFeatureFlag = 0;
        int intXaxis = 310;
        //------------------------------------------------------------------------------------------------------------
        IDataReader reader = objHelper.gExecuteReader(CommandType.Text, strSql);
        while (reader.Read())
        {
            intProductId = Convert.ToInt32(string.IsNullOrWhiteSpace(Convert.ToString(reader["PRODUCT_ID"])) ? "0" : Convert.ToString(reader["PRODUCT_ID"]));
            intProdFeatureFlag = Convert.ToInt32(string.IsNullOrWhiteSpace(Convert.ToString(reader["PRODUCT_FEATURE_DISPLAY_FLAG"])) ? "0" : Convert.ToString(reader["PRODUCT_FEATURE_DISPLAY_FLAG"]));

            //lblProductNamePdf.Text = lblProductName.Text = Convert.ToString(reader["PRODUCT_NAME"]);
            //lblHeadSolutionNamePdf.Text = lblHeadSolutionName.Text = ": " + Convert.ToString(reader["SOLUTION_NAME"]);

            //-------------------------------------------------------------------------------------------------------------------------------------------------------
            var logo = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/edsLogo.JPG"));
            logo.SetAbsolutePosition(440, document.Top - 100f);
            logo.ScalePercent(65f, 65f);
            document.Add(logo);
            //-------------------------------------------------------------------------------------------------------------------------------------------------------
            PlaceText(writer.DirectContent, Convert.ToString(reader["PRODUCT_NAME"]) + ":" + Convert.ToString(reader["SOLUTION_NAME"]), titleFont, 316, 750, 40, 790, 14, Element.ALIGN_LEFT);
            PlaceText(writer.DirectContent, "Size:" + Convert.ToString(reader["SIZE_DESCRIPTION"]) + " (" + Convert.ToString(reader["EXHIBIT_DETAILS"]) + ")", bodyFont, 316, 750, 40, 775, 14, Element.ALIGN_LEFT);
            //-------------------------------------------------------------------------------------------------------------------------------------------------------
            var bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            cb.BeginText();
            cb.SetFontAndSize(bf, 9);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "www.expodisplayservice.ae", document.PageSize.GetRight(157), document.PageSize.GetTop(123), 0);
            cb.EndText();
            //-------------------------------------------------------------------------------------------------------------------------------------------------------
            cb.MoveTo(40, document.Top - 120f);
            cb.LineTo(550, document.Top - 120f);
            cb.Stroke();
            //----------------------------------------------------
            cb.MoveTo(40f, document.Top - 130f);
            cb.LineTo(550f, document.Top - 130f);
            cb.LineTo(550f, 100f);
            cb.LineTo(40f, 100f);
            cb.ClosePath();
            cb.Stroke();
            //--------------------------------------------------
            logo = iTextSharp.text.Image.GetInstance(Server.MapPath(imgPreviewLarge.ImageUrl));

            // logo.ScalePercent(20f, 20f);

            logo.ScaleAbsolute(240f, 245f);
            logo.SetAbsolutePosition(55, document.Top - 387f);
            logo.Border = Rectangle.BOX;
            // logo.BorderColor = System.Drawing.Color.Black;
            logo.BorderWidth = 1f;
            document.Add(logo);
            //-----------------------------------------------------
            //PRINT SOLUTION TEXT IF ANY
            if (!string.IsNullOrWhiteSpace(Convert.ToString(reader["SOLUTION_TEXT"])))
            {
                ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                para.Add(new Chunk(Convert.ToString(reader["SOLUTION_TEXT"]), SubbodyFont));
                ct.AddText(para);
                ct.Go();

                intYaxis += 10;
            }
            //-----------------------------------------------------

            if (Convert.ToInt32(Convert.ToString(reader["SHIPPING_DISPLAY_FLAG"])) > 0)
            {
                para = new Paragraph();
                ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                para.Add(new Chunk("Shipping :", subTitleFont));
                ct.AddText(para);
                ct.Go();
                //-------------------------
                intYaxis += 20;

                para = new Paragraph();
                ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                para.Add(new Chunk("Minimum days required to ship : " + Convert.ToString(reader["SHIPPING_DAYS"]), SubbodyFont));
                ct.AddText(para);
                ct.Go();

                intYaxis += 10;
            }

            if (Convert.ToDouble(Convert.ToString(reader["PRICE"])) > 0)
            {
                para = new Paragraph();
                ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                para.Add(new Chunk("Price : ", subTitleFont));
                para.Add(new Chunk(Convert.ToString(reader["CURRENCY_SYMBOL"]) + " " + Convert.ToString(reader["PRICE"]), subTitleFont));
                ct.AddText(para);
                ct.Go();

                intYaxis += 10;
            }

        }
        reader.Close();
        //-----------------------------------------------------------------------

        intYaxis += 5;
        para = new Paragraph();
        ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 10);

        string strParaName = "";
        strSql = @"SELECT INSTA_MST_PARAGRAPH_HEADER.PARAGRAPH_DESCRIPTION,
                          INSTA_MST_SETUP.SOLUTION_DETAILS_BULLET_FLAG,
                          INSTA_MST_SOLUTION_DETAILS.SOLUTION_DETAILS
                   FROM   INSTA_MST_SOLUTION_DETAILS,
                          INSTA_MST_PARAGRAPH_HEADER,
                          INSTA_MST_SETUP
                   WHERE INSTA_MST_SOLUTION_DETAILS.PARAGRAPH_HEADER_ID = INSTA_MST_PARAGRAPH_HEADER.PARAGRAPH_HEADER_ID
                     AND INSTA_MST_SOLUTION_DETAILS.SOLUTION_ID=" + Convert.ToString(ViewState["SOLUTION_ID"]) + @"
                   ORDER BY INSTA_MST_PARAGRAPH_HEADER.SORT_ORDER,
                            INSTA_MST_SOLUTION_DETAILS.SOLUTION_DETAIL_ID";

        reader = objHelper.gExecuteReader(CommandType.Text, strSql);
        while (reader.Read())
        {
            if (strParaName != Convert.ToString(reader["PARAGRAPH_DESCRIPTION"]))
            {
                // intYaxis += 5;
                para = new Paragraph();
                //  ct.SetSimpleColumn(285, document.Top - intYaxis, 500, 100);
                para.Add(new Chunk(Convert.ToString(reader["PARAGRAPH_DESCRIPTION"]) + ": ", SubbodyFont1));
                ct.AddText(para);
                ct.Go();

                // intYaxis += 10;
            }

            //if (Convert.ToInt32(Convert.ToString(reader["SOLUTION_DETAILS_BULLET_FLAG"])) > 0)
            //{
            //    strDynamicHTML += "<li style=\"font-family: Arial, Helvetica, sans-serif;font-size: 12px;\" >" + Convert.ToString(reader["SOLUTION_DETAILS"]) + "</li> ";
            //}
            //else
            //{
            para = new Paragraph();
            //  ct.SetSimpleColumn(285, document.Top - intYaxis, 550, 600);
            para.Add(new Chunk(Convert.ToString(reader["SOLUTION_DETAILS"]), SubbodyFont));
            ct.AddText(para);
            ct.Go();

            // intYaxis += 10;
            //}

            strParaName = Convert.ToString(reader["PARAGRAPH_DESCRIPTION"]);

        }
        reader.Close();

        //ADD PRODUCT FEATURES
        //------------------------------------------------------------------------
        if (intProdFeatureFlag > 0)
        {
            divProductFeature.Visible = true;
            //---------------------------------------------------------
            //intYaxis = 100;
            para = new Paragraph();
            ct.SetSimpleColumn(55, 440, 500, 100);
            para.Add(new Chunk(lblProductName.Text + " Features", subTitleFont));
            ct.AddText(para);
            ct.Go();
            //---------------------------------------------------------
            iTextSharp.text.List listFeature = new iTextSharp.text.List(List.UNORDERED, 10f);
            listFeature.SetListSymbol("\u2022");
            listFeature.IndentationLeft = 1f;
            //---------------------------------------------------------
            strSql = @"SELECT FEATURE_DESCRIPTION,
                              SORT_ORDER,
                              PRODUCT_FEATURE_BULLET_FLAG
                       FROM   INSTA_MST_PRODUCT_FEATURE,
                              INSTA_MST_SETUP
                       WHERE  PRODUCT_ID = " + intProductId + @"
                       ORDER BY SORT_ORDER ";

            reader = objHelper.gExecuteReader(CommandType.Text, strSql);
            while (reader.Read())
            {
                if (Convert.ToInt32(Convert.ToString(reader["PRODUCT_FEATURE_BULLET_FLAG"])) > 0)
                {
                    listFeature.Add(new iTextSharp.text.ListItem(Convert.ToString(reader["FEATURE_DESCRIPTION"]), SubbodyFont));
                }
                else
                {
                    listFeature.Add(new iTextSharp.text.ListItem(Convert.ToString(reader["FEATURE_DESCRIPTION"]), SubbodyFont));
                }
            }
            reader.Close();

            //------------------------------------
            para = new Paragraph();
            ct.SetSimpleColumn(55, 420, 260, 100);
            para.Add(listFeature);

            ct.AddElement(para);
            ct.Go();

            int i = listFeature.Size;

        }

        //-------------------------------------------------------------------------

        document.Close();

        Response.ContentType = "application/pdf";
        Response.AddHeader("Content-Disposition", string.Format("attachment;filename=Receipt-{0}.pdf", lblProductName.Text + lblHeadSolutionName.Text));
        Response.BinaryWrite(output.ToArray());
        Response.End();
    }
コード例 #2
0
ファイル: Global.cs プロジェクト: shreykejriwal/insta
        public static void CreatePDF(string strSolID)
        {
            string strSql = "";
            string strProductName = "";
            string strSolName = "";
            string strImageURL = "";

            DBHelper objHelper = new DBHelper();

            using (MemoryStream output = new MemoryStream())
            {
                using (Document document = new Document(PageSize.A4, 10, 10, 10, 0))
                {
                    using (PdfWriter writer = PdfWriter.GetInstance(document, output))
                    {
                        // CREATE A DOCUMENT OBJECT
                      //  var document = new Document(PageSize.A4, 10, 10, 10, 0);

                        // CREATE A NEW PDFWRITE OBJECT, WRITING THE OUTPUT TO A MEMORYSTREAM
                      //  var output = new MemoryStream();
                      //  var writer = PdfWriter.GetInstance(document, output);

                        // OPEN THE DOCUMENT FOR WRITING
                        //THIS CLASS IS FOR FOOTER
                        PDFHeaderFooter PageEventHandler = new PDFHeaderFooter();
                        writer.PageEvent = PageEventHandler;

                        document.Open();

                        // FIRST, CREATE OUR FONTS... (FOR MORE ON WORKING W/FONTS IN ITEXTSHARP, see: http://www.mikesdotnetting.com/Article/81/iTextSharp-Working-with-Fonts
                        var titleFont = FontFactory.GetFont("Arial", 18, Font.BOLD);
                        titleFont.SetColor(202, 5, 17);

                        var subTitleFont = FontFactory.GetFont("Arial", 12, Font.BOLD);
                        //subTitleFont.SetColor(161, 38, 101);
                        subTitleFont.SetColor(202, 5, 17);

                        var SubbodyFont = FontFactory.GetFont("Arial", 10, Font.NORMAL);
                        var SubbodyFont1 = FontFactory.GetFont("Arial", 10, Font.BOLD);

                        var boldTableFont = FontFactory.GetFont("Arial", 12, Font.BOLD);
                        var endingMessageFont = FontFactory.GetFont("Arial", 10, Font.ITALIC);
                        var bodyFont = FontFactory.GetFont("Arial", 12, Font.NORMAL);
                        var anchorFont = FontFactory.GetFont("Arial", 10, Font.NORMAL);
                        //---------------------------------------------------------------------
                        strSql = @"SELECT INSTA_MST_SOLUTION.SOLUTION_ID,
                              INSTA_MST_SOLUTION.SOLUTION_NAME,
                              INSTA_MST_SIZE.SIZE_DESCRIPTION,
                              INSTA_MST_EXHIBIT_TYPE_DETAIL.EXHIBIT_DETAILS,
                              INSTA_PAR_MOD_PORT_TYPE.MOD_PORT_DESCRIPTION,
                              INSTA_MST_PRODUCT.PRODUCT_ID,
                              INSTA_MST_PRODUCT.PRODUCT_NAME,
                              INSTA_MST_PRODUCT.PRODUCT_DESCRIPTION,
                              INSTA_MST_CURRENCY.CURRENCY_DESCRIPTION,
                              INSTA_MST_CURRENCY.CURRENCY_SYMBOL,
                              INSTA_MST_DISCOUNT.DISCOUNT_RATE,
                              CAST(INSTA_MST_SOLUTION.PRICE AS VARCHAR(10)) AS PRICE,
                              INSTA_MST_SOLUTION.SHIPPING_DAYS,
                              INSTA_MST_SOLUTION.SHIPPING_DISPLAY_FLAG,
                              INSTA_MST_SOLUTION.SOLUTION_TEXT,
                              INSTA_MST_SOLUTION.PRODUCT_FEATURE_DISPLAY_FLAG,
                             (SELECT TOP 1 '~/upload/Images/' + PICTURE_NAME
                              FROM  INSTA_MST_PICTURE_LINK
                              WHERE SOLUTION_ID =INSTA_MST_SOLUTION.SOLUTION_ID
                              AND   INACTIVE_FLAG = 0
                              ORDER BY SORT_ORDER ) AS PICS_URL
                   FROM INSTA_MST_SOLUTION
                   LEFT JOIN INSTA_MST_SIZE
                   ON INSTA_MST_SOLUTION.SIZE_ID = INSTA_MST_SIZE.SIZE_ID
                   LEFT JOIN INSTA_MST_EXHIBIT_TYPE_DETAIL
                   ON INSTA_MST_SOLUTION.EXHIBIT_DETAIL_ID = INSTA_MST_EXHIBIT_TYPE_DETAIL.EXHIBIT_DETAIL_ID
                   LEFT JOIN INSTA_PAR_MOD_PORT_TYPE
                   ON INSTA_MST_SOLUTION.MOD_PORT_ID = INSTA_PAR_MOD_PORT_TYPE.MOD_PORT_ID
                   LEFT JOIN  INSTA_MST_PRODUCT
                   ON INSTA_MST_SOLUTION.PRODUCT_ID = INSTA_MST_PRODUCT.PRODUCT_ID
                   LEFT JOIN INSTA_MST_DISCOUNT
                   ON INSTA_MST_SOLUTION.DISCOUNT_ID = INSTA_MST_DISCOUNT.DISCOUNT_ID
                   LEFT JOIN INSTA_MST_CURRENCY
                   ON INSTA_MST_SOLUTION.CURRENCY_ID = INSTA_MST_CURRENCY.CURRENCY_ID
                   WHERE INSTA_MST_SOLUTION.SOLUTION_ID =" + strSolID;
                        //------------------------------------------------------------------------------------------------------------
                        PdfContentByte cb = writer.DirectContent;

                        var para = new Paragraph();
                        ColumnText ct = new iTextSharp.text.pdf.ColumnText(cb);

                        float intYaxis = 150f;

                        int intProductId = 0;
                        int intProdFeatureFlag = 0;
                        int intXaxis = 310;
                        int intShippingDisflg = 0;
                        int intShippingDays = 0;
                        string strCurrSymbol = "";
                        string strPrice = "";
                        //------------------------------------------------------------------------------------------------------------
                        IDataReader reader = objHelper.gExecuteReader(CommandType.Text, strSql);
                        while (reader.Read())
                        {
                            strProductName = Convert.ToString(reader["PRODUCT_NAME"]);
                            strSolName = Convert.ToString(reader["SOLUTION_NAME"]);
                            strImageURL = Convert.ToString(reader["PICS_URL"]);

                            intProductId = Convert.ToInt32(string.IsNullOrWhiteSpace(Convert.ToString(reader["PRODUCT_ID"])) ? "0" : Convert.ToString(reader["PRODUCT_ID"]));
                            intProdFeatureFlag = Convert.ToInt32(string.IsNullOrWhiteSpace(Convert.ToString(reader["PRODUCT_FEATURE_DISPLAY_FLAG"])) ? "0" : Convert.ToString(reader["PRODUCT_FEATURE_DISPLAY_FLAG"]));

                            //lblProductNamePdf.Text = lblProductName.Text = Convert.ToString(reader["PRODUCT_NAME"]);
                            //lblHeadSolutionNamePdf.Text = lblHeadSolutionName.Text = ": " + Convert.ToString(reader["SOLUTION_NAME"]);

                            //-------------------------------------------------------------------------------------------------------------------------------------------------------
                            //DISPLAY LOGO
                            var logo = iTextSharp.text.Image.GetInstance(HttpContext.Current.Server.MapPath("~/images/Insta-logo.png"));
                            logo.SetAbsolutePosition(445, document.Top - 100f);
                            logo.ScalePercent(65f, 65f);
                            document.Add(logo);

                            //-------------------------------------------------------------------------------------------------------------------------------------------------------
                            PlaceText(writer.DirectContent, Convert.ToString(reader["PRODUCT_NAME"]) + ": " + Convert.ToString(reader["SOLUTION_NAME"]), titleFont, 40, 790, 580, 317, 15, Element.ALIGN_LEFT);
                            PlaceText(writer.DirectContent, "Size: " + Convert.ToString(reader["SIZE_DESCRIPTION"]) + " (" + Convert.ToString(reader["EXHIBIT_DETAILS"]).Replace("<sup>","").Replace("</sup>","") + ")", bodyFont, 40, 775, 580, 317, 15, Element.ALIGN_LEFT);

                            //PlaceText(writer.DirectContent, Convert.ToString(reader["PRODUCT_NAME"]) + ":" + Convert.ToString(reader["SOLUTION_NAME"]), titleFont, 316, 750, 40, 790, 14, Element.ALIGN_LEFT);
                            //PlaceText(writer.DirectContent, "Size:" + Convert.ToString(reader["SIZE_DESCRIPTION"]) + " (" + Convert.ToString(reader["EXHIBIT_DETAILS"]) + ")", bodyFont, 316, 750, 40, 775, 14, Element.ALIGN_LEFT);
                            //-------------------------------------------------------------------------------------------------------------------------------------------------------
                            var bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                            cb.BeginText();
                            cb.SetFontAndSize(FontFactory.GetFont(FontFactory.HELVETICA_BOLD).BaseFont, 8);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "www.insta-group.com", document.PageSize.GetRight(152), document.PageSize.GetTop(123), 0);

                            cb.EndText();
                            //-------------------------------------------------------------------------------------------------------------------------------------------------------
                            //FOR HORIZONTAL LINE BELOW PRODUCT & LOGO IMAGE
                            cb.MoveTo(40, document.Top - 120f);
                            cb.LineTo(550, document.Top - 120f);
                            cb.Stroke();
                            ////----------------------------------------------------
                            //FOR RECTANGLE BORDER OVER CONTENT
                            //cb.MoveTo(40f, document.Top - 130f);
                            //cb.LineTo(550f, document.Top - 130f);
                            //cb.LineTo(550f, 100f);
                            //cb.LineTo(40f, 100f);
                            //cb.ClosePath();
                            //cb.Stroke();
                            //--------------------------------------------------
                            logo = iTextSharp.text.Image.GetInstance(HttpContext.Current.Server.MapPath(strImageURL));

                            // logo.ScalePercent(20f, 20f);

                            logo.ScaleAbsolute(240f, 245f);
                            logo.SetAbsolutePosition(40, document.Top - 387f);
                            logo.Border = Rectangle.BOX;
                            // logo.BorderColor = System.Drawing.Color.Black;
                            logo.BorderWidth = 1f;
                            document.Add(logo);
                            //-----------------------------------------------------
                            //PRINT SOLUTION TEXT IF ANY
                            if (!string.IsNullOrWhiteSpace(Convert.ToString(reader["SOLUTION_TEXT"])))
                            {
                                ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                                para.Add(new Chunk(Convert.ToString(reader["SOLUTION_TEXT"]), SubbodyFont));
                                ct.AddText(para);
                                ct.Go();

                                intYaxis += 10;
                            }
                            //-----------------------------------------------------

                            intShippingDisflg = Convert.ToInt32(Convert.ToString(reader["SHIPPING_DISPLAY_FLAG"]));
                            intShippingDays = Convert.ToInt32(Convert.ToString(reader["SHIPPING_DAYS"]));
                            strCurrSymbol = Convert.ToString(reader["CURRENCY_SYMBOL"]);
                            strPrice = Convert.ToString(reader["PRICE"]);

                            //if (Convert.ToInt32(Convert.ToString(reader["SHIPPING_DISPLAY_FLAG"])) > 0)
                            //{
                            //    para = new Paragraph();
                            //    ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                            //    para.Add(new Chunk("Shipping :", subTitleFont));
                            //    ct.AddText(para);
                            //    ct.Go();
                            //    //-------------------------
                            //    intYaxis += 20;

                            //    para = new Paragraph();
                            //    ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                            //    para.Add(new Chunk("Minimum days required to ship : " + Convert.ToString(reader["SHIPPING_DAYS"]), SubbodyFont));
                            //    ct.AddText(para);
                            //    ct.Go();

                            //    intYaxis += 10;
                            //}

                            //if (Convert.ToDouble(Convert.ToString(reader["PRICE"])) > 0)
                            //{
                            //    para = new Paragraph();
                            //    ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                            //    para.Add(new Chunk("Price : ", subTitleFont));
                            //    para.Add(new Chunk(Convert.ToString(reader["CURRENCY_SYMBOL"]) + " " + Convert.ToString(reader["PRICE"]), subTitleFont));
                            //    ct.AddText(para);
                            //    ct.Go();

                            //    intYaxis += 10;
                            //}

                        }
                        reader.Close();
                        //-----------------------------------------------------------------------

                        //intYaxis += 15;

                        string strParaName = "";
                        strSql = @"SELECT INSTA_MST_PARAGRAPH_HEADER.PARAGRAPH_DESCRIPTION,
                                          INSTA_MST_SETUP.SOLUTION_DETAILS_BULLET_FLAG,
                                          INSTA_MST_SOLUTION_DETAILS.SOLUTION_DETAILS
                                   FROM   INSTA_MST_SOLUTION_DETAILS,
                                          INSTA_MST_PARAGRAPH_HEADER,
                                          INSTA_MST_SETUP
                                   WHERE INSTA_MST_SOLUTION_DETAILS.PARAGRAPH_HEADER_ID = INSTA_MST_PARAGRAPH_HEADER.PARAGRAPH_HEADER_ID
                                     AND INSTA_MST_SOLUTION_DETAILS.SOLUTION_ID=" + strSolID + @"
                                   ORDER BY INSTA_MST_PARAGRAPH_HEADER.SORT_ORDER,
                                            INSTA_MST_SOLUTION_DETAILS.SOLUTION_DETAIL_ID";
                        bool bnlSpecifican = false;
                        reader = objHelper.gExecuteReader(CommandType.Text, strSql);
                        while (reader.Read())
                        {
                            if (!bnlSpecifican)
                            {
                                para = new Paragraph();
                                ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                                para.Add(new Chunk("Specification : ", subTitleFont));
                                ct.AddText(para);
                                ct.Go();

                                intYaxis += 20;

                                bnlSpecifican = true;
                            }

                            if (strParaName != Convert.ToString(reader["PARAGRAPH_DESCRIPTION"]))
                            {
                                para = new Paragraph();
                                para.Add(new Chunk(Convert.ToString(reader["PARAGRAPH_DESCRIPTION"]) + ": ", SubbodyFont1));
                                para.Leading = 0;
                                para.MultipliedLeading = 2f;
                                ct.AddElement(new Phrase(para));
                                //ct.AddElement(Chunk.NEWLINE);
                                // ct.AddElement(para);
                                ct.Go();
                            }

                            para = new Paragraph();
                            para.Add(new Chunk(Convert.ToString(reader["SOLUTION_DETAILS"]), SubbodyFont));

                            // para.SpacingAfter = 0;
                            para.Leading = 0;
                            para.MultipliedLeading = 1f;
                            //  ct.AddElement(new Phrase(para));
                            ct.AddElement(new Phrase(para));

                            //ct.AddText(Chunk.NEWLINE);
                            //ct.AddText(para);

                            ct.Go();

                            strParaName = Convert.ToString(reader["PARAGRAPH_DESCRIPTION"]);

                        }
                        reader.Close();

                        //-----------------------------------------------------------------------------
                        //-- ADDING SHIPPING DETAILS
                        //-----------------------------------------------------------------------------
                        intYaxis = ct.YLine -30 ;

                        if (intShippingDisflg > 0 && intShippingDays > 0)
                        {
                            para = new Paragraph();
                            ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                            //ct.SetSimpleColumn(intXaxis, ct.YLine+50, 550, 100);

                            para.Add(new Chunk("Shipping :", subTitleFont));
                            ct.AddElement(para);
                            ct.Go();
                            //-------------------------
                            intYaxis += 10;

                            para = new Paragraph();
                            ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                            para.Add(new Chunk("Minimum days required to ship : " + intShippingDays, SubbodyFont));
                            ct.AddElement(para);
                            ct.Go();

                        }

                        if (Convert.ToDouble(strPrice) > 0)
                        {
                            intYaxis += 15;
                            para = new Paragraph();
                            ct.SetSimpleColumn(intXaxis, document.Top - intYaxis, 550, 100);
                            para.Add(new Chunk("Price : ", SubbodyFont));
                            para.Add(new Chunk(strCurrSymbol + " " + strPrice, SubbodyFont));
                            ct.AddElement(para);
                            ct.Go();

                        }

                        //ADD PRODUCT FEATURES
                        //------------------------------------------------------------------------
                        if (intProdFeatureFlag > 0)
                        {
                            //---------------------------------------------------------
                            //intYaxis = 100;
                            para = new Paragraph();
                            ct.SetSimpleColumn(40, 440, 500, 100);
                            para.Add(new Chunk(strProductName + " Features", subTitleFont));
                            ct.AddElement(para);
                            ct.Go();
                            //---------------------------------------------------------
                            iTextSharp.text.List listFeature = new iTextSharp.text.List(List.UNORDERED, 10f);
                            listFeature.SetListSymbol("\u2022");
                            listFeature.IndentationLeft = 1f;
                            //---------------------------------------------------------
                            strSql = @"SELECT FEATURE_DESCRIPTION,
                                              SORT_ORDER,
                                              PRODUCT_FEATURE_BULLET_FLAG
                                       FROM   INSTA_MST_PRODUCT_FEATURE,
                                              INSTA_MST_SETUP
                                       WHERE  PRODUCT_ID = " + intProductId + @"
                                       ORDER BY SORT_ORDER ";

                            reader = objHelper.gExecuteReader(CommandType.Text, strSql);
                            while (reader.Read())
                            {
                                if (Convert.ToInt32(Convert.ToString(reader["PRODUCT_FEATURE_BULLET_FLAG"])) > 0)
                                {
                                    listFeature.Add(new iTextSharp.text.ListItem(Convert.ToString(reader["FEATURE_DESCRIPTION"]), SubbodyFont));
                                }
                                else
                                {
                                    listFeature.Add(new iTextSharp.text.ListItem(Convert.ToString(reader["FEATURE_DESCRIPTION"]), SubbodyFont));
                                }
                            }
                            reader.Close();

                            //------------------------------------
                            para = new Paragraph();
                            ct.SetSimpleColumn(40, 420, 260, 100);
                            para.Add(listFeature);

                            ct.AddElement(para);
                            ct.Go();

                            int i = listFeature.Size;

                        }

                        //-------------------------------------------------------------------------
                        document.Close();

                        HttpContext.Current.Response.ContentType = "application/pdf";
                        HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.pdf", strProductName + strSolName));
                        HttpContext.Current.Response.BinaryWrite(output.ToArray());
                        HttpContext.Current.Response.End();
                    }
                }

            }
        }