From e0c5e4a955b019938eb09b12116d6a8552a30d60 Mon Sep 17 00:00:00 2001 From: gkolokythas Date: Wed, 30 Oct 2019 18:21:04 +0200 Subject: [PATCH] Fixes bug on DMP and Dataset docx export, removing the upper empty element. --- .../eudat/logic/managers/DataManagementPlanManager.java | 8 ++++++++ .../main/java/eu/eudat/logic/managers/DatasetManager.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 8c204a44d..ddc784d52 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -272,6 +272,14 @@ public class DataManagementPlanManager { // Page break at the end of the Dataset. XWPFParagraph parBreakDataset = document.createParagraph(); }); + + // Removes the top empty headings. + document.removeBodyElement(0); + document.removeBodyElement(0); + document.removeBodyElement(0); + document.removeBodyElement(0); + document.removeBodyElement(0); + String fileName = dmpEntity.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); File exportFile = new File(fileName + ".docx"); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index 37c8504db..ba2fd91f1 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -263,6 +263,14 @@ public class DatasetManager { wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService); String label = datasetEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", ""); File exportFile = new File(label + ".docx"); + + // Removes the top empty headings. + document.removeBodyElement(0); + document.removeBodyElement(0); + document.removeBodyElement(0); + document.removeBodyElement(0); + document.removeBodyElement(0); + FileOutputStream out = new FileOutputStream(exportFile); document.write(out); out.close();