Hi
I have an app which reads bookmark content from a DOC file into EditText controls. The user then updates these. To give users an opportunity to preview the result in the document, there is a ViewActivity activity. This uses a copy of the Document object saved in memory, updates the bookmark content from the EditText values, and calls renderToScale on the Document. This is implemented in the overridden onDraw method of a custom extended View object (RenderView) which has been added to the layout of ViewActivity. The onResume method of ViewActivity performs the document manipulation and calls postInvalidate on the RenderView object.
The first time the ViewActivity activity is started, this works as I had planned, rendering the document with updated content. ViewActivity is then closed using the ‘back’ function, and further changes are made to the EditTexts. ViewActivity is started again, but this time the document is rendered without the most recent updates. Having stepped through it in the debugger, the Document content appears to be correct (i.e. bookmarks updated) at the point where renderToScale is called. On this occasion, renderToScale returns instantaneously, compared with a delay of a few seconds in the prior call. It seems as though renderToScale is doing nothing in this second launch of ViewActivity.
Any ideas about what may be going wrong here?
Thanks
Keith
Hi Keith,
Thanks for your inquiry and sorry for the delayed response. To ensure a timely and accurate response, it would be great if you please create a standalone/runnable simple android application (source code) that helps me reproduce your problem on my end and attach it here for testing. Please also attach the sample document(s) your application uses. As soon as you get this simple application ready for me, I’ll start investigation into your issue and provide you more information.
Best regards,
Hi Awais
I have created a small app to show what I mean. The project for eclipse is in the attached zip file.
The ViewActivity.java and activity_view.xml are exactly as in my app, the other classes have been stripped down.
There is also a SRTemplate.doc file in the zip, which you can copy to any convenient folder on the target device.
So, build the app and run it. Open the menu and go to Settings; put in the full path name for your saved copy of SRTemplate.doc.
Now press the “Load” button. The four EditText controls should be populated with text from the 4 bookmarks in the doc file.
Modify the contents of one of the EditText and press the “View” Button. The ViewActivity will be launched and should show the document with the changes you just made (long delay if debugging).
Press the device back-button to return to the main activity. Now modify the contents of another EditText and press “View”. The ViewActivity will launch again, but this time you will only see the first changes made, not the latest ones. That is, exactly the same image as previously.
I have placed a line of code at line 60 in ViewActivity.java so that if you step through with a debugger, you can confirm that the Document object has indeed been updated with the changed text, even though it does not seem to render.
So, renderToScale does not appear to be rendering the current state of the Document object each time that it is called.
Best regards
Keith
Hi Keith,
Thanks for supplying a detailed description. In “ViewActivity.java”, please add the “Global.doc.updatePageLayout();” statement before “renderToScale” method call to fix this issue:
https://reference.aspose.com/words/java/com.aspose.words/document#updatePageLayout()
Best regards,