doc.isModified() returns true after a document is created, only

59 views
Skip to first unread message

Ron Allan

unread,
Feb 25, 2015, 12:32:02 PM2/25/15
to pdfne...@googlegroups.com
Using the Android 'PDFNetAndroid-6.3.2.27718' SDK

I am attempting to distinguish when a document has been modified so that I can prompt the user to save on exit. I am finding that doc.isModified() returns true immediately after being created:

PDFDoc doc = new PDFDoc();

if(doc != null) {

    Log.d(TAG, "IS DOC MODIFIED: " + doc.isModified());

 }

Log Contents:

IS DOC MODIFIED: true

-------

Is there a reason it returns true prior to any modifications to the actual document? Is there a way to tell when the document has been modified through the API?

Thanks in advance.

Ron

Ryan

unread,
Feb 26, 2015, 6:27:47 PM2/26/15
to pdfne...@googlegroups.com
When a document is loaded by PDFNet it might have to repair the document. This is why IsModified may return true before you do anything.

Here is how you can test for a repaired file

PDFDoc doc = new PDFDoc(path);
m_repaired = doc.IsModified(); // call before anything else
doc.InitSecurityHandler();

It is probably best to track your own variable for user made changes, and only prompt for save if user made a change themselves. This how typical PDF reader apps work.

Reply all
Reply to author
Forward
0 new messages