File Operations#
There are a number of file operations available against a document, an application developer should only be required to implement these if using the Custom UI.
Save#
Saving a document only needs to be invoked if there are changes made to a document. As such an application developer can verify if changes have been made or not and act accordingly.
if (documentView.isDocumentModified {
documentView.save()
}
if (documentView.isDocumentModified()) {
documentView.save();
}
Save As#
When saving a document using this method an application developer must provide a valid path on the file system to save to.
val docPath:String = "<YOUR_DOCUMENT_PATH>"
documentView.saveTo(docPath) { result, err ->
if (result == SODocSaveListener.SODocSave_Succeeded) {
// success
} else {
// error
}
}
String docPath = "<YOUR_DOCUMENT_PATH>";
documentView.saveTo(newPath, new SODocSaveListener() {
@Override
public void onComplete(int result, int err) {
if (result == SODocSave_Succeeded) {
// success
} else {
// error
}
}
});
Export#
It is possible to export the content of a PDF into an external text file for simple text extraction. To do so an application developer should define a valid file path to use with the exportToAPI
.
documentView.exportTo("filePath", "txt") { result, err ->
if (result == SODocSaveListener.SODocSave_Succeeded) {
// success
} else {
// error
}
}
documentView.exportTo("filePath", "txt", (result, err) -> {
if (result == SODocSaveListener.SODocSave_Succeeded) {
// success
} else {
// error
}
});
Note
At present the only valid format to export to is a text file, so the format parameter should always be set to “txt”.
Further formats will become available later.
Print#
Application developers should call the print()
method against the DocumentView
instance to open up the print dialog.
documentView.print()
documentView.print();
Search#
Searching is invoked from the current document selection or cursor position and can be made forward or backward from this point. Successful searching automatically highlights the next instance of a found String and moves the document selection to that point.
Note
Search is case-insensitive.
fun search(text:String, forward:Boolean) {
if (forward) {
documentView.searchForward(text)
} else {
documentView.searchBackward(text)
}
}
private void search(String text, Boolean forward) {
if (forward) {
documentView.searchForward(text);
} else {
documentView.searchBackward(text);
}
}
This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of that license. Refer to licensing information at artifex.com or contact Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, CA 94129, USA, for further information.