1

I have a word document that I would like to have viewed as an image in order to zoom and scroll. How would I go about doing this, or if this is a dumb and complicated procedure, what is the best way of going about displaying large amounts of text to be scrollable and zoomable. The text is going to be primarily math equations. Thank you!

My problem is that it opens a browser and then said the file was not found. /mnt/sdcard/CheetSheetTest1Alg.html(No such file or directory)

    import java.io.File;
    import android.app.Activity;
    import android.content.Intent;
    import anrdoid.net.Uri;
    import android.os.Bundle;
    import android.os.Environment;

    public class CheatMathActivity extends Activity {

      public void onCreate(Bundle savedInstanceState){
          super,onCreate(savedInstanceState);
          setContentView(R.layout.main);

      File file = new File(Environment.getExternalStorageDirectory(), "CheetSheetTest1Alg.html:);
      Uri uri = Uri.fromFile(file);
      Intent intent = new Intent(Intent.ACTION_VIEW).setData(uri);
      intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
      startActivity(intent);
     }
     }
Easy
  • 159
  • 1
  • 2
  • 11
  • By "word document" do you mean it's in Microsoft Word format? If not, in which format is the text? – Dheeraj Vepakomma Mar 21 '12 at 17:02
  • Currently it is in Microsoft Word format, but I can put it in any format that would be easiest – Easy Mar 21 '12 at 17:06
  • The spelling of "/mnt/sdcard/CheetSheatTest1Alg.html" is not the same as in the code "CheetSheetTest1Ald.html". Notice the 'Sheat' and 'Alg' parts. You use a simple name like "test.html" for this test. – Dheeraj Vepakomma Mar 26 '12 at 17:40
  • Thank you for noticing that @Dheeraj, I checked and made sure it was correct in my actual code and it still gives me the same error. How do I place the .html file into the "/mnt/sdcard" ? – Easy Mar 27 '12 at 17:17
  • Use a tool like the File Explorer in DDMS "Device" menu, or use `adb push` in the command prompt. – Dheeraj Vepakomma Mar 27 '12 at 19:39

1 Answers1

2

Convert the Word document to an HTML file. This can be done by choosing the HTML type in the "Save as" dialog in MS Word.

Then you can either display it using the web browser or using a WebView inside your app. The default Android web browser already supports pinch zoom and scroll.

To open the HTML file on your SDCard using the Android web browser from your app, use the following code:

File file = new File(Environment.getExternalStorageDirectory(), "document.html");
Uri uri = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW).setData(uri);
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
startActivity(intent);
Dheeraj Vepakomma
  • 26,870
  • 17
  • 81
  • 104
  • Thank you for this suggestion. Is there a way of doing it locally? – Easy Mar 21 '12 at 17:32
  • I am having trouble utilizing the code above. Is there a way you can guide me through this? If not I completely understand, your help so far is very much appreciated – Easy Mar 26 '12 at 16:52
  • @Easy, edit your question to include the code you've written so far and exactly what part you do not understand. – Dheeraj Vepakomma Mar 26 '12 at 17:03
  • you have been a huge help but I'm still having problems. I am using the Equations in Word 2007, and after saving as an html file the equations do not show up upon opening. Is there another way of displaying this text with the ability of scrolling and zooming? Thank you very much – Easy Apr 03 '12 at 17:18
  • @Easy, if you can upload the Word doc with sample equations to [a hosting site](http://www.filehosting.org/), I'll see what I can do. – Dheeraj Vepakomma Apr 03 '12 at 18:18
  • @Easy, the Word doc uses Microsoft specific XML representation for displaying math. That would not work in browsers. There are open formats like `MathML` but rendering support is limited. See [this question](http://stackoverflow.com/questions/1784786/mathml-and-java). – Dheeraj Vepakomma Apr 05 '12 at 15:43
  • Alright after some researching I was able to make my equations a working web page. I am not understanding how this is will be put onto the sdcard in the first place. – Easy Apr 17 '12 at 02:34
  • @Easy, In the notifications area click on the "USB Connected" notification and then click the "Turn on USB storage". The SD card would now appear as a drive on your PC. – Dheeraj Vepakomma Apr 17 '12 at 04:52
  • Ok but how will this be sent out with the app so that when it is downloaded from the market the webpage will be put on the sdcard? – Easy Apr 18 '12 at 02:18
  • @Easy if the app needs to be published, you should package the html files as "raw" resources in the "res" folder. You can then use [resource APIs](http://developer.android.com/reference/android/content/res/Resources.html#openRawResource(int)) to retrieve them. This discussion is going way out of scope of the original question. If you still face issues, please post a new question and you'll get help. Good luck! – Dheeraj Vepakomma Apr 18 '12 at 09:36