Java 当数据长度增加时,ITEXT 7.0.4应用程序进入Infint循环

Java 当数据长度增加时,ITEXT 7.0.4应用程序进入Infint循环,java,spring-mvc,itext,itext7,Java,Spring Mvc,Itext,Itext7,我在使用iTEXT-7.0.4创建PDF时遇到了一个问题。当表行中的数据增加到某个限制时,程序将进入无限循环。我提供了适当的屏幕截图。如果你需要别的东西,请告诉我。我在我的项目中使用SpringMVC3 StudentReportCard.java private void getStudentAndInstituteDetailsReport(Document doc, StudentReportCardJson reportCardJson, Institution institute) {

我在使用iTEXT-7.0.4创建PDF时遇到了一个问题。当表行中的数据增加到某个限制时,程序将进入无限循环。我提供了适当的屏幕截图。如果你需要别的东西,请告诉我。我在我的项目中使用SpringMVC3

StudentReportCard.java

private void getStudentAndInstituteDetailsReport(Document doc, StudentReportCardJson reportCardJson, Institution institute) {
        Table table = new Table(UnitValue.createPercentArray(new float[] { 80, 20 })).useAllAvailableWidth();
        table.setWidth(UnitValue.createPercentValue(100));
        logger.info("inside main detail table");
        Table studentDetTable = new Table(UnitValue.createPercentArray(new float[] { 60 }), true).useAllAvailableWidth();
        logger.info("inside student detail table");
        studentDetTable.setWidth(UnitValue.createPercentValue(60));
        studentDetTable.setHorizontalAlignment(HorizontalAlignment.LEFT);
        logger.info("inside institute detail table");
        Table instituteDetTable = new Table(UnitValue.createPercentArray(new float[] { 20 })).useAllAvailableWidth();
        instituteDetTable.setWidth(UnitValue.createPercentValue(30));
        instituteDetTable.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        Paragraph reportDate = new Paragraph("Report Date: ").setTextAlignment(TextAlignment.LEFT).setFontSize(8f).setFontColor(Color.BLACK).setBold();
        Paragraph dateValue = new Paragraph(Utilities.getDisplaySqlDateInString(Utilities.getCurrentDate())).setFontSize(8f).setFontColor(Color.BLACK);

        studentDetTable.addCell(new Cell(0, 1).add(getHeadingAndTextFormatting("Student Name: ", reportCardJson.getStudentJson().getStudent_name())).setBorder(Border.NO_BORDER));
        if (institute.getCourse_structure_flag() == 1) {
            studentDetTable.addCell(new Cell(1, 1).add(getHeadingAndTextFormatting("Course(s): ", reportCardJson.getStudentJson().getAssignedCourses())).setBorder(Border.NO_BORDER));
        } else {
            studentDetTable.addCell(new Cell(0, 1).add("").setBorder(Border.NO_BORDER));
        }
    // This line of code creates infinite loop
        if (Utilities.isNotBlank(reportCardJson.getStudentJson().getBatchesAssigned())) {
            studentDetTable.addCell(new Cell(7, 1).add(getHeadingAndTextFormatting("Subject(s): ", reportCardJson.getStudentJson().getBatchesAssigned())).setBorder(Border.NO_BORDER));
        }
        if (Utilities.isNotBlank(reportCardJson.getStudentJson().getStudent_phone())) {
            studentDetTable.addCell(new Cell(0, 1).add(getHeadingAndTextFormatting("Contact No.: ", reportCardJson.getStudentJson().getStudent_phone())).setBorder(Border.NO_BORDER));
        }
        if (Utilities.isNotBlank(reportCardJson.getStudentJson().getStudent_email())) {
            studentDetTable.addCell(new Cell(0, 1).add(getHeadingAndTextFormatting("Email ID: ", reportCardJson.getStudentJson().getStudent_email())).setBorder(Border.NO_BORDER));
        }
        studentDetTable.addCell(new Cell(0, 1).add(getHeadingAndTextFormatting("Joining Date: ", reportCardJson.getStudentJson().getDoj())).setBorder(Border.NO_BORDER));
        studentDetTable.addCell(new Cell(0, 1).add(new Paragraph().add(reportDate).add(dateValue)).setBorder(Border.NO_BORDER));
        Style style = new Style();
        style.setFontColor(Color.BLACK).setFontSize(8f).setTextAlignment(TextAlignment.RIGHT);
        Cell instituteLogoCell = new Cell();
        if (Utilities.isNotBlank(institute.getLogo_url())) {
            ImageData data = null;
            try {
                data = ImageDataFactory.create(institute.getLogo_url());
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            if (data != null) {
                Image img = new Image(data);
                img.scaleAbsolute(60f, 30f);
                instituteLogoCell.add(img).setPaddingLeft(189f).setBorder(Border.NO_BORDER);
                // instituteLogoCell.setPaddingLeft(187f);
            }
        } else {
            instituteLogoCell.add("").setBorder(Border.NO_BORDER);
        }
        instituteDetTable.addCell(instituteLogoCell);
        instituteDetTable.addCell(new Cell(0, 1).add(institute.getInstitute_name()).addStyle(style).setBorder(Border.NO_BORDER));
        instituteDetTable.addCell(new Cell(0, 1).add(institute.getInstitute_primary_email()).addStyle(style).setBorder(Border.NO_BORDER));
        instituteDetTable.addCell(new Cell(0, 1).add(institute.getInstitute_primary_phone()).addStyle(style).setBorder(Border.NO_BORDER));
        table.addCell(new Cell().add(studentDetTable).setBorder(Border.NO_BORDER));
        logger.info("end student det table");
        table.addCell(new Cell().add(instituteDetTable).setBorder(Border.NO_BORDER));
        logger.info("end institute det table");
        doc.add(table);
        logger.info("end main det table");
    }

     private Paragraph getHeadingAndTextFormatting(String heading, String value) {
        Style style = new Style();
        style.setFontColor(Color.BLACK);
        style.setFontSize(7f);
        Paragraph headingValue = new Paragraph(heading).setFontColor(new DeviceRgb(107, 104, 132)).setFontSize(7f).setBold().setMarginBottom(0.0f).setMarginTop(0.0f);
        Paragraph text = new Paragraph(value).addStyle(style).setMarginBottom(0.0f).setMarginTop(0.0f);
        return new Paragraph().add(headingValue).add(text).setFixedLeading(16);
    }


在上面的代码中,reportCardJson.getStudentJson().getBatchesAssigned()使我的PDF进入无限循环


这是上面代码中的数据数据结构与算法、化学、OOP、人工智能操作与管理、数学、物理、软件测试与自动化测试、Java、DS

那么
reportCardJson.getStudentJson()中会发生什么呢
PDF处于无限循环中是什么意思?从提供的代码来看,根本没有循环。7.0.4是早期的itext 7版本。你试过新版本吗?可能您遇到了一个在较新版本中已修复的错误。也就是说,我是否正确理解您所指的是if(Utilities.isNotBlank(reportCardJson.getStudentJson().getBatchesAssigned())这一行{在你的评论中,这行代码创建了无限循环?@samabcde我知道我的代码中没有循环,但我想说的是,PDF正在不断生成,这会降低服务器的速度down@mkl不,我没有尝试使用较新的版本。是代码行(Utilities.isNotBlank(reportCardJson.getStudentJson().getBatchesAssigned())使PDF不断生成,从而降低服务器速度