|
@@ -347,7 +347,7 @@ export class CPDFDocument {
|
|
if (tag != null) {
|
|
if (tag != null) {
|
|
return CPDFViewManager.exportWidgets(tag);
|
|
return CPDFViewManager.exportWidgets(tag);
|
|
}
|
|
}
|
|
- return Promise.reject('Unable to find the native view reference');
|
|
|
|
|
|
+ return Promise.reject(new Error('Unable to find the native view reference'));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -361,7 +361,7 @@ export class CPDFDocument {
|
|
if (tag != null) {
|
|
if (tag != null) {
|
|
return CPDFViewManager.printDocument(tag);
|
|
return CPDFViewManager.printDocument(tag);
|
|
}
|
|
}
|
|
- return Promise.reject('Unable to find the native view reference');
|
|
|
|
|
|
+ return Promise.reject(new Error('Unable to find the native view reference'));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -376,16 +376,16 @@ export class CPDFDocument {
|
|
* const result = await pdfReaderRef.current?._pdfDocument.flattenAllPages(savePath, fontSubset);
|
|
* const result = await pdfReaderRef.current?._pdfDocument.flattenAllPages(savePath, fontSubset);
|
|
* @returns Returns the save path of the current document.
|
|
* @returns Returns the save path of the current document.
|
|
*/
|
|
*/
|
|
- flattenAllPages = (savePath : string, fontSubset : boolean) : Promise<string> => {
|
|
|
|
- const tag = findNodeHandle(this._viewerRef);
|
|
|
|
- if (tag != null) {
|
|
|
|
- return CPDFViewManager.flattenAllPages(tag, {
|
|
|
|
- 'save_path': savePath,
|
|
|
|
- 'font_sub_set': fontSubset
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- return Promise.reject('Unable to find the native view reference');
|
|
|
|
- }
|
|
|
|
|
|
+ // flattenAllPages = (savePath : string, fontSubset : boolean) : Promise<string> => {
|
|
|
|
+ // const tag = findNodeHandle(this._viewerRef);
|
|
|
|
+ // if (tag != null) {
|
|
|
|
+ // return CPDFViewManager.flattenAllPages(tag, {
|
|
|
|
+ // 'save_path': savePath,
|
|
|
|
+ // 'font_sub_set': fontSubset
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // return Promise.reject(new Error('Unable to find the native view reference'));
|
|
|
|
+ // }
|
|
|
|
|
|
/**
|
|
/**
|
|
* Saves the document to the specified directory.
|
|
* Saves the document to the specified directory.
|
|
@@ -403,31 +403,39 @@ export class CPDFDocument {
|
|
* @param fontSubset
|
|
* @param fontSubset
|
|
* @returns Whether to embed the font subset when saving the PDF.
|
|
* @returns Whether to embed the font subset when saving the PDF.
|
|
*/
|
|
*/
|
|
- saveAs = (savePath : string, removeSecurity : boolean, fontSubset : boolean) : Promise<string> => {
|
|
|
|
- const tag = findNodeHandle(this._viewerRef);
|
|
|
|
- if (tag != null) {
|
|
|
|
- return CPDFViewManager.saveAs(tag, {
|
|
|
|
- 'save_path': savePath,
|
|
|
|
- 'remove_security': removeSecurity,
|
|
|
|
- 'font_sub_set': fontSubset
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- return Promise.reject('Unable to find the native view reference');
|
|
|
|
- }
|
|
|
|
|
|
+ // saveAs = (savePath : string, removeSecurity : boolean, fontSubset : boolean) : Promise<string> => {
|
|
|
|
+ // const tag = findNodeHandle(this._viewerRef);
|
|
|
|
+ // if (tag != null) {
|
|
|
|
+ // return CPDFViewManager.saveAs(tag, {
|
|
|
|
+ // 'save_path': savePath,
|
|
|
|
+ // 'remove_security': removeSecurity,
|
|
|
|
+ // 'font_sub_set': fontSubset
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // return Promise.reject(new Error('Unable to find the native view reference'));
|
|
|
|
+ // }
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 返回当前文档的路径。
|
|
|
|
- * 在安卓平台,如果通过uri打开的文档,会返回uri
|
|
|
|
|
|
+ * Retrieves the path of the current document.
|
|
|
|
+ * On Android, if the document was opened via a URI, the URI will be returned.
|
|
|
|
+ *
|
|
|
|
+ * This function returns the path of the document being viewed. If the document was opened
|
|
|
|
+ * through a file URI on Android, the URI string will be returned instead of a file path.
|
|
|
|
+ *
|
|
* @example
|
|
* @example
|
|
* const documentPath = await pdfReaderRef.current?._pdfDocument.getDocumentPath();
|
|
* const documentPath = await pdfReaderRef.current?._pdfDocument.getDocumentPath();
|
|
- * @returns The path of the current document.
|
|
|
|
|
|
+ *
|
|
|
|
+ * @returns A promise that resolves to the path (or URI) of the current document.
|
|
|
|
+ * If the native view reference is not found, the promise will be rejected with an error.
|
|
|
|
+ *
|
|
|
|
+ * @throws Will reject with an error message if the native view reference cannot be found.
|
|
*/
|
|
*/
|
|
getDocumentPath = () : Promise<string> => {
|
|
getDocumentPath = () : Promise<string> => {
|
|
const tag = findNodeHandle(this._viewerRef);
|
|
const tag = findNodeHandle(this._viewerRef);
|
|
if (tag != null) {
|
|
if (tag != null) {
|
|
return CPDFViewManager.getDocumentPath(tag);
|
|
return CPDFViewManager.getDocumentPath(tag);
|
|
}
|
|
}
|
|
- return Promise.reject('Unable to find the native view reference');
|
|
|
|
|
|
+ return Promise.reject(new Error('Unable to find the native view reference'));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|