We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When I run code to covert html to Doc (like in org.docx4j.samples.ConvertInXHTMLFile) I get a document with extra spaces and paragraphs F.e., my html:
<!DOCTYPE html> <html> <head> <style> i { color: red; background-color: gray; } </style> </head> <body> <div> some text <span>new text</span> </div> </body> </html>
Document:
Source code:
public static void main(String[] args) throws Exception { // org.docx4j.samples.ConvertInXHTMLFile String baseURL = null; String stringFromFile = getContent(); /*RFonts rfonts = Context.getWmlObjectFactory().createRFonts(); rfonts.setAscii("Century Gothic"); XHTMLImporterImpl.addFontMapping("Century Gothic", rfonts);*/ WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(); NumberingDefinitionsPart ndp = new NumberingDefinitionsPart(); wordMLPackage.getMainDocumentPart().addTargetPart(ndp); ndp.unmarshalDefaultNumbering(); XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage); XHTMLImporter.setHyperlinkStyle("Hyperlink"); List<Object> convert = XHTMLImporter.convert(stringFromFile, baseURL); wordMLPackage.getMainDocumentPart().getContent().addAll(convert); System.out.println(XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getJaxbElement(), true, true)); wordMLPackage.save(new File("docs/a.docx")); }
<dependency> <groupId>org.docx4j</groupId> <artifactId>docx4j-ImportXHTML</artifactId> <version>8.3.2</version> </dependency>
The text was updated successfully, but these errors were encountered:
What does your getContent() do?
Can't reproduce, using ConvertInXHTMLFile sample code, which uses:
String stringFromFile = FileUtils.readFileToString(new File(inputfilepath), "UTF-8");
Sorry, something went wrong.
No branches or pull requests
When I run code to covert html to Doc (like in org.docx4j.samples.ConvertInXHTMLFile) I get a document with extra spaces and paragraphs
F.e., my html:
Document:
Source code:
The text was updated successfully, but these errors were encountered: