From 8fc3fcd5614427dab6af17403bc8e653cac69435 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Tue, 11 Jun 2024 11:45:32 +0300 Subject: [PATCH] Add page titles --- .../word/WordBuilderImpl.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/WordBuilderImpl.java b/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/WordBuilderImpl.java index e26419d..f8b3d92 100644 --- a/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/WordBuilderImpl.java +++ b/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/WordBuilderImpl.java @@ -285,15 +285,19 @@ public class WordBuilderImpl implements WordBuilder { } private void createPages(List datasetProfilePages, PropertyDefinitionModel propertyDefinitionModel, XWPFDocument mainDocumentPart, VisibilityService visibilityService) { - datasetProfilePages.stream().filter(item -> item.getSections() != null).forEach(item -> { - try { - if (visibilityService.isVisible(item.getId(), null)) { - createSections(item.getSections(), propertyDefinitionModel, mainDocumentPart, 0, false, item.getOrdinal() + 1, null, visibilityService); + for (PageModel item : datasetProfilePages) { + if (item.getSections() != null) { + try { + XWPFParagraph paragraph = addParagraphContent(item.getOrdinal() + 1 + " " + item.getTitle(), mainDocumentPart, ParagraphStyle.HEADER5, numId, 0); + mainDocumentPart.getPosOfParagraph(paragraph); + if (visibilityService.isVisible(item.getId(), null)) { + createSections(item.getSections(), propertyDefinitionModel, mainDocumentPart, 1, false, item.getOrdinal() + 1, null, visibilityService); + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } } - } catch (Exception e) { - logger.error(e.getMessage(), e); } - }); } private boolean createSections(List sections, PropertyDefinitionModel propertyDefinitionModel, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, Integer page, String sectionString, VisibilityService visibilityService) {