1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/dromara-x-easypdf

 / Детали:

При последовательном создании двух таблиц, вторая таблица может частично覆盖 первоначально созданной...

Предстоит сделать
Владелец
Создано  
03.03.2025

таблицей данные. Корректный перевод будет следующим: При последовательном создании двух таблиц, вторая таблица может частично перекрывать данные первой созданной таблицы.

Используемая версия:

org.dromara.x-easypdf
x-easypdf
3.2.1

public static void main(String[] args) {
    Document document = PdfHandler.getDocumentHandler().create();
    document.setMargin(20F);
    Page page = new Page(document);
    Table table = new Table(document.getCurrentPage());
    // Ширина таблицы
    float width = page.getWithoutMarginWidth() / 24;
    float height = 20F;
    table.setCellWidths(width * 3, width * 12, width * 3, width * 6);
    table.setBackgroundColor(new Color(244, 249, 239));
    table.setMarginTop(5f);
    table.setIsBorder(true);
    TableRow tableRow = new TableRow(table);
    tableRow.setHeight(height);
    tableRow.setContentVerticalAlignment(VerticalAlignment.CENTER);
    // Номер
    Textarea serialNumberTxt = new Textarea(document.getCurrentPage());
    serialNumberTxt.setText("Номер:");
    serialNumberTxt.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    serialNumberTxt.setFontColor(new Color(134, 5, 5));

    TableCell serialNumberTxtCell = new TableCell(tableRow);
    serialNumberTxtCell.addComponents(serialNumberTxt);
    serialNumberTxtCell.setContentHorizontalAlignment(HorizontalAlignment.RIGHT);

    // Номер
    Textarea serialNumberVal = new Textarea(document.getCurrentPage());
    serialNumberVal.setText("7e8f6a2b-9f32-42d8-b317-0b8cb20eb482");
    serialNumberVal.setHorizontalAlignment(HorizontalAlignment.LEFT);

    TableCell serialNumberValCell = new TableCell(tableRow);
    serialNumberValCell.addComponents(serialNumberVal);

    // Время проверки
    Textarea detectionTimeTxt = new Textarea(document.getCurrentPage());
    detectionTimeTxt.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    detectionTimeTxt.setFontColor(new Color(134, 5, 5));

    TableCell detectionTimeTxtCell = new TableCell(tableRow);
    detectionTimeTxtCell.addComponents(detectionTimeTxt);
    detectionTimeTxtCell.setContentHorizontalAlignment(HorizontalAlignment.RIGHT);

    // Время проверки
    Textarea detectionTimeVal = new Textarea(document.getCurrentPage());
    detectionTimeVal.setText("2023-09-12 16:45:00");
    detectionTimeVal.setHorizontalAlignment(HorizontalAlignment.RIGHT);

    TableCell detectionTimeValCell = new TableCell(tableRow);
    detectionTimeValCell.addComponents(detectionTimeVal);

    TableRow tableRow1 = new TableRow(table);
    tableRow1.setHeight(height);
    tableRow1.setContentVerticalAlignment(VerticalAlignment.CENTER);

    // Отправившаяся на проверку организация
    Textarea inspectionUnitTxt = new Textarea(document.getCurrentPage());
    inspectionUnitTxt.setText("Отправившаяся на проверку организация:");
    inspectionUnitTxt.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    inspectionUnitTxt.setFontColor(new Color(134, 5, 5));

    TableCell inspectionUnitTxtCell = new TableCell(tableRow1);
    inspectionUnitTxtCell.addComponents(inspectionUnitTxt);
    inspectionUnitTxtCell.setContentHorizontalAlignment(HorizontalAlignment.RIGHT);

    // Отправившаяся на проверку организация
    Textarea inspectionUnitVal = new Textarea(document.getCurrentPage());
    inspectionUnitVal.setText("тест тест");
    inspectionUnitVal.setHorizontalAlignment(HorizontalAlignment.LEFT);

    TableCell inspectionUnitValCell = new TableCell(tableRow1);
    inspectionUnitValCell.addComponents(inspectionUnitVal);

    tableRow.addCells(serialNumberTxtCell, serialNumberValCell, detectionTimeTxtCell, detectionTimeValCell);
    tableRow1.addCells(inspectionUnitTxtCell, inspectionUnitValCell, new TableCell(tableRow1), new TableCell(tableRow1));

    table.setRows(tableRow, tableRow1, tableRow1);
    table.render();

    Table tableInfo = new Table(document.getCurrentPage());
    tableInfo.setIsBorder(true);
    tableInfo.setCellWidths(24 * width);
    TableRow tableRowInfo = new TableRow(tableInfo);
    tableRowInfo.setHeight(height);

    Textarea txtInfo = new Textarea(document.getCurrentPage());
    txtInfo.setText("тест");
    TableCell tableCell = new TableCell(tableRowInfo);
    tableCell.addComponents(txtInfo);

    tableRowInfo.addCells(tableCell);
    tableInfo.addRows(tableRowInfo);
    tableInfo.render();

    document.appendPage(page);
    document.save("D:\\ideaWork\\xCheckerV2\\smartGenReportPDFBox\\src\\test\\simpleContainerTest1.pdf");
    document.close();
}

Комментарий (0)

GitLife Service Account Задача создана

Вход Перед тем как оставить комментарий

Статус
Ответственный
Контрольная точка
Pull Requests
Связанные запросы на слияние могут быть закрыты после их объединения
Ветки
Дата начала   -   Крайний срок
-
Закрепить/Открепить
Приоритет
Участники(1)
1
https://api.gitlife.ru/oschina-mirror/dromara-x-easypdf.git
git@api.gitlife.ru:oschina-mirror/dromara-x-easypdf.git
oschina-mirror
dromara-x-easypdf
dromara-x-easypdf