1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * Copyright (C) 2016 Mopria Alliance, Inc. 4 * Copyright (C) 2013 Hewlett-Packard Development Company, L.P. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef __WPRINT_MUPDF__ 20 #define __WPRINT_MUPDF__ 21 22 #include <jni.h> 23 #include "wprint_image.h" 24 25 extern const image_decode_ifc_t *wprint_mupdf_decode_ifc; 26 27 typedef struct pdf_render_ifc pdf_render_ifc_t; 28 29 /* 30 * Defines an interface for inspecting and rendering PDFs. Note: all methods must be called 31 * from the same thread that created the interface. 32 */ 33 struct pdf_render_ifc { 34 /* 35 * Return the page count for the specified file, or 0 on failure. 36 */ 37 int (*openDocument)(pdf_render_ifc_t *self, const char *fileName); 38 39 /* 40 * Render a page (1-based) at the specified zoom level into the supplied output buffer. The 41 * buffer must be large enough to contain width * height * 3 (RGB). Returns success. 42 */ 43 status_t (*renderPageStripe)(pdf_render_ifc_t *self, int page, int width, 44 int height, float zoom, char *buffer); 45 46 /* 47 * Determine the width and height of a particular page (1-based), returning success. 48 */ 49 status_t (*getPageAttributes)(pdf_render_ifc_t *self, int page, 50 double *width, double *height); 51 52 /* 53 * Finally release all resources related to this interface 54 */ 55 void (*destroy)(pdf_render_ifc_t *self); 56 }; 57 58 /* 59 * One-time initialization of pdf_render module. pdf_render_deinit must be called later to 60 * free resources. 61 */ 62 void pdf_render_init(JNIEnv *env); 63 64 /* 65 * Deinitialize the pdf_render module (at shutdown) 66 */ 67 void pdf_render_deinit(JNIEnv *env); 68 69 /* 70 * Allocate and return a thread-specific pdf_render interface. Caller must eventually 71 * call destroy on this instance. 72 */ 73 pdf_render_ifc_t *create_pdf_render_ifc(); 74 75 #endif // __WPRINT_MUPDF__