Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Sun May 09, 2021 5:21 pm

Hi,
I mostly generate single page PDF ,but some times its have 2 pages and then the last line is overlap with content,bellow code working fine pdf file upto 1 page.

Code: Select all
 grid = new PdfGrid();
            grid.Style.CellPadding = new PdfPaddings(3f, 3f, 3f, 3f);

            grid.Columns.Add(1);
            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Cells[0].Value = "(System Generated Purchase Order Signature NOT Required)";
            pdfGridRow.Cells[0].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[0].Style.Borders.All= new PdfPen(System.Drawing.Color.Transparent);           
            result = grid.Draw(page, new PointF(0, y));

but when 2nd page then the text overlap

pdf.png


Thanks in advance

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Mon May 10, 2021 3:40 am

Hello,

Thanks for your inquiry.
I simulated your case to generated a 2-page PDF, but did not notice the text overlap you mentioned. To help us further analyze your issue, could you please provide your full test code (to generate a 2-page PDF) or a runnable sample project that can reproduce your issue? Thanks in advance for your assistance.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Tue May 11, 2021 3:51 pm

Hi,

Please try with bellow code

Code: Select all
float y = 0;
            PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, new PdfMargins { All = 20f });
            PdfGrid grid;
            PdfLayoutResult result;
            PdfGridCellContentList lst;
            PdfGridCellContent textAndStyle;
            PdfGridRow pdfGridRow;

            #region Item Detais Table
            grid = new PdfGrid();
            var itemdetailstableheaderstyle = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 6f, FontStyle.Regular | FontStyle.Italic), true) };

            grid.Style.CellPadding = new PdfPaddings(3f, 3f, 3f, 3f);
            grid.Columns.Add(8);

            float width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);

            grid.Columns[0].Width = width * 0.03f;
            grid.Columns[1].Width = width * 0.08f;
            grid.Columns[2].Width = width * 0.50f;
            grid.Columns[3].Width = width * 0.05f;
            grid.Columns[4].Width = width * 0.09f;
            grid.Columns[5].Width = width * 0.09f;
            grid.Columns[6].Width = width * 0.07f;
            grid.Columns[7].Width = width * 0.09f;

           
            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Style = itemdetailstableheaderstyle;
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[0].Value = "Sl";
            pdfGridRow.Cells[0].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[1].Value = "HSN";
            pdfGridRow.Cells[1].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[2].Value = "Description of Goods";
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[3].Value = "UOM";
            pdfGridRow.Cells[3].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[4].Value = "QTY";
            pdfGridRow.Cells[4].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[5].Value = "Rate";
            pdfGridRow.Cells[5].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[6].Value = "GST";
            pdfGridRow.Cells[6].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[7].Value = "Value";
            pdfGridRow.Cells[7].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };

            for (int i = 0; i <= 28 - 1; i++)
            {

                PdfGridRow sdlooprow = grid.Rows.Add();


                sdlooprow.Cells[0].Value = Convert.ToString(i + 1);

                sdlooprow.Cells[1].Value = Convert.ToString(4587454);
                sdlooprow.Cells[1].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[1].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Center };

                lst = new PdfGridCellContentList();

                textAndStyle = new PdfGridCellContent();
                textAndStyle.Text = Convert.ToString("Quartz.NET Configuration Reference");
                textAndStyle.Font = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 6.5f, FontStyle.Bold | FontStyle.Italic), true);
                lst.List.Add(textAndStyle);




                textAndStyle = new PdfGridCellContent();
                textAndStyle.Text = " \n" + Convert.ToString("Main Configuration");
                textAndStyle.Font = CellContentStyleVerdana6Regular;
                textAndStyle.Brush = PdfBrushes.Black;
                textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 1f };
                lst.List.Add(textAndStyle);


                sdlooprow.Cells[2].Value = lst;


                sdlooprow.Cells[3].Value = "Nos";
                sdlooprow.Cells[3].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[3].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Center };


                sdlooprow.Cells[4].Value = Convert.ToString(569);
                sdlooprow.Cells[4].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[4].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };

                sdlooprow.Cells[5].Value = Convert.ToString(5856);
                sdlooprow.Cells[5].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[5].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };

                sdlooprow.Cells[6].Value = Convert.ToString(256);
                sdlooprow.Cells[6].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[6].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };

                sdlooprow.Cells[7].Value = Convert.ToString(1256);
                sdlooprow.Cells[7].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[7].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };

            }
           

            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Cells[2].Style = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 7f, FontStyle.Bold | FontStyle.Italic), true) };
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };
            pdfGridRow.Cells[2].Value = "Total";

            pdfGridRow.Cells[6].Value = Convert.ToString(99999999);
            pdfGridRow.Cells[6].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };
            pdfGridRow.Cells[6].Style = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 7f, FontStyle.Bold | FontStyle.Italic), true) };

            pdfGridRow.Cells[7].Value = Convert.ToString(99999999);
            pdfGridRow.Cells[7].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };
            pdfGridRow.Cells[7].Style = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 7f, FontStyle.Bold | FontStyle.Italic), true) };

            result = grid.Draw(page, new PointF(0, y));
            y = y + result.Bounds.Height + 5;

            #region Last Line

            grid = new PdfGrid();
            grid.Style.CellPadding = new PdfPaddings(3f, 3f, 3f, 3f);

            grid.Columns.Add(1);


            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Cells[0].Value = "(System Generated Purchase Order Signature NOT Required)";
            pdfGridRow.Cells[0].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[0].Style.Borders.All = new PdfPen(System.Drawing.Color.Transparent);
            result = grid.Draw(page, new PointF(0, y));
            #endregion

            string filename = "testfile.pdf";
            doc.SaveToFile(Server.MapPath(Statics.virtualPath + "/PrintableFiles/" + filename), Spire.Pdf.FileFormat.PDF);


