|
34 | 34 | import com.compdfkit.tools.common.pdf.CPDFConfigurationUtils; |
35 | 35 | import com.compdfkit.tools.common.pdf.config.CPDFConfiguration; |
36 | 36 | import com.compdfkit.tools.common.utils.CFileUtils; |
| 37 | +import com.compdfkit.tools.common.utils.print.CPDFPrintUtils; |
37 | 38 | import com.compdfkit.tools.common.utils.threadpools.CThreadPoolUtils; |
38 | 39 | import com.compdfkit.tools.common.utils.viewutils.CViewUtils; |
39 | 40 | import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl; |
|
45 | 46 | import com.compdfkitpdf.reactnative.view.CPDFView; |
46 | 47 | import com.facebook.react.bridge.Promise; |
47 | 48 | import com.facebook.react.bridge.ReactApplicationContext; |
| 49 | +import com.facebook.react.bridge.ReactMethod; |
48 | 50 | import com.facebook.react.uimanager.ThemedReactContext; |
49 | 51 | import com.facebook.react.uimanager.ViewGroupManager; |
50 | 52 | import com.facebook.react.uimanager.annotations.ReactProp; |
@@ -367,9 +369,9 @@ public void showBotaView(int tag) { |
367 | 369 | pdfView.documentFragment.showBOTA(); |
368 | 370 | } |
369 | 371 |
|
370 | | - public void showAddWatermarkView(int tag) { |
| 372 | + public void showAddWatermarkView(int tag, boolean saveAsNewFile) { |
371 | 373 | CPDFView pdfView = mDocumentViews.get(tag); |
372 | | - pdfView.documentFragment.showAddWatermarkDialog(); |
| 374 | + pdfView.documentFragment.showAddWatermarkDialog(saveAsNewFile); |
373 | 375 | } |
374 | 376 |
|
375 | 377 | public void showSecurityView(int tag) { |
@@ -476,11 +478,11 @@ public void saveAs(int tag, String savePath, boolean removeSecurity, boolean fon |
476 | 478 | } |
477 | 479 |
|
478 | 480 | public void print(int tag) { |
479 | | - CPDFView pdfView = mDocumentViews.get(tag); |
480 | | - CPDFReaderView readerView = pdfView.getCPDFReaderView(); |
481 | | - String path = readerView.getPDFDocument().getAbsolutePath(); |
482 | | - Uri uri = readerView.getPDFDocument().getUri(); |
483 | | - CFileUtils.startPrint(reactContext, path, uri); |
| 481 | + if (reactContext.getCurrentActivity() != null) { |
| 482 | + CPDFView pdfView = mDocumentViews.get(tag); |
| 483 | + CPDFReaderView readerView = pdfView.getCPDFReaderView(); |
| 484 | + CPDFPrintUtils.printCurrentDocument(reactContext.getCurrentActivity(), readerView.getPDFDocument()); |
| 485 | + } |
484 | 486 | } |
485 | 487 |
|
486 | 488 | public void removePassword(int tag, Promise promise) { |
@@ -510,7 +512,6 @@ public void setPassword(int tag, |
510 | 512 | Promise promise) { |
511 | 513 | CPDFView pdfView = mDocumentViews.get(tag); |
512 | 514 | CPDFDocument document = pdfView.getCPDFReaderView().getPDFDocument(); |
513 | | - ; |
514 | 515 | CThreadPoolUtils.getInstance().executeIO(() -> { |
515 | 516 | try { |
516 | 517 | if (!TextUtils.isEmpty(userPassword)) { |
|
0 commit comments