mupdf
Loading...
Searching...
No Matches
mu-office-lib.h
Go to the documentation of this file.
1// Copyright (C) 2004-2021 Artifex Software, Inc.
2//
3// This file is part of MuPDF.
4//
5// MuPDF is free software: you can redistribute it and/or modify it under the
6// terms of the GNU Affero General Public License as published by the Free
7// Software Foundation, either version 3 of the License, or (at your option)
8// any later version.
9//
10// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Affero General Public License
16// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17//
18// Alternative licensing terms are available from the licensor.
19// For commercial licensing, see <https://www.artifex.com/> or contact
20// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21// CA 94129, USA, for further information.
22
31
32#ifndef MU_OFFICE_LIB_H
33#define MU_OFFICE_LIB_H
34
35/*
36 * General use
37 *
38 * This library uses threads but is not thread safe for the caller. All
39 * calls should be made from a single thread. Some calls allow the user
40 * to arrange for their own functions to be called back from the library;
41 * often the users functions will be called back from a different thread. If
42 * a call into the library is required in response to information from a
43 * callback, it is the responsibility of the user to arrange for those
44 * library calls to be made on the same thread as for other library calls.
45 * Calls back into the library from a callback are not permitted.
46 *
47 * There are two main modes of use. In interactive windowing systems, it
48 * is usual for the app developers code to be called on the main UI thread.
49 * It is from the UI thread that all library calls should be made. Such
50 * systems usually provide a way to post a call onto the UI thread. That
51 * is the best way to respond to a callback from the library.
52 *
53 * The other mode of use is for plain executables that might wish to
54 * (say) generate images of all the pages of a document. This can
55 * be achieved, without use of callbacks, using the few synchronous
56 * calls. E.g., MuOfficeDoc_getNumPages will wait for background document
57 * loading to complete before returning the total number of pages and
58 * MuOfficeRender_destroy will wait for background rendering to complete
59 * before returning.
60 */
61
62#include <stddef.h> /* For size_t */
63#include "mupdf/fitz.h" /* For fz_context/fz_document/fz_page */
64
74typedef int MuError;
75
102
106typedef struct
107{
108 void *memptr;
109 int width;
113
120typedef struct
121{
122 float x;
123 float y;
125
134typedef struct
135{
136 float x;
137 float y;
138 float width;
139 float height;
141
147
148typedef struct
149{
150 float x;
151 float y;
154
167
172
182typedef void *(MuOfficeAllocFn)(void *cookie,
183 size_t size);
184
199typedef void (MuOfficeLoadingProgressFn)(void *cookie,
200 int pagesLoaded,
201 int complete);
202
211typedef void (MuOfficeLoadingErrorFn)( void *cookie,
213
221typedef void (MuOfficePageUpdateFn)( void *cookie,
222 const MuOfficeBox *area);
223
232typedef void (MuOfficeRenderProgressFn)(void *cookie,
233 MuError error);
234
246
257
265typedef void (MuOfficeSaveResultFn)( void *cookie,
266 MuOfficeSaveResult result);
267
277
284
293
301
330 const char *path,
331 MuOfficeLoadingProgressFn *progressFn,
332 MuOfficeLoadingErrorFn *errorFn,
333 void *cookie,
334 MuOfficeDoc **pDoc);
335
351MuError MuOfficeLib_run(MuOfficeLib *mu, void (*fn)(fz_context *ctx, void *arg), void *arg);
352
365int MuOfficeDoc_providePassword(MuOfficeDoc *doc, const char *password);
366
375
393
402
414 const char *path,
415 MuOfficeSaveResultFn *resultFn,
416 void *cookie);
417
425
433
447 int pageNumber,
448 MuOfficePageUpdateFn *updateFn,
449 void *cookie,
450 MuOfficePage **pPage);
451
476MuError MuOfficeDoc_run(MuOfficeDoc *doc, void (*fn)(fz_context *ctx, fz_document *doc, void *arg), void *arg);
477
488
504 float *pWidth,
505 float *pHeight);
506
520 int width,
521 int height,
522 float *pXZoom,
523 float *pYZoom);
524
541 float zoom,
542 int *pWidth,
543 int *pHeight);
544
569MuError MuOfficePage_run(MuOfficePage *page, void (*fn)(fz_context *ctx, fz_page *page, void *arg), void *arg);
570
599 float zoom,
600 const MuOfficeBitmap *bitmap,
601 const MuOfficeRenderArea *area,
602 MuOfficeRenderProgressFn *progressFn,
603 void *cookie,
604 MuOfficeRender **pRender);
605
627
647
665
666#endif /* SMART_OFFICE_LIB_H */
MuOfficeDocType
Definition mu-office-lib.h:241
@ MuOfficeDocType_IMG
Definition mu-office-lib.h:244
@ MuOfficeDocType_PDF
Definition mu-office-lib.h:242
@ MuOfficeDocType_XPS
Definition mu-office-lib.h:243
MuError MuOfficeDoc_getNumPages(MuOfficeDoc *doc, int *pNumPages)
MuError MuOfficePage_getSize(MuOfficePage *page, float *pWidth, float *pHeight)
MuOfficeDocType MuOfficeLib_getDocTypeFromFileExtension(const char *path)
void MuOfficeRender_destroy(MuOfficeRender *render)
MuError MuOfficePage_render(MuOfficePage *page, float zoom, const MuOfficeBitmap *bitmap, const MuOfficeRenderArea *area, MuOfficeRenderProgressFn *progressFn, void *cookie, MuOfficeRender **pRender)
struct MuOfficeRender MuOfficeRender
Definition mu-office-lib.h:171
void MuOfficeSaveResultFn(void *cookie, MuOfficeSaveResult result)
Definition mu-office-lib.h:265
struct MuOfficeDoc MuOfficeDoc
Definition mu-office-lib.h:169
MuError MuOfficePage_getSizeForZoom(MuOfficePage *page, float zoom, int *pWidth, int *pHeight)
char * MuOfficeLib_getSupportedFileExtensions(void)
MuError MuOfficeLib_run(MuOfficeLib *mu, void(*fn)(fz_context *ctx, void *arg), void *arg)
MuOfficeSaveResult
Definition mu-office-lib.h:251
@ MuOfficeSave_Error
Definition mu-office-lib.h:253
@ MuOfficeSave_Succeeded
Definition mu-office-lib.h:252
@ MuOfficeSave_Cancelled
Definition mu-office-lib.h:254
MuOfficePointType
Definition mu-office-lib.h:143
@ MuOfficePointType_MoveTo
Definition mu-office-lib.h:144
@ MuOfficePointType_LineTo
Definition mu-office-lib.h:145
int MuError
Definition mu-office-lib.h:74
void MuOfficePage_destroy(MuOfficePage *page)
MuOfficeDocErrorType
Definition mu-office-lib.h:81
@ MuOfficeDocErrorType_PasswordRequest
Definition mu-office-lib.h:100
@ MuOfficeDocErrorType_OutOfMemory
Definition mu-office-lib.h:88
@ MuOfficeDocErrorType_Aborted
Definition mu-office-lib.h:87
@ MuOfficeDocErrorType_EmptyDocument
Definition mu-office-lib.h:84
@ MuOfficeDocErrorType_UnsupportedEncryption
Definition mu-office-lib.h:86
@ MuOfficeDocErrorType_NoError
Definition mu-office-lib.h:82
@ MuOfficeDocErrorType_UnsupportedDocumentType
Definition mu-office-lib.h:83
@ MuOfficeDocErrorType_IllegalArgument
Definition mu-office-lib.h:92
@ MuOfficeDocErrorType_UnableToLoadDocument
Definition mu-office-lib.h:85
void MuOfficeRenderProgressFn(void *cookie, MuError error)
Definition mu-office-lib.h:232
MuError MuOfficeDoc_getPage(MuOfficeDoc *doc, int pageNumber, MuOfficePageUpdateFn *updateFn, void *cookie, MuOfficePage **pPage)
MuError MuOfficePage_calculateZoom(MuOfficePage *page, int width, int height, float *pXZoom, float *pYZoom)
MuError MuOfficeLib_loadDocument(MuOfficeLib *mu, const char *path, MuOfficeLoadingProgressFn *progressFn, MuOfficeLoadingErrorFn *errorFn, void *cookie, MuOfficeDoc **pDoc)
void MuOfficeLib_destroy(MuOfficeLib *mu)
void MuOfficeRender_abort(MuOfficeRender *render)
MuOfficeDocType MuOfficeDoc_docType(MuOfficeDoc *doc)
void MuOfficeLoadingProgressFn(void *cookie, int pagesLoaded, int complete)
Definition mu-office-lib.h:199
struct MuOfficePage MuOfficePage
Definition mu-office-lib.h:170
void MuOfficeLoadingErrorFn(void *cookie, MuOfficeDocErrorType error)
Definition mu-office-lib.h:211
MuError MuOfficeRender_waitUntilComplete(MuOfficeRender *render)
MuError MuOfficeDoc_run(MuOfficeDoc *doc, void(*fn)(fz_context *ctx, fz_document *doc, void *arg), void *arg)
int MuOfficeDoc_hasBeenModified(MuOfficeDoc *doc)
void MuOfficeDoc_destroy(MuOfficeDoc *doc)
MuError MuOfficeLib_create(MuOfficeLib **pMu)
struct MuOfficeLib MuOfficeLib
Definition mu-office-lib.h:168
void MuOfficeDoc_abortLoad(MuOfficeDoc *doc)
void * MuOfficeAllocFn(void *cookie, size_t size)
Definition mu-office-lib.h:182
int MuOfficeDoc_providePassword(MuOfficeDoc *doc, const char *password)
MuError MuOfficeDoc_save(MuOfficeDoc *doc, const char *path, MuOfficeSaveResultFn *resultFn, void *cookie)
MuError MuOfficePage_run(MuOfficePage *page, void(*fn)(fz_context *ctx, fz_page *page, void *arg), void *arg)
void MuOfficePageUpdateFn(void *cookie, const MuOfficeBox *area)
Definition mu-office-lib.h:221
Definition mu-office-lib.h:107
int width
Definition mu-office-lib.h:109
void * memptr
Definition mu-office-lib.h:108
int height
Definition mu-office-lib.h:110
int lineSkip
Definition mu-office-lib.h:111
Definition mu-office-lib.h:135
float width
Definition mu-office-lib.h:138
float y
Definition mu-office-lib.h:137
float x
Definition mu-office-lib.h:136
float height
Definition mu-office-lib.h:139
Definition mu-office-lib.h:149
MuOfficePointType type
Definition mu-office-lib.h:152
float y
Definition mu-office-lib.h:151
float x
Definition mu-office-lib.h:150
Definition mu-office-lib.h:121
float y
Definition mu-office-lib.h:123
float x
Definition mu-office-lib.h:122
Definition mu-office-lib.h:163
MuOfficeBox renderArea
Definition mu-office-lib.h:165
MuOfficePoint origin
Definition mu-office-lib.h:164
Definition context.h:886
Definition document.h:1080
Definition document.h:1044