Upto 27 loop its ok,more then 27 the text
(System Generated Purchase Order Signature NOT Required)
overlap with table cell text.

pdf.png

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Wed May 12, 2021 10:36 am

Hello,

Thanks for your sharing.
In you code, you always draw the second grid on the first page, so when the first grid exceeds one page, there will be a problem of text overlap.

To solve this issue, please refer to the following modified code below.

Code: Select all
            //..........
            //..........
            //Draw the first grid and get the result
            result = grid.Draw(page, new PointF(0, y));
            y = y + result.Bounds.Height + 5;

            #region Last Line
            grid = new PdfGrid();
            grid.Style.CellPadding = new PdfPaddings(3f, 3f, 3f, 3f);

            grid.Columns.Add(1);


            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Cells[0].Value = "(System Generated Purchase Order Signature NOT Required)";
            pdfGridRow.Cells[0].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[0].Style.Borders.All = new PdfPen(System.Drawing.Color.Transparent);
            //*********************************
            // result = grid.Draw(page, new PointF(0, y));
            // Draw the second grid
            result = grid.Draw(result.Page, new PointF(0, y));
            #endregion
            //*********************************
            string filename = "testfile.pdf";
            doc.SaveToFile(Server.MapPath(Statics.virtualPath + "/PrintableFiles/" + filename), Spire.Pdf.FileFormat.PDF);

If you have any other questions, please feel free to contact us.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Wed May 19, 2021 10:32 am

Hello,

Has the issue been solved now? Could you please give us some feedback at your convenience?
Thanks in advance.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Thu May 27, 2021 4:40 pm

Hi,
For the long content a new page added ,How do I get newly added page content height? so that I am able to add more content after that.

Code: Select all
var CellStyleStyleVerdana10Bold = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 10f, FontStyle.Bold), true) };
            var CellStyleStyleVerdana10Regular = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 10f, FontStyle.Regular), true) };
            var CellContentStyleVerdana10Bold = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 10f, FontStyle.Bold), true);
            var CellContentStyleVerdana10Regular = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 10f, FontStyle.Regular), true);
            var CellContentStyleVerdana6Regular = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 6f, FontStyle.Regular), true);
            var CellContentStyleVerdana65Bold = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 6.5f, FontStyle.Bold), true);
            var CellContentStyleVerdana65Regular = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 6.5f, FontStyle.Regular), true);
            var CellStyleVerdana65Regular = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 6.5f, FontStyle.Regular), true) };
            var CellStyleVerdana65Bold = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 6.5f, FontStyle.Bold), true) };
            var CellStyleVerdana6Regular = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 6f, FontStyle.Regular), true) };
            var CellStyleVerdana6Bold = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 6f, FontStyle.Bold), true) };


            float y = 0;
            PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, new PdfMargins { Top = 20f, Left = 20f, Right = 20f, Bottom = 20f });
            PdfGrid grid;
            PdfLayoutResult result;
            PdfGridCellContentList lst;
            PdfGridCellContent textAndStyle;
            PdfGridRow pdfGridRow;

            #region Header
            grid = new PdfGrid();
            grid.Style.CellPadding = new PdfPaddings(3f, 3f, 3f, 3f);
            // grid.Style.CellPadding = new PdfPaddings(20, 20, 20, 20);
            grid.Columns.Add(3);

            float width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);

            grid.Columns[0].Width = width * 0.50f;
            grid.Columns[1].Width = width * 0.25f;
            grid.Columns[2].Width = width * 0.25f;
            #region Company Information

            pdfGridRow = grid.Rows.Add();

            lst = new PdfGridCellContentList();
            textAndStyle = new PdfGridCellContent();

            textAndStyle.Text = "branchdetails.CompanyName";
            textAndStyle.Font = CellContentStyleVerdana10Bold;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Center };
            lst.List.Add(textAndStyle);


            //IEnumerable<string> BranchAddress1 = print.ChunksUpto(Convert.ToString(branchdetails.BranchAddress1), 125);

            //foreach (string address in BranchAddress1)
            //{
            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" + Convert.ToString("branchdetails.BranchAddress1");
            textAndStyle.Font = CellContentStyleVerdana10Regular;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Center };
            lst.List.Add(textAndStyle);
            //// }

            //IEnumerable<string> BranchAddress2 = print.ChunksUpto(Convert.ToString(branchdetails.BranchAddress2), 125);

            //foreach (string address in BranchAddress2)
            //{
            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" + Convert.ToString("branchdetails.BranchAddress2");
            textAndStyle.Font = CellContentStyleVerdana10Regular;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Center };
            lst.List.Add(textAndStyle);
            // }



            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" + "GSTIN/UIN : " + "branchdetails.Branch_GSTIN_NO" + "";
            textAndStyle.Font = CellContentStyleVerdana10Regular;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Center };
            lst.List.Add(textAndStyle);

            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" + " \n" + "PURCHASE ORDER";
            textAndStyle.Font = CellContentStyleVerdana10Bold;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            lst.List.Add(textAndStyle);


            pdfGridRow.Height = 80f;
            pdfGridRow.Cells[0].ColumnSpan = 3;
            pdfGridRow.Cells[0].Value = lst;
            #endregion

            #region PO Details
            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Cells[0].Value = "purchasemaster.VendorName";
            pdfGridRow.Cells[0].Style = CellStyleVerdana65Bold;
            pdfGridRow.Cells[1].Value = "Ref Indent No: ";
            pdfGridRow.Cells[2].Value = "Indent Date: " ;

            pdfGridRow = grid.Rows.Add();


            pdfGridRow.Cells[0].RowSpan = 2;
            pdfGridRow.Height = 50f;
            lst = new PdfGridCellContentList();
            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = Convert.ToString("");
            textAndStyle.Font = CellContentStyleVerdana65Regular;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);


            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" + "GST No: " + Convert.ToString("purchasemaster.VendorGST");
            textAndStyle.Font = CellContentStyleVerdana65Regular;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);


            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" + "Contact  :" + "purchasemaster.VendorContactPerson";
            textAndStyle.Font = CellContentStyleVerdana65Regular;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);


            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" + "Mobile No:" + "purchasemaster.VendorContactNo";
            textAndStyle.Font = CellContentStyleVerdana65Regular;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);


            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" + "Email:" + "purchasemaster.VendorEmail";
            textAndStyle.Font = CellContentStyleVerdana65Regular;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);
            pdfGridRow.Cells[0].Value = lst;

            lst = new PdfGridCellContentList();
            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = "LPO No: " + "purchasemaster.ERPSystem_PurchaseOrderNo";
            textAndStyle.Font = CellContentStyleVerdana65Regular;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);


            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" + "PO Date: " + "purchasemaster.PO_OrderDate.ToString(dd/MM/yyyy)";
            textAndStyle.Font = CellContentStyleVerdana65Regular;
            //textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);

            pdfGridRow.Cells[1].Value = lst;
            pdfGridRow.Cells[2].Value = "Delivery Date: " + "purchasemaster.strDeliveryDate";

            pdfGridRow = grid.Rows.Add();
            //pdfGridRow.Cells[1].Value = ;
            pdfGridRow.Cells[1].Value = "Quotation No: " + "purchasemaster.ReferenceQuotationNos";
            pdfGridRow.Cells[2].Value = "Quotation Date:" + "purchasemaster.ReferenceQuotationDates";


            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Cells[0].ColumnSpan = 3;
            pdfGridRow.Cells[0].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[0].Value = "Please supply the under mentioned goods subject to term & condition stipulated here under";

            // pdfGridRow.Style.Font = CellContentStyleVerdana6Regular;

            #endregion
            result = grid.Draw(page, new PointF(0, y));
            y = y + result.Bounds.Height + 5;

            #endregion

            #region Item Detais Table
            grid = new PdfGrid();
            var itemdetailstableheaderstyle = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Verdana", 6f, FontStyle.Regular | FontStyle.Italic), true) };

            grid.Style.CellPadding = new PdfPaddings(3f, 3f, 3f, 3f);
            grid.Columns.Add(8);

             width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);

            grid.Columns[0].Width = width * 0.03f;
            grid.Columns[1].Width = width * 0.08f;
            grid.Columns[2].Width = width * 0.50f;
            grid.Columns[3].Width = width * 0.05f;
            grid.Columns[4].Width = width * 0.09f;
            grid.Columns[5].Width = width * 0.09f;
            grid.Columns[6].Width = width * 0.07f;
            grid.Columns[7].Width = width * 0.09f;


            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Style = itemdetailstableheaderstyle;
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[0].Value = "Sl";
            pdfGridRow.Cells[0].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[1].Value = "HSN";
            pdfGridRow.Cells[1].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[2].Value = "Description of Goods";
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[3].Value = "UOM";
            pdfGridRow.Cells[3].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[4].Value = "QTY";
            pdfGridRow.Cells[4].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[5].Value = "Rate";
            pdfGridRow.Cells[5].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[6].Value = "GST";
            pdfGridRow.Cells[6].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[7].Value = "Value";
            pdfGridRow.Cells[7].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };

            for (int i = 0; i <= 30 - 1; i++)
            {

                PdfGridRow sdlooprow = grid.Rows.Add();
                sdlooprow.Height = 14f;

                sdlooprow.Cells[0].Value = Convert.ToString(i + 1);

                sdlooprow.Cells[1].Value = Convert.ToString(4587454);
                sdlooprow.Cells[1].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[1].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Center };

               


                sdlooprow.Cells[2].Value = "Quartz.NET Configuration Reference";
                sdlooprow.Cells[2].Style = CellStyleVerdana65Bold;
                sdlooprow.Cells[2].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Left };

                sdlooprow.Cells[3].Value = "Nos";
                sdlooprow.Cells[3].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[3].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Center };


                sdlooprow.Cells[4].Value = Convert.ToString(569);
                sdlooprow.Cells[4].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[4].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };

                sdlooprow.Cells[5].Value = Convert.ToString(5856);
                sdlooprow.Cells[5].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[5].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };

                sdlooprow.Cells[6].Value = Convert.ToString(256);
                sdlooprow.Cells[6].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[6].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };

                sdlooprow.Cells[7].Value = Convert.ToString(1256);
                sdlooprow.Cells[7].Style = CellStyleVerdana65Regular;
                sdlooprow.Cells[7].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };

            }


            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Cells[2].Style = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 7f, FontStyle.Bold | FontStyle.Italic), true) };
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };
            pdfGridRow.Cells[2].Value = "Total";

            pdfGridRow.Cells[6].Value = Convert.ToString(99999999);
            pdfGridRow.Cells[6].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };
            pdfGridRow.Cells[6].Style = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 7f, FontStyle.Bold | FontStyle.Italic), true) };

            pdfGridRow.Cells[7].Value = Convert.ToString(99999999);
            pdfGridRow.Cells[7].StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Right };
            pdfGridRow.Cells[7].Style = new PdfGridCellStyle() { Font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 7f, FontStyle.Bold | FontStyle.Italic), true) };

            result = grid.Draw(page, new PointF(0, y));
            y = y + result.Bounds.Height + 5;
            #endregion

            #region Amount in Word
            grid = new PdfGrid();
            grid.Style.CellPadding = new PdfPaddings(3f, 3f, 3f, 3f);

            grid.Columns.Add(2);

            width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);

            grid.Columns[0].Width = width * 0.10f;
            grid.Columns[1].Width = width * 0.90f;



            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 15f;


            pdfGridRow.Cells[0].Value = "Total In Words ";
            pdfGridRow.Cells[0].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Left };
            pdfGridRow.Cells[0].Style = CellStyleVerdana65Regular;

            pdfGridRow.Cells[1].Value = "INR ";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Bold;
            pdfGridRow.Cells[1].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Left };

            pdfGridRow.Cells[0].Style.Borders.Right = new PdfPen(System.Drawing.Color.Transparent);
            pdfGridRow.Cells[1].Style.Borders.Left = new PdfPen(System.Drawing.Color.Transparent);


            result = grid.Draw(result.Page, new PointF(0, y));
            y = y + result.Bounds.Height + 5;

            #endregion

            #region Delivery Details

            grid = new PdfGrid();
            grid.Style.CellPadding = new PdfPaddings(3f, 3f, 3f, 3f);

            grid.Columns.Add(3);

            width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);

            grid.Columns[0].Width = width * 0.65f;
            grid.Columns[1].Width = width * 0.15f;
            grid.Columns[2].Width = width * 0.20f;

            pdfGridRow = grid.Rows.Add();

            pdfGridRow.Height = 25f;
            pdfGridRow.Cells[0].RowSpan = 3;

            lst = new PdfGridCellContentList();
            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = "Delivery Address: ";
            textAndStyle.Font = CellContentStyleVerdana65Bold;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);

            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" ;
            textAndStyle.Font = CellContentStyleVerdana65Regular;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);

            pdfGridRow.Cells[0].Value = lst;

            pdfGridRow.Cells[1].Value = "Price :";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = Convert.ToString(5542454.54);
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };

            pdfGridRow = grid.Rows.Add();

            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[1].Value = "Discount :";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = Convert.ToString(54564.23);
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };

            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[1].Value = "Service Amount :";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = Convert.ToString(48414.36);
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };

            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[0].Value = "Payment Terms :" + "purchasemaster.PaymentTermName";
            pdfGridRow.Cells[0].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[1].Value = "Commissioning :";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = Convert.ToString(24544.56);
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };

            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[0].RowSpan = 7;
            pdfGridRow.Cells[0].Value = "Insurance : " + "purchasemaster.InsuranceProviderDetails";
            pdfGridRow.Cells[0].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[1].Value = "TCS : ";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = Convert.ToString(656565.35);
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };

            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[1].Value = "GST Rate : ";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = "";
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };


            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[1].Value = "IGST : ";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = Convert.ToString(54454);
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };

            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[1].Value = "SGST :";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = Convert.ToString(87879);
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };

            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[1].Value = "CGST :";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = Convert.ToString(784);
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };

            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[1].Value = "Round off :";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = Convert.ToString(5);
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };

            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[1].Value = "Total :";
            pdfGridRow.Cells[1].Style = CellStyleVerdana65Regular;
            pdfGridRow.Cells[2].Value = Convert.ToString(5454);
            pdfGridRow.Cells[2].Style = CellStyleVerdana6Bold;
            pdfGridRow.Cells[2].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Right };


            result = grid.Draw(result.Page, new PointF(0, y));
            y = y + result.Bounds.Height + 5;


            #endregion

            #region Remarks

            grid = new PdfGrid();
            grid.Style.CellPadding = new PdfPaddings(3f, 3f, 3f, 3f);

            grid.Columns.Add(2);

            width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);

            grid.Columns[0].Width = width * 0.10f;
            grid.Columns[1].Width = width * 0.90f;



            //pdfGridRow = grid.Rows.Add();
            //pdfGridRow.Cells[0].Value = "Remarks :";
            //pdfGridRow.Cells[0].ColumnSpan = 2;


            pdfGridRow = grid.Rows.Add();
            //pdfGridRow.Height = 14f;
            lst = new PdfGridCellContentList();

            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = "purchasemaster.PONote_1";
            textAndStyle.Font = CellContentStyleVerdana6Regular;
            textAndStyle.StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);

            pdfGridRow.Cells[0].Value = "Note 1";
            pdfGridRow.Cells[1].Value = lst;
            pdfGridRow.Cells[0].Style.Borders.Right = new PdfPen(System.Drawing.Color.Transparent);
            //pdfGridRow.Cells[1].Style.Borders.Bottom = new PdfPen(System.Drawing.Color.Transparent);

            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Height = 14f;
            lst = new PdfGridCellContentList();

            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = "purchasemaster.PONote_2";
            textAndStyle.Font = CellContentStyleVerdana6Regular;
            textAndStyle.StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);

            pdfGridRow.Cells[0].Value = "Note 2";
            pdfGridRow.Height = 14f;
            pdfGridRow.Cells[1].Value = lst;
            pdfGridRow.Cells[0].Style.Borders.Right = new PdfPen(System.Drawing.Color.Transparent);
            //pdfGridRow.Cells[1].Style.Borders.Bottom = new PdfPen(System.Drawing.Color.Transparent);

            pdfGridRow = grid.Rows.Add();
            lst = new PdfGridCellContentList();

            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = "purchasemaster.Remarks";
            textAndStyle.Font = CellContentStyleVerdana6Regular;
            textAndStyle.StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);

            pdfGridRow.Cells[0].Value = "Remarks";
            pdfGridRow.Cells[1].Value = lst;
            pdfGridRow.Cells[0].Style.Borders.Right = new PdfPen(System.Drawing.Color.Transparent);
            //pdfGridRow.Cells[1].Style.Borders.All = new PdfPen(System.Drawing.Color.Transparent);

            pdfGridRow = grid.Rows.Add();
            lst = new PdfGridCellContentList();

            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = "For " + "branchdetails.CompanyName";
            textAndStyle.Font = CellContentStyleVerdana10Bold;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);

            textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = " \n" + " \n" + "Authorised Signatory";
            textAndStyle.Font = CellContentStyleVerdana10Bold;
            textAndStyle.StringFormat = new PdfStringFormat { LineSpacing = textAndStyle.Font.Size * 2f, Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);

            pdfGridRow.Height = 50f;
            pdfGridRow.Cells[0].ColumnSpan = 2;
            pdfGridRow.Cells[0].Value = lst;

            result = grid.Draw(result.Page, new PointF(0, y));
            y = y + result.Bounds.Height + 5;

            #endregion

            #region Last Line

            grid = new PdfGrid();
            grid.Style.CellPadding = new PdfPaddings(3f, 3f, 3f, 3f);

            grid.Columns.Add(1);


            pdfGridRow = grid.Rows.Add();
            pdfGridRow.Cells[0].Value = "(System Generated Purchase Order Signature NOT Required)";
            pdfGridRow.Cells[0].StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Center };
            pdfGridRow.Cells[0].Style.Borders.All = new PdfPen(System.Drawing.Color.Transparent);
            result = grid.Draw(result.Page, new PointF(0, y));
            #endregion

            string filename = "testfile.pdf";
            doc.SaveToFile(Server.MapPath(Statics.virtualPath + "/PrintableFiles/" + filename), Spire.Pdf.FileFormat.PDF);

testfile.rar

above code genarate attached pdf ,which is not genarate as expected,I want every element one after another but its genarate too much gap between the.

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Fri May 28, 2021 6:28 am

Hello,

Thank you for your reply.
Please refer to the attached modified code. If you have any other questions, you are welcome to contact us.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Fri May 28, 2021 8:41 am

Thanks for reply,
But If item count more then 30 (the item count not fixed ,can be any number between 1-200) ,I change the code and add 60 loops for item and then its not working properly.
Please see attached file and code

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Fri May 28, 2021 10:53 am

Hello,

Thank you for your reply.
Please refer to the attached modified code. If you have any other questions, you are welcome to contact us.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Fri May 28, 2021 12:21 pm

Hi,
Thanks for reply..Working now.

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Mon May 31, 2021 2:32 am

Glad to hear that your issue has been solved.
Have a nice day!
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.PDF