Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# PDF格式的问题(文本与页脚重叠)_C#_Itext - Fatal编程技术网

C# PDF格式的问题(文本与页脚重叠)

C# PDF格式的问题(文本与页脚重叠),c#,itext,C#,Itext,当我以PDF格式创建报告时,如果包含的内容大于第二页,其工作正常,但在上面的页面中,它与页脚重叠,我尝试使用table.SplitLate=false和secondTable.SplitLate=false但它不工作,而且当我被设置为secondTableCell.VerticalAlignment=Element.ALIGN\u TOP所有的手机都可以接触到最上面的留言板,所以,请告诉我哪里我错了。这里有一些PDF格式的创建报告代码和屏幕截图 谢谢你 datePrintTable=新的PdfP

当我以PDF格式创建报告时,如果包含的内容大于第二页,其工作正常,但在上面的页面中,它与页脚重叠,我尝试使用
table.SplitLate=false
secondTable.SplitLate=false但它不工作,而且当我被设置为
secondTableCell.VerticalAlignment=Element.ALIGN\u TOP所有的手机都可以接触到最上面的留言板,所以,请告诉我哪里我错了。这里有一些PDF格式的创建报告代码和屏幕截图

谢谢你

datePrintTable=新的PdfPTable(1);
datePrintTable.TotalWidth=大小;
datePrintTable.LockedWidth=true;
datePrintTable.SetWidths(新浮点[]{15f});
短语=新短语();
短语.Add(新块(“报告:+ReportModule.Report_Module_Name,FontFactory.GetFont”(“Arial Unicode MS,Arial”,9,iTextSharp.text.Font.BOLD,iTextSharp.text.Color.BLACK));
单元格=短语单元格(短语,PdfPCell.ALIGN_CENTER);
cell.VerticalAlignment=Element.ALIGN\u TOP;
//cell.BorderColor=new iTextSharp.text.Color(229229229229229);
单元固定高度=15f;
datePrintTable.AddCell(单元格);
短语=新短语();
短语.Add(新块(“”,FontFactory.GetFont(“Arial Unicode MS,Arial”,8,iTextSharp.text.Font.BOLD,iTextSharp.text.Color.BLACK));
单元格=短语单元格(短语,PdfPCell.ALIGN_CENTER);
cell.VerticalAlignment=Element.ALIGN\u TOP;
//cell.BorderColor=new iTextSharp.text.Color(229229229229229);
单元固定高度=15f;
datePrintTable.AddCell(单元格);
文件。添加(日期打印表);
float[]widthArry=新的float[ColWidth.Count];
浮动宽度计数=0;
for(int i=0;ix!=0.ToArray();
表=新的PdfPTable(宽度);
表1.TotalWidth=尺寸;
table.LockedWidth=true;
table.SplitLate=false;
表.设置宽度(宽度范围);
int Srno=1;
整数计数=0;
对于(int a=0;a                    datePrintTable = new PdfPTable(1);
                    datePrintTable.TotalWidth = Size;
                    datePrintTable.LockedWidth = true;
                    datePrintTable.SetWidths(new float[] { 15f });

                    phrase = new Phrase();
                    phrase.Add(new Chunk("Report : " + ReportModule.Report_Module_Name, FontFactory.GetFont("Arial Unicode MS,Arial", 9, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                    cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                    cell.VerticalAlignment = Element.ALIGN_TOP;
                    //cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                    cell.FixedHeight = 15f;
                    datePrintTable.AddCell(cell);

                    phrase = new Phrase();
                    phrase.Add(new Chunk("", FontFactory.GetFont("Arial Unicode MS,Arial", 8, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                    cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                    cell.VerticalAlignment = Element.ALIGN_TOP;
                    //cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                    cell.FixedHeight = 15f;
                    datePrintTable.AddCell(cell);

                    document.Add(datePrintTable);

                    float[] widthArry = new float[ColWidth.Count];
                    float widthCount = 0;
                    for (int i = 0; i < ColWidth.Count; i++)
                    {
                        widthArry[i] = ColWidth[i];
                        widthCount += ColWidth[i];
                    }
                    widthArry = widthArry.Where(x => x != 0).ToArray();
                    table = new PdfPTable(widthArry);
                    table.TotalWidth = Size;
                    table.LockedWidth = true;
                    table.SplitLate = false;
                    table.SetWidths(widthArry);

                    int Srno = 1;
                    int count = 0;


                    for (int a = 0; a < colindexid.Count; a = a + 1)
                    {
                        #region addcolumnHeadeName


                        if (colindexid[a].ToString() == Convert.ToString(0))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H1, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(1))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H2, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(2))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H3, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(3))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H4, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(4))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H5, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(5))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H6, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(6))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H7, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(7))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H8, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(8))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H9, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(9))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H10, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(10))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H11, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(11))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H12, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(12))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H13, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }
                        else if (colindexid[a].ToString() == Convert.ToString(13))
                        {
                            // dt.Columns.Add(new DataColumn(H1, typeof(string)));
                            phrase = new Phrase();
                            phrase.Add(new Chunk(H14, FontFactory.GetFont("Arial Unicode MS,Arial", 6, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK)));
                            cell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            cell.FixedHeight = 15f;
                            table.AddCell(cell);

                        }


                        #endregion addcolumnHeadeName
                    }


                    document.Add(table);

                    secondTable = new PdfPTable(widthArry);
                    secondTable.TotalWidth = Size;
                    secondTable.LockedWidth = true;
                    secondTable.SplitLate = false;
                    secondTable.SetWidths(widthArry);



                    foreach (var item in resultAdmissionReuslt)
                    {
                        #region rowadd
                        int ii = 0;
                        float datacellwidth = 0;

                        if (colindexid.Contains(Convert.ToInt32(0)))
                        {

                            phrase = new Phrase();
                            phrase.Add(new Chunk(Convert.ToString(Srno), f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);

                            secondTable.AddCell(secondTableCell);

                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(1)))
                        {

                            if (!string.IsNullOrEmpty(item.AdmissionRequestNo))
                            {
                                item.AdmissionRequestNo = textInfo.ToTitleCase(item.AdmissionRequestNo.ToLower());
                            }
                            phrase = new Phrase();
                            phrase.Add(new Chunk(item.AdmissionRequestNo, f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);

                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(2)))
                        {


                            phrase = new Phrase();
                            phrase.Add(new Chunk(item.Date + "\n", f));
                            phrase.Add(new Chunk(item.Time, f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);

                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(3)))
                        {
                             if (!string.IsNullOrEmpty(item.AttenedBy))
                            {
                                item.AttenedBy = textInfo.ToTitleCase(item.AttenedBy.ToLower());
                            }
                            phrase = new Phrase();
                            phrase.Add(new Chunk(item.AttenedBy, f));                               
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);

                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(4)))
                        {
                            if (!string.IsNullOrEmpty(item.Existing_Relation))
                            {
                                item.Existing_Relation = textInfo.ToTitleCase(item.Existing_Relation.ToLower());
                            }
                            phrase = new Phrase();
                            phrase.Add(new Chunk(item.Existing_Relation, f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);

                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(5)))
                        {      

                            if (!string.IsNullOrEmpty(item.Relation))
                            {
                                item.Relation = textInfo.ToTitleCase(item.Relation.ToLower());
                            }
                            phrase = new Phrase();
                            phrase.Add(new Chunk(item.Relation, f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);

                        }
                        else
                        {
                        }
                        if (colindexid.Contains(Convert.ToInt32(6)))
                        {

                            if (!string.IsNullOrEmpty(item.StudentName))
                            {
                                item.StudentName = textInfo.ToTitleCase(item.StudentName.ToLower());
                            }
                            phrase = new Phrase();
                            phrase.Add(new Chunk(item.StudentName, f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);

                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(7)))
                        {

                            phrase = new Phrase();
                            phrase.Add(new Chunk((item.Gender.ToUpper() == "MALE" ? "M" : "F"), f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);

                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(8)))
                        {

                            if (!string.IsNullOrEmpty(item.ClassForDisplay))
                            {
                                item.ClassForDisplay = textInfo.ToTitleCase(item.ClassForDisplay.ToLower());
                            }
                            phrase = new Phrase();
                            phrase.Add(new Chunk(item.ClassForDisplay, f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);

                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(9)))
                        {

                            if (!string.IsNullOrEmpty(item.ParentName))
                            {
                                item.ParentName = textInfo.ToTitleCase(item.ParentName.ToLower());
                            }
                            phrase = new Phrase();
                            phrase.Add(new Chunk(item.ParentName, f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);

                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(10)))
                        {
                            string Contact = "";
                            if (!string.IsNullOrEmpty(item.ContactNo1))
                            {
                                Contact += item.ContactNo1 ;
                            }
                            if (!string.IsNullOrEmpty(item.contactNo2))
                            {
                                Contact +=  Environment.NewLine + item.contactNo2;
                            }


                            phrase = new Phrase();
                            phrase.Add(new Chunk(Contact, f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);
                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(11)))
                        {
                            if (!string.IsNullOrEmpty(item.LandMark))
                            {
                                item.LandMark= textInfo.ToTitleCase(item.LandMark.ToLower());
                            }

                            phrase = new Phrase();
                            phrase.Add(new Chunk(item.LandMark, f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);
                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(12)))
                        {
                            phrase = new Phrase();
                            phrase.Add(new Chunk((item.Walkin_Online.ToUpper() == "ONLINE" ? "O" : "W"), f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);
                        }
                        else
                        {

                        }
                        if (colindexid.Contains(Convert.ToInt32(13)))
                        {
                            if (!string.IsNullOrEmpty(item.AdmissionStatus))
                            {
                                item.AdmissionStatus= textInfo.ToTitleCase(item.AdmissionStatus.ToLower());
                            }
                            phrase = new Phrase();
                            phrase.Add(new Chunk(item.AdmissionStatus, f));
                            secondTableCell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
                            secondTableCell.BorderColor = new iTextSharp.text.Color(229, 229, 229);
                            secondTableCell.VerticalAlignment = Element.ALIGN_TOP;
                            secondTable.AddCell(secondTableCell);
                        }
                        else
                        {

                        }


                        #endregion rowadd

                        Srno++;
                    }


                    document.Add(secondTable);
                }