docx4j icon indicating copy to clipboard operation
docx4j copied to clipboard

Some settings are not taken into account (image directory)

Open toki07 opened this issue 2 years ago • 0 comments

When redefining the image directory path, some images are still in the default directory.

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File("/some/docxfile.docx"));
FOSettings foSettings = new FOSettings(wordMLPackage);
foSettings.setImageDirPath("/custom_temporary_directory");
foSettings.setApacheFopMime(FOSettings.INTERNAL_FO_MIME);

ByteArrayOutputStream os = new ByteArrayOutputStream();
Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);

This is caused by FOPAreaTreeHelper.java :

Document getAreaTreeViaFOP(WordprocessingMLPackage hfPkg, boolean useXSLT, FOSettings foSettingsOverall) throws Docx4JException, ParserConfigurationException, SAXException, IOException  {

FOSettings foSettingsHere = Docx4J.createFOSettings();
foSettingsHere.setFopConfig(foSettingsOverall.getFopConfig());

foSettingsHere use only some of the redefined settings from foSettingsOverall. And thus use the default directory for image generation.

toki07 avatar Oct 18 '22 08:10 toki07