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

Android/Gradle StyleDefinitionsPart.getCss()' on a null object reference #70

Open
gilshallem opened this issue Jan 17, 2021 · 1 comment

Comments

@gilshallem
Copy link

gilshallem commented Jan 17, 2021

Hi
I'm trying to convert html to docx on android

My dependencies definition (.gradle):

implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'javax.xml.stream:stax-api:1.0-2'
implementation 'com.fasterxml:aalto-xml:1.2.2'
implementation('org.docx4j:docx4j-ImportXHTML:8.0.0'){
    exclude module: 'commons-io'
}

Code:

WordprocessingMLPackage docxOut = WordprocessingMLPackage.createPackage();
XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(docxOut);
htmlString = "<html><head><title></title></head><body>hi</body></html>";
docxOut.getMainDocumentPart().getContent().addAll(
XHTMLImporter.convert(htmlString, null) );

Error:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart.getCss()' on a null object reference
        at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.stylesToCSS(XHTMLImporterImpl.java:460)
        at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.getRenderer(XHTMLImporterImpl.java:271)
        at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.convert(XHTMLImporterImpl.java:663)

PLEASE HELP :)

@plutext plutext changed the title WordprocessingML.StyleDefinitionsPart.getCss()' on a null object reference Android/Gradle WordprocessingML.StyleDefinitionsPart.getCss()' on a null object reference Jan 17, 2021
@plutext
Copy link
Owner

plutext commented Jan 17, 2021

Can't reproduce in Java env with either ImportXHTML:8.0.0 or ImportXHTML:8.2.0

@plutext plutext changed the title Android/Gradle WordprocessingML.StyleDefinitionsPart.getCss()' on a null object reference Android/Gradle StyleDefinitionsPart.getCss()' on a null object reference Jan 17, 2021
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

2 participants