Skip to content

Commit

Permalink
[Android] Expose getSavedSignatureJpgFolder (#377)
Browse files Browse the repository at this point in the history
* (Android) expose getSavedSignatureJpgFolder

* bump ver
  • Loading branch information
akwanpdf authored Sep 9, 2021
1 parent dd0ccfb commit 28715fb
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
25 changes: 24 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -3124,7 +3124,9 @@ this._viewer.getSavedSignatures().then((signatures) => {
```

#### getSavedSignatureFolder
Retrieves the absolute file path to the folder containing the saved signatures
Retrieves the absolute file path to the folder containing the saved signature PDFs.

For Android, to get the folder containing the saved signature JPGs, use [`getSavedSignatureJpgFolder`](#getSavedSignatureJpgFolder).

Returns a Promise.

Expand All @@ -3142,6 +3144,27 @@ this._viewer.getSavedSignatureFolder().then((path) => {
})
```

#### getSavedSignatureJpgFolder
Retrieves the absolute file path to the folder containing the saved signature JPGs. Android only.

To get the folder containing the saved signature PDFs, use [`getSavedSignatureFolder`](#getSavedSignatureFolder).

Returns a Promise.

Promise Parameters:

Name | Type | Description
--- | --- | ---
path | string | the absolute file path to the folder

```js
this._viewer.getSavedSignatureJpgFolder().then((path) => {
if (path != null) {
console.log(path);
}
})
```

### Others

#### exportAsImage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,21 @@ public void run() {
});
}

@ReactMethod
public void getSavedSignatureJpgFolder(final int tag, final Promise promise) {
getReactApplicationContext().runOnUiQueueThread(new Runnable() {
@Override
public void run() {
try {
String result = mDocumentViewInstance.getSavedSignatureJpgFolder(tag);
promise.resolve(result);
} catch (Exception e) {
promise.reject(e);
}
}
});
}

@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
mDocumentViewInstance.onActivityResult(requestCode, resultCode, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,15 @@ public String getSavedSignatureFolder(int tag) throws PDFNetException {
}
}

public String getSavedSignatureJpgFolder(int tag) throws PDFNetException {
DocumentView documentView = mDocumentViews.get(tag);
if (documentView != null) {
return documentView.getSavedSignatureJpgFolder();
} else {
throw new PDFNetException("", 0L, getName(), "getSavedSignatureJpgFolder", "Unable to find DocumentView.");
}
}

@Override
public boolean needsCustomLayoutForChildren() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4213,6 +4213,15 @@ public String getSavedSignatureFolder() {
}
return "";
}

public String getSavedSignatureJpgFolder() {
Context context = getContext();
if (context != null) {
File file = StampManager.getInstance().getSavedSignatureJpgFolder(context);
return file.getAbsolutePath();
}
return "";
}

public void setSaveStateEnabled(boolean saveStateEnabled) {
mSaveStateEnabled = saveStateEnabled;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-native-pdftron",
"title": "React Native Pdftron",
"version": "2.0.3-beta.180",
"version": "2.0.3-beta.181",
"description": "React Native Pdftron",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/DocumentView/DocumentView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,14 @@ export default class DocumentView extends PureComponent {
return Promise.resolve();
}

getSavedSignatureJpgFolder = () => {
const tag = findNodeHandle(this._viewerRef);
if (tag != null) {
return DocumentViewManager.getSavedSignatureJpgFolder(tag);
}
return Promise.resolve();
}

_setNativeRef = (ref) => {
this._viewerRef = ref;
};
Expand Down

0 comments on commit 28715fb

Please sign in to comment.