how to Show or Read docx file

前端 未结 3 1053
-上瘾入骨i
-上瘾入骨i 2020-12-16 18:07

I am new to rendering files in android, and I want to render or display a docx file in my application.

I had already extract text from docx file, but now I want to e

相关标签:
3条回答
  • 2020-12-16 18:33

    Have a look at AndroidDocxToHtml, which I made to demonstrate using docx4j on Android.

    A couple of caveats.

    First, that project does not include all docx4j dependencies, only the ones required for docx to HTML conversion. So if you want to do other things, you may need others of the dependencies.

    Second, docx4j requires JAXB - see this blog post re JAXB on Android - and JAXB context init on app startup takes a while depending on the device. There are ways to work around this, but at extra effort.

    If all you want to do is extract the images, and you don't care how they relate to the text, you could just look for image parts. You might use OpenXML4J for that, and avoid JAXB.

    0 讨论(0)
  • 2020-12-16 18:45

    The easiest way to create an image in Android is to use the BitmapFactory factory methods.

    The BitmapFactory class has methods for creating a Bitmap from a byte array, a file or an InputStream.

    Once you have a Bitmap object you can display it by setting it on an ImageView in your layout using the setImageBitmap method.

    0 讨论(0)
  • 2020-12-16 18:47

    You can just unzip the file (rename to .zip and open it) then you can investigate the folder structure, where the images are located etc.

    0 讨论(0)
提交回复
热议问题