Skip to content

Commit 4f104ee

Browse files
author
Rad Azzouz
committed
Delete the processed document if it already exists in the Catalog example
1 parent 3ecf2fa commit 4f104ee

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

samples/Catalog/Catalog.ios.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,12 @@ class AnnotationProcessing extends Component {
10571057
onPress={async () => {
10581058
const processedDocumentPath =
10591059
RNFS.DocumentDirectoryPath + "/embedded.pdf";
1060+
// Delete the processed document if it already exists.
1061+
RNFS.exists(processedDocumentPath).then(exists => {
1062+
if (exists) {
1063+
RNFS.unlink(processedDocumentPath);
1064+
}
1065+
});
10601066
// First, save all annotations in the current document.
10611067
await this.refs.pdfView.saveCurrentDocument().then(success => {
10621068
if (success) {
@@ -1091,7 +1097,14 @@ class AnnotationProcessing extends Component {
10911097
onPress={async () => {
10921098
const processedDocumentPath =
10931099
RNFS.DocumentDirectoryPath + "/flattened.pdf";
1100+
// Delete the processed document if it already exists.
1101+
RNFS.exists(processedDocumentPath).then(exists => {
1102+
if (exists) {
1103+
RNFS.unlink(processedDocumentPath);
1104+
}
1105+
});
10941106
// First, save all annotations in the current document.
1107+
10951108
await this.refs.pdfView.saveCurrentDocument().then(success => {
10961109
if (success) {
10971110
// Then, flatten all the annotations
@@ -1125,6 +1138,12 @@ class AnnotationProcessing extends Component {
11251138
onPress={async () => {
11261139
const processedDocumentPath =
11271140
RNFS.DocumentDirectoryPath + "/removed.pdf";
1141+
// Delete the processed document if it already exists.
1142+
RNFS.exists(processedDocumentPath).then(exists => {
1143+
if (exists) {
1144+
RNFS.unlink(processedDocumentPath);
1145+
}
1146+
});
11281147
// First, save all annotations in the current document.
11291148
await this.refs.pdfView.saveCurrentDocument().then(success => {
11301149
if (success) {
@@ -1159,6 +1178,12 @@ class AnnotationProcessing extends Component {
11591178
onPress={async () => {
11601179
const processedDocumentPath =
11611180
RNFS.DocumentDirectoryPath + "/printed.pdf";
1181+
// Delete the processed document if it already exists.
1182+
RNFS.exists(processedDocumentPath).then(exists => {
1183+
if (exists) {
1184+
RNFS.unlink(processedDocumentPath);
1185+
}
1186+
});
11621187
// First, save all annotations in the current document.
11631188
await this.refs.pdfView.saveCurrentDocument().then(success => {
11641189
if (success) {

0 commit comments

Comments
 (0)