|
@@ -66,9 +66,21 @@ class RCTCPDFView: UIView {
|
|
|
// MARK: - Public Methods
|
|
|
|
|
|
func saveDocument(completionHandler: @escaping (Bool) -> Void) {
|
|
|
- let document = self.pdfViewController?.pdfListView?.document
|
|
|
- let success = document?.write(to: document?.documentURL ?? URL(fileURLWithPath: ""), isSaveFontSubset: true) ?? false
|
|
|
- completionHandler(success)
|
|
|
+ if (self.pdfViewController?.pdfListView?.isEditing() == true && self.pdfViewController?.pdfListView?.isEdited() == true) {
|
|
|
+ self.pdfViewController?.pdfListView?.commitEditing()
|
|
|
+
|
|
|
+ if self.pdfViewController?.pdfListView?.document.isModified() == true {
|
|
|
+ let document = self.pdfViewController?.pdfListView?.document
|
|
|
+ let success = document?.write(to: document?.documentURL ?? URL(fileURLWithPath: ""), isSaveFontSubset: true) ?? false
|
|
|
+ completionHandler(success)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if self.pdfViewController?.pdfListView?.document.isModified() == true {
|
|
|
+ let document = self.pdfViewController?.pdfListView?.document
|
|
|
+ let success = document?.write(to: document?.documentURL ?? URL(fileURLWithPath: ""), isSaveFontSubset: true) ?? false
|
|
|
+ completionHandler(success)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// MARK: - RCT Methods
|