I want to display word doc file, it should be from within app.
Hi Pratibha,
- Load your Word document into Aspose.Words for Android
- Generate images against each page in Word document and then view them in some android control.
try
{
String licString = Environment.getExternalStorageDirectory().getAbsolutePath() + “/Aspose.Words.Android.lic”;
String inputPath = Environment.getExternalStorageDirectory().getAbsolutePath() + “/input.docx”;
String outputPath = Environment.getExternalStorageDirectory().getAbsolutePath() + “/”;com<font color="BLUE"><b>.</b></font>aspose<font color="BLUE"><b>.</b></font>words<font color="BLUE"><b>.</b></font>License lic <font color="BLUE">=</font> <font color="RED"><b>new</b></font> com<font color="BLUE"><b>.</b></font>aspose<font color="BLUE"><b>.</b></font>words<font color="BLUE"><b>.</b></font>License<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> lic<font color="BLUE"><b>.</b></font>setLicense<font color="BLUE"><b>(</b></font>licString<font color="BLUE"><b>,</b></font> <font color="RED"><b>this</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> com<font color="BLUE"><b>.</b></font>aspose<font color="BLUE"><b>.</b></font>words<font color="BLUE"><b>.</b></font>Document doc <font color="BLUE">=</font> <font color="RED"><b>new</b></font> com<font color="BLUE"><b>.</b></font>aspose<font color="BLUE"><b>.</b></font>words<font color="BLUE"><b>.</b></font>Document<font color="BLUE"><b>(</b></font>inputPath<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> com<font color="BLUE"><b>.</b></font>aspose<font color="BLUE"><b>.</b></font>words<font color="BLUE"><b>.</b></font>ImageSaveOptions options <font color="BLUE">=</font> <font color="RED"><b>new</b></font> com<font color="BLUE"><b>.</b></font>aspose<font color="BLUE"><b>.</b></font>words<font color="BLUE"><b>.</b></font>ImageSaveOptions<font color="BLUE"><b>(</b></font>SaveFormat<font color="BLUE"><b>.</b></font>PNG<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> options<font color="BLUE"><b>.</b></font>setPageCount<font color="BLUE"><b>(</b></font><font color="BROWN">1</font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> <font color="RED"><b>for</b></font> <font color="BLUE"><b>(</b></font><font color="RED"><b>int</b></font> i <font color="BLUE">=</font> <font color="BROWN">0</font><font color="BLUE"><b>;</b></font> i <font color="BLUE"><</font> doc<font color="BLUE"><b>.</b></font>getPageCount<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> i<font color="BLUE"><font color="BLUE">+</font><font color="BLUE">+</font></font><font color="BLUE"><b>)</b></font> <font color="BLUE"><b>{</b></font> options<font color="BLUE"><b>.</b></font>setPageIndex<font color="BLUE"><b>(</b></font>i<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> doc<font color="BLUE"><b>.</b></font>save<font color="BLUE"><b>(</b></font>outputPath <font color="BLUE">+</font> <font color="PURPLE">"out_"</font> <font color="BLUE">+</font> i <font color="BLUE">+</font> <font color="PURPLE">".png"</font><font color="BLUE"><b>,</b></font> options<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> <font color="BLUE"><b>}</b></font> Bitmap bm <font color="BLUE">=</font> BitmapFactory<font color="BLUE"><b>.</b></font>decodeFile<font color="BLUE"><b>(</b></font>outputPath <font color="BLUE">+</font> <font color="PURPLE">"out_1.png"</font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> ImageView img <font color="BLUE">=</font> <font color="BLUE"><b>(</b></font>ImageView<font color="BLUE"><b>)</b></font>findViewById<font color="BLUE"><b>(</b></font>R<font color="BLUE"><b>.</b></font>id<font color="BLUE"><b>.</b></font>imageView1<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> img<font color="BLUE"><b>.</b></font>setImageBitmap<font color="BLUE"><b>(</b></font>bm<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font>
}
catch (Exception e)
{
e.printStackTrace();
}
Thanks Awais,it really helpful for me.But when i integrate this code into my code then it will give me the following error.
Error:(97, 45) error: cannot access zzF4
class file for asposewobfuscated.zzF4 not found
Error:Execution failed for task ‘:app:compileDebugJavaWithJavac’.
> Compilation failed; see the compiler error output for details.
I have attached my MainActivity.java file here for reference.
Hi Pratibha,
- Extract attached “dex2jar.zip” to ""C:\dex2jar"
- Go to “~\HelloWorld\app\src\main\assets” folder in “HelloWorld” project and copy “aspose-words-1.12-libs-android-jdk16.apk” to “C:\dex2jar” folder
- Open “aspose-words-1.12-libs-android-jdk16.apk” with WinRar and extract “classes.dex” file to "C:\dex2jar"
- Open command prompt in Windows and enter the following commands
- C:\WINDOWS\system32>cd/
- C:>cd dex2jar
- C:\dex2jar>d2j-dex2jar.bat c:\dex2jar\classes.dex
- dex2jar c:\dex2jar\classes.dex -> .\classes-dex2jar.jar
- C:\dex2jar>
- Now we have “classes-dex2jar.jar” which contains all the obfuscated classes
- Copy this .jar to “~\HelloWorld\app\libs” folder of “HelloWorld” project
- Now in Android Studio go to “Project Structure” of “HelloWorld” project
- Under “Modules”, select “app” and go to “Dependencies” tab
- Click ‘+’ and add a file dependency for "~\HelloWorld\app\libs\classes-dex2jar.jar"
- Under “Scope” column choose “Provided” value for this .jar and click OK and “Rebuild Project”.
Thanks Awais for this solution , i have follow all this step one by one and run the program but i have cought one error,
2 errors; aborting
Error:Execution failed for task ‘:app:preDexDebug’.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java’’ finished with non-zero exit value 1
How to solved this error? It is really end towards to fix the problem, Could you please help on this.
Hi Pratibha,
Thanks Awais for patiently providing your valuable help, i have follow all this steps one by one.
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72310Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2310Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72310Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42310Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug
Uncaught translation error: com.android.dx.cf.code.SimException: expected type int[] but found float[]
Uncaught translation error: com.android.dx.cf.code.SimException: expected type int[] but found float[]
2 errors; aborting
Error:Execution failed for task ‘:app:preDexDebug’.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java’’ finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 31.258 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
When i extracting that classes-dex2jar.jar file than through JD-GUI i open that file it contains one folder,i have attached that screen shot here:
asposewobfuscated
Hi Pratibha,
Thanks Awais, I’m using Android studio.
I have attached zip file of my project.
Hi Pratibha,
Hi Awais,actually i’m developing one small application and i’m still stuck with above mention problem.
So,is there is any solution for this above mention problem?
Hi Pratibha,
Thanks Awais.
Hello,
The issues you have found earlier (filed as WORDSANDROID-194) have been fixed in this Aspose.Words for Android 17.2.0 update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(7)