jasmine jain Ответов: 1

Как удалить дублирующуюся строку, входящую на следующую страницу pdf, используя itextsharp в C#


после использования table.splitlate = false ; я получаю эту ошибку. дубликат строки появляется в начале следующей страницы, как и последняя строка страницы 1.
пожалуйста помочь.

вот мой код:

public string GeneratePDF(List<ProviderDirectory.Provider> PCPData, GetPCPRequest request)
{

    string fileName = "ProviderDetails" + "_" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".pdf";
    string pdfpath = HealthGen.AppServices.Helpers.Helper.GetAppSettingValue(AppConstants.PCPPdfPath);
    string path = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
    pdfpath = pdfpath + fileName;
    var RequestParam = request.Updated_Date.Split(',');
    var UpdatedDate = RequestParam[0];
    var ProviderDirectory = RequestParam[1];
    var PdfParagraphh = RequestParam[2];
    var Disclaimer = RequestParam[3];
    var WorkinHr = RequestParam[4];
    var UpdatedOn = RequestParam[5];
    var Speciality = RequestParam[6];
    var Gender = RequestParam[7];
    var ProvType = RequestParam[8];
    var FrstName = RequestParam[9];
    var LastName = RequestParam[10];
    var Telephone = RequestParam[11];
    var Location = RequestParam[12];
    var Languages = RequestParam[13];
    var Hospitiliation = RequestParam[14];
    var MondayHrs = RequestParam[15];
    var TuesdayHrs = RequestParam[16];
    var WednesdayHrs = RequestParam[17];
    var ThursdayHrs = RequestParam[18];
    var FridayHrs = RequestParam[19];
    var DocTypeText = RequestParam[20];
    var FacTypeText = RequestParam[21];
    var Docctor = RequestParam[22];
    var Facility = RequestParam[23];
    var Behavioural = RequestParam[24];
    var Hospital = RequestParam[25];
    var DME = RequestParam[26];
    var MedAffiliation = RequestParam[27];
    var AcceptingNewPatients = RequestParam[28];
    var AreaOfExpertise = RequestParam[29];
    var urgentcarefacility = RequestParam[30];
    var BoardCertification = RequestParam[31];
    var PCP = RequestParam[32];
    var Limitations = RequestParam[33];
    var LanguagesClinical = RequestParam[34];
    var Telemedicine = RequestParam[35];
    var ADAaccessibility = RequestParam[36];
    var AccessibilityDetails = RequestParam[37];
    var InterpretationServices = RequestParam[38];
    var Accreditation = RequestParam[39];

    //   HealthGenPortalEntities objHIXPortal = null;
    //once you have the path you get the directory with:

    var directory = System.IO.Path.GetDirectoryName(path);
    Document document = new Document(PageSize.A4, 10, 10, 10, 40);

    Font NormalFont = FontFactory.GetFont("Calibri", 11, Font.NORMAL, Color.BLACK);
    PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(pdfpath, FileMode.Create));
    writer.PageEvent = new ITextSharpOverrides.PDFFooter();

    Phrase phrase = null;
    Phrase Link = null;
    PdfPTable celltable = null;
    Color color = null;
    bool ispcp_required = false;
    document.Open();


    #region Add Client loago to PDF
    string ClientLogoPath = string.Empty;
    if (request.Plan == AppConstants.Medicaid)
    {
        ClientLogoPath = HealthGen.AppServices.Helpers.Helper.GetAppSettingValue(AppConstants.Medicaid_logo);
    }
    else if (request.Plan == AppConstants.Medicare)
    {
        ClientLogoPath = HealthGen.AppServices.Helpers.Helper.GetAppSettingValue(AppConstants.Medicare_logo);
    }
    var ClientLogo = Image.GetInstance(ClientLogoPath);
    ClientLogo.ScalePercent(30f);
    if (request.Plan == AppConstants.Medicare)
    {
        ClientLogo.ScalePercent(50f);
    }
    phrase = new Phrase();
    phrase.Add(new Chunk(ClientLogo, 0, 0, true));

    PdfPTable table = new PdfPTable(2);
    table.TotalWidth = 700f;

    table.SetWidths(new float[] { 350f, 350f });

    PdfPCell cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
    table.AddCell(cell);

    phrase = new Phrase();
    phrase.Add(new Chunk(UpdatedOn + " " + UpdatedDate, FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.BLACK)));
    cell = PhraseCellVerticalAlignment(phrase, PdfPCell.ALIGN_RIGHT);

    table.AddCell(cell);
    document.Add(table);

    #endregion

    table = new PdfPTable(2);
    table.TotalWidth = 700f;
    table.SetWidths(new float[] { 350f, 350f });
    int j = 1;

    var ImgPath = HealthGen.AppServices.Helpers.Helper.GetAppSettingValue(AppConstants.PhoneImgPath);
    var image = Image.GetInstance(ImgPath);
    image.ScaleToFit(10, 10);
    var ISCHCImg = HealthGen.AppServices.Helpers.Helper.GetAppSettingValue(AppConstants.ISCHCPImgPath);
    var image1 = Image.GetInstance(ISCHCImg);
    image1.ScaleToFit(20, 20);
    var ISPCMHImg = HealthGen.AppServices.Helpers.Helper.GetAppSettingValue(AppConstants.ISPCMHImgPath);
    var image2 = Image.GetInstance(ISPCMHImg);
    image2.ScaleToFit(20, 20);
    var ADAAccessibilityImg = HealthGen.AppServices.Helpers.Helper.GetAppSettingValue(AppConstants.ADAAccessibilityImgPath);
    var image3 = Image.GetInstance(ADAAccessibilityImg);
    image3.ScaleToFit(20, 20);
    var TelemedicineImg = HealthGen.AppServices.Helpers.Helper.GetAppSettingValue(AppConstants.TelemedicineImgPath);
    var image4 = Image.GetInstance(TelemedicineImg);
    image4.ScaleToFit(20, 20);

    phrase = new Phrase();

    table = new PdfPTable(1);
    table.TotalWidth = 700f;
    table.SetWidths(new float[] { 700f });
    cell = PhraseCellVerticalAlignment(phrase, PdfPCell.ALIGN_MIDDLE);

    table.AddCell(cell);
    document.Add(table);

    var TopBoardercount = 0;

    foreach (var clinics in PCPData)
    {
        TopBoardercount = TopBoardercount + 1;
        //document.Add(new Paragraph(new Chunk("\n", FontFactory.GetFont("Calibri", 11, Font.NORMAL, Color.BLACK))));
        //phrase.Leading = 0; //line spacing
        #region template for Clinic Name
        table = new PdfPTable(1);
        table.TotalWidth = 700f;
        table.SetWidths(new float[] { 700f });
        phrase = new Phrase();
        phrase.Add(new Chunk(clinics.ClinicName + "", FontFactory.GetFont("Calibri", 11, Font.BOLD, Color.BLACK)));

        if (clinics.ISCHC == "Y")
        {
            phrase.Add(new Chunk("  "));
            phrase.Add(new Chunk(image1, 0, 0, true));
            phrase.Add(new Chunk(" "));
        }
        if (clinics.ISPCMH == "Y")
        {
            phrase.Add(new Chunk("  "));
            phrase.Add(new Chunk(image2, 0, 0, true));
            phrase.Add(new Chunk(" "));
        }
        if (clinics.ADAAccessibility == "Y")
        {
            phrase.Add(new Chunk("  "));
            phrase.Add(new Chunk(image3, 0, 0, true));
            phrase.Add(new Chunk(" "));
        }
        if (clinics.Telemedicine == "Y")
        {
            phrase.Add(new Chunk("  "));
            phrase.Add(new Chunk(image4, 0, 0, true));
            phrase.Add(new Chunk(" "));
        }

        var cliniccell = PhraseCellVerticalAlignment(phrase, PdfPCell.ALIGN_MIDDLE);
        cliniccell.BorderWidthBottom = 1f;
        cliniccell.BorderWidthRight = 1f;
        cliniccell.BorderWidthTop = 1f;
        cliniccell.BorderWidthLeft = 1f;
        cliniccell.BorderColor = Color.LIGHT_GRAY;

        #endregion

        table = new PdfPTable(2);
        table.TotalWidth = 700f;
        table.SetWidths(new float[] { 350f, 350f });
        cliniccell.Colspan = 2;
        table.AddCell(cliniccell);

        // reduced space raid 95

        table.SplitLate = false;
        table.SetWidths(new int[] { 7, 7 });

        if (TopBoardercount != 1)
        {
            //table.DeleteLastRow();
            document.Add(new Paragraph(new Chunk("\n", FontFactory.GetFont("Calibri", 11, Font.NORMAL, Color.BLACK))));
        }
        ispcp_required = clinics.Providers.Any(x => x.PCPFlag);
        j = 1;

        var cellcount = 0;
        var tablecount = 0;
        var providerscount = 1;
        foreach (var prov in clinics.Providers)
        {


            #region Template for Provider info
            phrase = new Phrase();

            string Name = string.Empty;

            if (!string.IsNullOrEmpty(prov.FirstName))
            {
                Name = Name + prov.FirstName + " ";
            }
            if (!string.IsNullOrEmpty(prov.LastName))
            {
                Name = Name + prov.LastName;
            }
            if (!string.IsNullOrEmpty(prov.LICENSE))
            {
                Name = Name + ", " + prov.LICENSE;
            }

            //if (prov.DIRECTORY_INCLUDE == "Y" && prov.MEDI_DIRECTORY_INCLUDE == "Y" && !string.IsNullOrWhiteSpace(request.DualIndicatorLabel))
            //    Name = Name + "\n";
            //else
            //    Name = Name + "\n\n";

            phrase.Add(new Chunk(Name, FontFactory.GetFont("Calibri", 10, Font.BOLDITALIC, Color.DARK_GRAY)));
            phrase.Add(new Chunk("\n"));
            if (prov.DIRECTORY_INCLUDE == "Y" && prov.MEDI_DIRECTORY_INCLUDE == "Y" && !string.IsNullOrWhiteSpace(request.DualIndicatorLabel))
                phrase.Add(new Chunk(request.DualIndicatorLabel + "\n", FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

           if (request.ProviderType == "DOC" || request.ProviderType == "BHE")
            {
                var ProvGender = "";
                if (prov.Gender == "M")
                    ProvGender = "Male";
                else if (prov.Gender == "F")
                    ProvGender = "Female";
                else if (prov.Gender == "U")
                    ProvGender = "Unknown";
                else
                    ProvGender = "Not Available";
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(Gender + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk(ProvGender, FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
            }

            string zipcode = string.Empty;
            if (!string.IsNullOrEmpty(prov.ZipCode) && prov.ZipCode.Length > 5)
            {
                zipcode = prov.ZipCode.Substring(0, 5);
            }
            else
            {
                zipcode = prov.ZipCode;
            }
            var address = "";
            address = prov.Address1 != null ? address + prov.Address1 : "";
            address = prov.Address2 != null ? address != "" ? address + ", " + prov.Address2 : address + prov.Address2 : "";
            address = prov.City != null ? address != "" ? address + ", " + prov.City : address + prov.City : "";
            address = prov.State != null ? address != "" ? address + ", " + prov.State : address + prov.State : "";
            address = zipcode != null && address != "" ? address + ", " + zipcode : "";
            address = prov.County != null && prov.County != "" && address != "" ? address + ", " + prov.County : address + "";
            address = address.Replace(", , ", ", ");
            phrase.Add(new Chunk("\n"));
            phrase.Add(new Chunk(Location + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
            phrase.Add(new Chunk(address, FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

            if (prov.PhoneNumber != "" && prov.PhoneNumber != null)
            {
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(image, 0, 0, true));
                Int64 phone = 0;
                Int64.TryParse(prov.PhoneNumber, out phone);
                if (phone != 0)
                {
                    phrase.Add(new Chunk(Telephone + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                    phrase.Add(new Chunk(phone.ToString("(###) ###-####"), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

                }
                else
                {
                    phrase.Add(new Chunk(Telephone + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                    phrase.Add(new Chunk("Not Available", FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                }
            }
            else
            {
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(image, 0, 0, true));
                phrase.Add(new Chunk(Telephone + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk("Not Available", FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
            }

            var Specialty = "";
            if (prov.Specialty != null && prov.Specialty != "")
                Specialty = prov.Specialty.Replace("|", "\n");
            else
                Specialty = "Not Available";
            phrase.Add(new Chunk("\n"));
            phrase.Add(new Chunk(Speciality + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
            phrase.Add(new Chunk(Specialty, FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
            phrase.Add(new Chunk("\n"));
            phrase.Add(new Chunk(AcceptingNewPatients + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
            phrase.Add(new Chunk((prov.AcceptingPatients == "" ? "Not Available" : prov.AcceptingPatients), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

            if (prov.MONDAY_HOURS == "" && prov.TUESDAY_HOURS == "" && prov.WEDNESDAY_HOURS == "" && prov.THURSDAY_HOURS == "" && prov.FRIDAY_HOURS == "")
            {
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(WorkinHr + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk("Not Available", FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
            }
            else
            {
                phrase.Add(new Chunk("\n"));
                string MondayHr = prov.MONDAY_HOURS == null ? "Not Available" : HoursCalculate(prov.MONDAY_HOURS);
                string TuesdayHr = prov.TUESDAY_HOURS == null ? "Not Available" : HoursCalculate(prov.TUESDAY_HOURS);
                string WednesdayHr = prov.WEDNESDAY_HOURS == null ? "Not Available" : HoursCalculate(prov.WEDNESDAY_HOURS);
                string ThursdayHr = prov.THURSDAY_HOURS == null ? "Not Available" : HoursCalculate(prov.THURSDAY_HOURS);
                string FridayHr = prov.FRIDAY_HOURS == null ? "Not Available" : HoursCalculate(prov.FRIDAY_HOURS);

                var Hours = "";

                Hours = "\n" + MondayHrs + "- " + MondayHr + "\n";
                Hours = Hours + TuesdayHrs + "- " + TuesdayHr + "\n";
                Hours = Hours + WednesdayHrs + "- " + WednesdayHr + "\n";
                Hours = Hours + ThursdayHrs + "- " + ThursdayHr + "\n";
                Hours = Hours + FridayHrs + "- " + FridayHr;
                phrase.Add(new Chunk(WorkinHr + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk(Hours, FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

            }
            if (request.ProviderType == "DOC")
            {
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(PCP + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.PCPFlag.ToString() == "" ? "Not Available" : prov.PCPFlag.ToString() == "True" ? "Y" : "No"), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

            }
            if (request.ProviderType == "DOC" || request.ProviderType == "BHE")
            {
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(urgentcarefacility + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.IsUrgentcare == "" ? "Not Available" : prov.IsUrgentcare), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(Telemedicine + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.Telemedicine == "" ? "Not Available" : prov.Telemedicine), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(MedAffiliation + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.PracticeGroup == "" ? "Not Available" : prov.PracticeGroup), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(Hospitiliation + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.HospAffiliationName == "" ? "Not Available" : prov.HospAffiliationName), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(BoardCertification + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.BoardCertifications == "" ? "Not Available" : prov.BoardCertifications), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(AreaOfExpertise + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.AreasOfExpertise == "" ? "Not Available" : prov.AreasOfExpertise), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(Limitations + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.LIMITATIONS == "" ? "Not Available" : prov.LIMITATIONS), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

            }
            if (request.ProviderType == "BHE" || request.ProviderType == "DME")
            {
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(Accreditation + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.Accreditation == "" ? "Not Available" : prov.Accreditation), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(InterpretationServices + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.InterpretationServices == "" ? "Not Available" : prov.InterpretationServices), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
            }
            if (request.ProviderType == "FAC" || request.ProviderType == "HOSP")
            {
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(urgentcarefacility + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.IsUrgentcare == "" ? "Not Available" : prov.IsUrgentcare), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(Telemedicine + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.Telemedicine == "" ? "Not Available" : prov.Telemedicine), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(Accreditation + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.Accreditation == "" ? "Not Available" : prov.Accreditation), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(InterpretationServices + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.InterpretationServices == "" ? "Not Available" : prov.InterpretationServices), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                phrase.Add(new Chunk("\n"));
                phrase.Add(new Chunk(Limitations + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                phrase.Add(new Chunk((prov.LIMITATIONS == "" ? "Not Available" : prov.LIMITATIONS), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

                if (prov.ClinicalStafLanguage != "")
                {
                    var Language = "";
                    Language = prov.ClinicalStafLanguage.Replace('|', ',');
                    Language = Language.Trim(',');
                    Language = Language.Replace(",", ", ");
                    phrase.Add(new Chunk("\n"));
                    phrase.Add(new Chunk(Languages + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                    phrase.Add(new Chunk(Language, FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

                }
                else
                {
                    phrase.Add(new Chunk("\n"));
                    phrase.Add(new Chunk(Languages + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                    phrase.Add(new Chunk("Not Available", FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

                }
            }
            else
            {
                if (prov.Languages != "" && prov.Languages != null)
                {

                    var ProvLanguage = "";
                    ProvLanguage = prov.Languages.Replace('|', ',');
                    ProvLanguage = ProvLanguage.Trim(',');
                    ProvLanguage = ProvLanguage.Replace(",", ", ");
                    phrase.Add(new Chunk("\n"));
                    phrase.Add(new Chunk(Languages + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                    phrase.Add(new Chunk(ProvLanguage, FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                }
                else
                {
                    phrase.Add(new Chunk("\n"));
                    phrase.Add(new Chunk(Languages + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
                    phrase.Add(new Chunk("Not Available", FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
                }
            }
            phrase.Add(new Chunk("\n"));
            phrase.Add(new Chunk(LanguagesClinical + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
            phrase.Add(new Chunk((prov.ClinicalStafLanguage == "" ? "Not Available" : prov.ClinicalStafLanguage), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
            phrase.Add(new Chunk("\n"));
            phrase.Add(new Chunk(ADAaccessibility + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
            phrase.Add(new Chunk((prov.ADAAccessibility == "" ? "Not Available" : prov.ADAAccessibility), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));
            phrase.Add(new Chunk("\n"));
            phrase.Add(new Chunk(AccessibilityDetails + ": ", FontFactory.GetFont("Calibri", 9, Font.BOLD, Color.DARK_GRAY)));
            phrase.Add(new Chunk((prov.Accessibility == "" ? "Not Available" : prov.Accessibility), FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY)));

            #endregion


            //cell.AddElement(new Paragraph(Convert.ToString("to be continued")));
            //table.AddCell(cell);
            //cell.AddElement(new Paragraph("Continue on next page"));
            //table.AddCell (cell);
            //table.SkipFirstHeader = true;
            //table.SkipLastFooter = true;

            //var wrapperTable = new PdfPTable(2);
            //wrapperTable.DefaultCell.Border = Rectangle.NO_BORDER;
            //wrapperTable.AddCell(phrase);
            //cell.AddElement(wrapperTable);

            cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
            cell.BorderColorRight = Color.LIGHT_GRAY;
            cell.BorderWidthRight = 0.1f;

            if (cellcount > 0)
            {
                cell.BorderColorLeft = Color.LIGHT_GRAY;
                cell.BorderWidthLeft = 0.1f;
                cell.BorderColorRight = Color.LIGHT_GRAY;
                cell.BorderWidthRight = 0.1f;

                cell.BorderColorTop = Color.LIGHT_GRAY;
                cell.BorderWidthTop = 0.1f;

                cell.BorderColorBottom = Color.LIGHT_GRAY;
                cell.BorderWidthBottom = 0.1f;
            }
            else
            {
                cell.BorderColorLeft = Color.LIGHT_GRAY;
                cell.BorderWidthLeft = 0.1f;

                cell.BorderColorTop = Color.LIGHT_GRAY;
                cell.BorderWidthTop = 0.1f;

                cell.BorderColorBottom = Color.LIGHT_GRAY;
                cell.BorderWidthBottom = 0.1f;
            }
            tablecount++;
            table.AddCell(cell);

            providerscount++;
            if (j == 2)
            {
                if (providerscount < clinics.Providers.Count())
                {
                    j = 1;
                }
                cellcount = 0;
            }
            else
            {
                cellcount++;
                j++;
            }

        }
        do
        {
            phrase = new Phrase();
            cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT); ;
            cell.BorderColorLeft = Color.LIGHT_GRAY;
            cell.BorderWidthLeft = 0.1f;
            cell.BorderColorRight = Color.LIGHT_GRAY;
            cell.BorderWidthRight = 0.1f;
            cell.BorderColorTop = Color.LIGHT_GRAY;
            cell.BorderWidthTop = 0.1f;

            cell.BorderColorBottom = Color.LIGHT_GRAY;
            cell.BorderWidthBottom = 0.1f;

            table.AddCell(cell);

            j++;

        }
        while (j <= 2);

        document.Add(table);

        // pagebreak logic
        //document.NewPage();
    }


    table = new PdfPTable(1);
    table.TotalWidth = 700f;

    phrase = new Phrase();
    //phrase.Add(new Paragraph(new Chunk("\n", FontFactory.GetFont("Calibri", 11, Font.NORMAL, Color.BLACK))));
    phrase.Add(new Paragraph(new Chunk("\n" + Disclaimer, FontFactory.GetFont("Calibri", 11, Font.BOLD, Color.BLACK))));
    phrase.Add(new Paragraph(new Chunk("\n\n" + PdfParagraphh, FontFactory.GetFont("Calibri", 9, Font.NORMAL, Color.DARK_GRAY))));
    phrase.Add(new Paragraph(new Chunk("", FontFactory.GetFont("Calibri", 11, Font.NORMAL, Color.BLACK))));
    phrase.Add(new Chunk("\n\n" + "Providers self-report their information to CHPW on the application to join our network and is verified every three years thereafter. Additional updates are made at the provider’s request.", FontFactory.GetFont("Calibri", 10, Font.NORMAL, Color.DARK_GRAY)));

    table.SetWidths(new float[] { 350f });

    cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
    table.AddCell(cell);

    Font link = FontFactory.GetFont("Arial", 9, Font.UNDERLINE, new Color(79, 129, 189));

    document.Add(table);

    if (!string.IsNullOrWhiteSpace(request.DisclaimerText))
    {
        Anchor anchor = new Anchor(request.DisclaimerText, link) { };
        anchor.Reference = request.DisclaimerLink;
        Paragraph pDis = new Paragraph();
        pDis.IndentationLeft = 68f;
        pDis.Add(anchor);
        document.Add(pDis);
    }


    document.Close();
    return fileName;
}


Что я уже пробовал:

я пробовал использовать различные методы, но ни один из них, кажется, не работает...пожалуйста, помогите
1.
//нижний колонтитул

//публичный класс PDFFooter : PdfPageEventHelper
//{

// // пишем в конце каждой страницы
// общественного переопределить недействительными OnEndPage(PdfWriter писателя, документ )
// {
// база.OnEndPage(писатель, документ);
// PdfPTable celltable = new PdfPTable(new float[] { 1F });
// PdfPCell ячейка;
// celltable.Значение параметра totalwidth = 500F;
// cell = new PdfPCell(новая фраза("нижний колонтитул"));
// //cell = new PdfPCell(новая фраза("\n"));
// celltable.AddCell(ячейка);
// celltable.Расстояние до = 20f;
// celltable.WriteSelectedRows(0, -1, 20, document.Дно, писатель.DirectContent);

// }

//}


//нижний колонтитул конец
2.
//cell.AddElement(new Paragraph(Convert.ToString("to be continued")));
                    //table.AddCell(cell);                    
                    //cell.AddElement(new Paragraph("Continue on next page"));
                    //table.AddCell (cell);
                    //table.SkipFirstHeader = true;
                    //table.SkipLastFooter = true;

3.

                    //var wrapperTable = new PdfPTable(2);
                    //wrapperTable.DefaultCell.Border = Rectangle.NO_BORDER;
                    //wrapperTable.AddCell(phrase);
                    //cell.AddElement(wrapperTable);

1 Ответов

Рейтинг:
1

phil.o

Это, кажется, описывает вашу проблему и предлагает обходной путь:
Дубликат строки, поступающей на следующую страницу pdf - документа в iText[^]
Это для java-версии, но, возможно, и для нее .Чистая версия страдает той же проблемой.


jasmine jain

спасибо Phil.o но я уже пробовал использовать этот код(выше упомянутый - wrappertable) он не работает в .net,он полностью портит форматирование pdf и дублирует все данные n раз.

phil.o

Я подозреваю, что эта проблема никогда не будет исправлена, поскольку iText теперь перешел на платный продукт. Может быть, вы можете попробовать с версией сообщества?

jasmine jain

используя версию сообщества и попробуйте код здесь нет возможности, так как я использую профессиональную версию

phil.o

Тогда, может быть, вы поговорите с их командой поддержки, если у вас есть профессиональная версия?

jasmine jain

эта проблема решается с помощью последней версии itextsharp.dll(5.5.13). Спасибо, Фил.