Fixes bug on DMP and Dataset docx export, removing the upper empty element.

This commit is contained in:
gkolokythas 2019-10-30 18:21:04 +02:00
parent 1911670ea3
commit e0c5e4a955
2 changed files with 16 additions and 0 deletions

View File

@ -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");

View File

@ -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();