Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
thangnm11 opened this issue Jan 4, 2023 · 1 comment

Comments

@thangnm11
Copy link

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!!!

@thangnm11
Copy link
Author

@rieckpil Please help me, thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant