We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Words

Hello everyone,
I would like to understand if it is possible getting a text with html tags inside and render it in a TextView as a doc file.
I’m creating an app with an editor inside made with an EditText in which the user can insert some text and see it in a preview in another section of the app in a TextView.
The problem is that appears in the TextView not well formatted and with the newline chars not inserted in the correct place.
With your library is it possible to handle text files as doc files as the official Word does?


Hi Giorgio,

Thanks for your inquiry. Please note that Aspose.Words for Android is a class library and with it you can programmatically generate, modify, convert and render word processing documents. So, it does not offer any UI or control for performing these document processing tasks. However, if you’re intended to just preview your Word/Html document in your android application, we can offer you a simple way that will help you in achieving what you are looking for.

  1. Load your Word document into Aspose.Words for Android
  2. Generate images against each page in Word document and then view them in some android control.

Please see the following code that uses standard ImageView widget to show Aspose.Words generated images:

    String licString = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Aspose.Words.Android.lic";

    String inputPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/input.html";

    String outputPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
    com.aspose.words.License lic = new com.aspose.words.License();
    lic.setLicense(licString, this);

    com.aspose.words.Document doc = new com.aspose.words.Document(inputPath);

    com.aspose.words.ImageSaveOptions options = new com.aspose.words.ImageSaveOptions(SaveFormat.PNG);

    for (int i = 0; i < doc.getPageCount(); i++)
        doc.save(outputPath + "out_" + i + ".png", options);

    Bitmap bm = BitmapFactory.decodeFile(outputPath + "out_1.png");

    ImageView img = (ImageView)findViewById(R.id.imageView1);

catch (Exception e)

Hope, this helps.

Dear Tahir,
how the library performs the doc.getPageCount() operation? Does it know the page number?
If I have a string populated with text e html tags such the only way to render the document is to create an image for every page?

Thanks for the support
Best regards

Hi Giorgio,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does.

When Document.getPageCount is called, it invokes page layout, document is formatted into pages and returned the number of pages in the document.

Hi Tahir,
I downloaded the AsposeWords for android demo and I’m trying to implement your example.
Is the license file necessary also for the demo?
Is it possible instead of passing an html file to this “com.aspose.words.Document doc = new com.aspose.words.Document(inputPath);” passing directly a string populated with html tag?

Best regards

Hi Giorgio,
Thanks for your inquiry. We suggest you please request for 30-days temporary license from here:Get temporary license
Please use DocumentBuilder.InsertHtml method to insert an HTML string into the document as shown in following code snippet.

Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
        "<P align='right'>Paragraph right</P>" +
                "<b>Implicit paragraph left</b>" +
                "<div align='center'>Div center</div>" +
                "<h1 align='left'>Heading 1 left.</h1>");