summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-04-14 11:53:53 +0200
committerRobin Watts <robin.watts@artifex.com>2015-04-14 16:13:58 +0100
commita7be4a1caca767baa0ce0946792f3c3e9e150308 (patch)
tree76804ec000992a20fdf62bf962ef06df6750a0e8 /include/mupdf/fitz
parent1bc74dac2b251764d373c164e2b5235875f27901 (diff)
downloadmupdf-a7be4a1caca767baa0ce0946792f3c3e9e150308.tar.xz
Split fz_meta into separate querying functions.
Add fz_has_permission function to fz_document. Add fz_lookup_metadata function to fz_document. Remove fz_meta function from fz_document.
Diffstat (limited to 'include/mupdf/fitz')
-rw-r--r--include/mupdf/fitz/document.h56
-rw-r--r--include/mupdf/fitz/meta.h80
2 files changed, 54 insertions, 82 deletions
diff --git a/include/mupdf/fitz/document.h b/include/mupdf/fitz/document.h
index 9d8a60a6..9e81efbb 100644
--- a/include/mupdf/fitz/document.h
+++ b/include/mupdf/fitz/document.h
@@ -16,6 +16,7 @@ typedef struct fz_document_s fz_document;
typedef struct fz_document_handler_s fz_document_handler;
typedef struct fz_page_s fz_page;
typedef struct fz_annot_s fz_annot;
+typedef enum fz_permission_e fz_permission;
// TODO: move out of this interface (it's pdf specific)
typedef struct fz_write_options_s fz_write_options;
@@ -23,11 +24,12 @@ typedef struct fz_write_options_s fz_write_options;
typedef void (fz_document_close_fn)(fz_context *ctx, fz_document *doc);
typedef int (fz_document_needs_password_fn)(fz_context *ctx, fz_document *doc);
typedef int (fz_document_authenticate_password_fn)(fz_context *ctx, fz_document *doc, const char *password);
+typedef int (fz_document_has_permission_fn)(fz_context *ctx, fz_document *doc, fz_permission permission);
typedef fz_outline *(fz_document_load_outline_fn)(fz_context *ctx, fz_document *doc);
typedef void (fz_document_layout_fn)(fz_context *ctx, fz_document *doc, float w, float h, float em);
typedef int (fz_document_count_pages_fn)(fz_context *ctx, fz_document *doc);
typedef fz_page *(fz_document_load_page_fn)(fz_context *ctx, fz_document *doc, int number);
-typedef int (fz_document_meta_fn)(fz_context *ctx, fz_document *doc, int key, void *ptr, int size);
+typedef int (fz_document_lookup_metadata_fn)(fz_context *ctx, fz_document *doc, const char *key, char *buf, int size);
typedef void (fz_document_write_fn)(fz_context *ctx, fz_document *doc, char *filename, fz_write_options *opts);
typedef fz_link *(fz_page_load_links_fn)(fz_context *ctx, fz_page *page);
@@ -61,11 +63,12 @@ struct fz_document_s
fz_document_close_fn *close;
fz_document_needs_password_fn *needs_password;
fz_document_authenticate_password_fn *authenticate_password;
+ fz_document_has_permission_fn *has_permission;
fz_document_load_outline_fn *load_outline;
fz_document_layout_fn *layout;
fz_document_count_pages_fn *count_pages;
fz_document_load_page_fn *load_page;
- fz_document_meta_fn *meta;
+ fz_document_lookup_metadata_fn *lookup_metadata;
fz_document_write_fn *write;
int did_layout;
};
@@ -300,4 +303,53 @@ void fz_drop_page(fz_context *ctx, fz_page *page);
*/
fz_transition *fz_page_presentation(fz_context *ctx, fz_page *page, float *duration);
+/*
+ fz_has_permission: Check permission flags on document.
+*/
+int fz_has_permission(fz_context *ctx, fz_document *doc, fz_permission p);
+
+enum fz_permission_e
+{
+ FZ_PERMISSION_PRINT = 'p',
+ FZ_PERMISSION_COPY = 'c',
+ FZ_PERMISSION_EDIT = 'e',
+ FZ_PERMISSION_ANNOTATE = 'n',
+};
+
+/*
+ fz_lookup_metadata: Retrieve document meta data strings.
+
+ doc: The document to query.
+
+ key: Which meta data key to retrieve...
+
+ Basic information:
+ 'format' -- Document format and version.
+ 'encryption' -- Description of the encryption used.
+
+ From the document information dictionary:
+ 'info:Title'
+ 'info:Author'
+ 'info:Subject'
+ 'info:Keywords'
+ 'info:Creator'
+ 'info:Producer'
+ 'info:CreationDate'
+ 'info:ModDate'
+
+ buf: The buffer to hold the results (a nul-terminated UTF-8 string).
+
+ size: Size of 'buf'.
+
+ Returns the size of the output string (may be larger than 'size' if
+ the output was truncated), or -1 if the key is not recognized or found.
+*/
+int fz_lookup_metadata(fz_context *ctx, fz_document *doc, const char *key, char *buf, int size);
+
+#define FZ_META_FORMAT "format"
+#define FZ_META_ENCRYPTION "encryption"
+
+#define FZ_META_INFO_AUTHOR "info:Author"
+#define FZ_META_INFO_TITLE "info:Title"
+
#endif
diff --git a/include/mupdf/fitz/meta.h b/include/mupdf/fitz/meta.h
deleted file mode 100644
index 8075c3c6..00000000
--- a/include/mupdf/fitz/meta.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef MUPDF_FITZ_META_H
-#define MUPDF_FITZ_META_H
-
-#include "mupdf/fitz/system.h"
-#include "mupdf/fitz/context.h"
-#include "mupdf/fitz/document.h"
-
-/*
- fz_meta: Perform a meta operation on a document.
-
- (In development - Subject to change in future versions)
-
- Meta operations provide a way to perform format specific
- operations on a document. The meta operation scheme is
- designed to be extensible so that new features can be
- transparently added in later versions of the library.
-
- doc: The document on which to perform the meta operation.
-
- key: The meta operation to try. If a particular operation
- is unsupported on a given document, the function will return
- FZ_META_UNKNOWN_KEY.
-
- ptr: An operation dependent (possibly NULL) pointer.
-
- size: An operation dependent integer. Often this will
- be the size of the block pointed to by ptr, but not always.
-
- Returns an operation dependent value; FZ_META_UNKNOWN_KEY
- always means "unknown operation for this document". In general
- FZ_META_OK should be used to indicate successful operation.
-*/
-int fz_meta(fz_context *ctx, fz_document *doc, int key, void *ptr, int size);
-
-enum
-{
- FZ_META_UNKNOWN_KEY = -1,
- FZ_META_OK = 0,
-
- /*
- ptr: Pointer to block (uninitialised on entry)
- size: Size of block (at least 64 bytes)
- Returns: Document format as a brief text string.
- All formats should support this.
- */
- FZ_META_FORMAT_INFO = 1,
-
- /*
- ptr: Pointer to block (uninitialised on entry)
- size: Size of block (at least 64 bytes)
- Returns: Encryption info as a brief text string.
- */
- FZ_META_CRYPT_INFO = 2,
-
- /*
- ptr: NULL
- size: Which permission to check
- Returns: 1 if permitted, 0 otherwise.
- */
- FZ_META_HAS_PERMISSION = 3,
-
- FZ_PERMISSION_PRINT = 0,
- FZ_PERMISSION_CHANGE = 1,
- FZ_PERMISSION_COPY = 2,
- FZ_PERMISSION_NOTES = 3,
-
- /*
- ptr: Pointer to block. First entry in the block is
- a pointer to a UTF8 string to lookup. The rest of the
- block is uninitialised on entry.
- size: size of the block in bytes.
- Returns: 0 if not found. 1 if found. The string
- result is copied into the block (truncated to size
- and NULL terminated)
-
- */
- FZ_META_INFO = 4,
-};
-
-#endif