1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <jni.h>
18 #include <stdio.h>
19 
20 #ifndef MEDIAPROVIDER_JNI_PDF_DOCUMENT_JNI_H_
21 #define MEDIAPROVIDER_JNI_PDF_DOCUMENT_JNI_H_
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved);
28 
29 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_createFromFd(
30         JNIEnv* env, jobject obj, jint jfd, jstring jpassword);
31 
32 // NOTE: All of these functions have an extra parameter called jobject
33 // jPdfDocument because for non-static methods, Java includes a hidden
34 // parameter that refers to this instance of the object.
35 JNIEXPORT void JNICALL Java_android_graphics_pdf_PdfDocumentProxy_destroy(JNIEnv* env,
36                                                                           jobject jPdfDocument);
37 
38 JNIEXPORT jboolean JNICALL Java_android_graphics_pdf_PdfDocumentProxy_saveToFd(JNIEnv* env,
39                                                                                jobject jPdfDocument,
40                                                                                jint jfd);
41 
42 JNIEXPORT jint JNICALL Java_android_graphics_pdf_PdfDocumentProxy_getPageWidth(JNIEnv* env,
43                                                                                jobject jPdfDocument,
44                                                                                jint pageNum);
45 
46 JNIEXPORT jint JNICALL Java_android_graphics_pdf_PdfDocumentProxy_getPageHeight(JNIEnv* env,
47                                                                                jobject jPdfDocument,
48                                                                                jint pageNum);
49 
50 JNIEXPORT jboolean JNICALL Java_android_graphics_pdf_PdfDocumentProxy_render(
51         JNIEnv* env, jobject jPdfDocument, jint pageNum, jobject jbitmap, jint clipLeft,
52         jint clipTop, jint clipRight, int clipBottom, jfloatArray jTransform, jint renderMode,
53         jint showAnnotTypes, jboolean renderFormFields);
54 
55 JNIEXPORT jboolean JNICALL Java_android_graphics_pdf_PdfDocumentProxy_cloneWithoutSecurity(
56         JNIEnv* env, jobject jPdfDocument, jint destination);
57 
58 JNIEXPORT jstring JNICALL Java_android_graphics_pdf_PdfDocumentProxy_getPageText(
59         JNIEnv* env, jobject jPdfDocument, jint pageNum);
60 
61 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_getPageAltText(
62         JNIEnv* env, jobject jPdfDocument, jint pageNum);
63 
64 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_searchPageText(
65         JNIEnv* env, jobject jPdfDocument, jint pageNum, jstring query);
66 
67 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_selectPageText(
68         JNIEnv* env, jobject jPdfDocument, jint pageNum, jobject start, jobject stop);
69 
70 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_getPageLinks(
71         JNIEnv* env, jobject jPdfDocument, jint pageNum);
72 
73 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_getPageGotoLinks(
74         JNIEnv* env, jobject jPdfDocument, jint pageNum);
75 
76 JNIEXPORT void JNICALL Java_android_graphics_pdf_PdfDocumentProxy_retainPage(JNIEnv* env,
77                                                                              jobject jPdfDocument,
78                                                                              jint pageNum);
79 
80 JNIEXPORT void JNICALL Java_android_graphics_pdf_PdfDocumentProxy_releasePage(JNIEnv* env,
81                                                                               jobject jPdfDocument,
82                                                                               jint pageNum);
83 
84 JNIEXPORT jboolean JNICALL
85 Java_android_graphics_pdf_PdfDocumentProxy_isPdfLinearized(JNIEnv* env, jobject jPdfDocument);
86 
87 JNIEXPORT jboolean JNICALL
88 Java_android_graphics_pdf_PdfDocumentProxy_scaleForPrinting(JNIEnv* env, jobject jPdfDocument);
89 
90 JNIEXPORT jint JNICALL Java_android_graphics_pdf_PdfDocumentProxy_getFormType(JNIEnv* env,
91                                                                               jobject jPdfDocument);
92 
93 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_getFormWidgetInfo__III(
94         JNIEnv* env, jobject jPdfDocument, jint pageNum, jint x, jint y);
95 
96 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_getFormWidgetInfo__II(
97         JNIEnv* env, jobject jPdfDocument, jint pageNum, jint index);
98 
99 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_getFormWidgetInfos(
100         JNIEnv* env, jobject jPdfDocument, jint pageNum, jintArray jTypeIds);
101 
102 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_clickOnPage(
103         JNIEnv* env, jobject jPdfDocument, jint pageNum, jint x, jint y);
104 
105 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_setFormFieldText(
106         JNIEnv* env, jobject jPdfDocument, jint pageNum, jint annotationIndex, jstring jText);
107 
108 JNIEXPORT jobject JNICALL Java_android_graphics_pdf_PdfDocumentProxy_setFormFieldSelectedIndices(
109         JNIEnv* env, jobject jPdfDocument, jint pageNum, jint annotationIndex,
110         jintArray jSelectedIndices);
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif  // MEDIAPROVIDER_JNI_PDF_DOCUMENT_JNI_H_