Skip to content

Export file docx by template using docx4j output auto add "generated with Docx4j on Wildfly" to the footer #150

Description

@thangnm11

Blog post you are referring to

link blog: https://rieckpil.de/howto-generate-documents-from-word-templates-with-docx4j-on-wildfly-14/
link src code: https://github.com/rieckpil/blog-tutorials/tree/master/generate-documents-from-word-templates-with-docx4j-on-wildfly14

Expected Behavior

Show by template input.docx without add more in footer

Current Behavior

Show in footer of file output.docx "generated with Docx4j on Wildfly"

Steps to Reproduce

lib maven pom.xml

org.docx4j
docx4j-JAXB-Internal
8.0.0


org.docx4j
docx4j-JAXB-ReferenceImpl
8.0.0


org.docx4j
docx4j-JAXB-MOXy
8.0.0


org.docx4j
docx4j-export-fo
8.0.0

code java:
public static void generateDocxFileFromTemplate() throws Exception {
// TODO - ref: https://github.com/rieckpil/blog-tutorials/tree/master/generate-documents-from-word-templates-with-docx4j-on-wildfly14
InputStream templateInputStream = new FileInputStream("C:\Users\thangnm\Desktop\template (1).docx");

	WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(templateInputStream);

	MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();

	VariablePrepare.prepare(wordMLPackage);

	HashMap<String, String> variables = new HashMap<>();
	variables.put("firstName", "userInformation.getFirstName()");
	variables.put("lastName", "userInformation.getLastName()");
    variables.put("salutation", "userInformation.getSalutation()");
	variables.put("message", "userInformation.getMessage()");

	documentPart.variableReplace(variables);

	String outputfilepath = "C:\\Users\\thangnm\\Desktop\\template (2).docx";
	FileOutputStream os = new FileOutputStream(outputfilepath);

	wordMLPackage.save(os);
	os.flush();
	os.close();
}

Please help me, thanks!!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions