@@ -1057,6 +1057,12 @@ class AnnotationProcessing extends Component {
1057
1057
onPress = { async ( ) => {
1058
1058
const processedDocumentPath =
1059
1059
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
+ } ) ;
1060
1066
// First, save all annotations in the current document.
1061
1067
await this . refs . pdfView . saveCurrentDocument ( ) . then ( success => {
1062
1068
if ( success ) {
@@ -1091,7 +1097,14 @@ class AnnotationProcessing extends Component {
1091
1097
onPress = { async ( ) => {
1092
1098
const processedDocumentPath =
1093
1099
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
+ } ) ;
1094
1106
// First, save all annotations in the current document.
1107
+
1095
1108
await this . refs . pdfView . saveCurrentDocument ( ) . then ( success => {
1096
1109
if ( success ) {
1097
1110
// Then, flatten all the annotations
@@ -1125,6 +1138,12 @@ class AnnotationProcessing extends Component {
1125
1138
onPress = { async ( ) => {
1126
1139
const processedDocumentPath =
1127
1140
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
+ } ) ;
1128
1147
// First, save all annotations in the current document.
1129
1148
await this . refs . pdfView . saveCurrentDocument ( ) . then ( success => {
1130
1149
if ( success ) {
@@ -1159,6 +1178,12 @@ class AnnotationProcessing extends Component {
1159
1178
onPress = { async ( ) => {
1160
1179
const processedDocumentPath =
1161
1180
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
+ } ) ;
1162
1187
// First, save all annotations in the current document.
1163
1188
await this . refs . pdfView . saveCurrentDocument ( ) . then ( success => {
1164
1189
if ( success ) {
0 commit comments