summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-11-09 17:41:43 +0000
committerRobin Watts <robin.watts@artifex.com>2016-11-11 13:18:39 +0000
commitda50c6f300e565c8eedf4ce252c44b5ddbb95cee (patch)
treed63891b1494b45046973cbc1ab3b4435821fc3f1 /include
parenta1d18b804019ad89841f289c465755d7feebe823 (diff)
downloadmupdf-da50c6f300e565c8eedf4ce252c44b5ddbb95cee.tar.xz
Add pdf_layer configuration API.
Add API to: * allow enumeration of layer configs (OCCDs) within PDF files. * allow selection of layer configs. * allow enumeration of the "UI" (or "Human readable") form of layer configs. * allow selection/toggling of entries in the UI.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/pdf/document.h125
-rw-r--r--include/mupdf/pdf/interpret.h4
-rw-r--r--include/mupdf/pdf/page.h7
3 files changed, 122 insertions, 14 deletions
diff --git a/include/mupdf/pdf/document.h b/include/mupdf/pdf/document.h
index 5b9632ff..4cb4c819 100644
--- a/include/mupdf/pdf/document.h
+++ b/include/mupdf/pdf/document.h
@@ -119,20 +119,125 @@ int pdf_lookup_metadata(fz_context *ctx, pdf_document *doc, const char *key, cha
fz_outline *pdf_load_outline(fz_context *ctx, pdf_document *doc);
-typedef struct pdf_ocg_entry_s pdf_ocg_entry;
+/*
+ pdf_count_layer_configs: Get the number of layer
+ configurations defined in this document.
+
+ doc: The document in question.
+*/
+int pdf_count_layer_configs(fz_context *ctx, pdf_document *doc);
-struct pdf_ocg_entry_s
+typedef struct
{
- int num;
- int state;
-};
+ const char *name;
+ const char *creator;
+} pdf_layer_config;
+
+/*
+ pdf_layer_config_info: Fetch the name (and
+ optionally creator) of the given layer config.
+
+ doc: The document in question.
+
+ config_num: A value in the 0..n-1 range, where n is the
+ value returned from pdf_count_layer_configs.
+
+ info: Pointer to structure to fill in. Pointers within
+ this structure may be set to NULL if no information is
+ available.
+*/
+void pdf_layer_config_info(fz_context *ctx, pdf_document *doc, int config_num, pdf_layer_config *info);
+
+/*
+ pdf_select_layer_config: Set the current configuration.
+ This updates the visibility of the optional content groups
+ within the document.
+
+ doc: The document in question.
+
+ config_num: A value in the 0..n-1 range, where n is the
+ value returned from pdf_count_layer_configs.
+*/
+void pdf_select_layer_config(fz_context *ctx, pdf_document *doc, int config_num);
+
+/*
+ pdf_count_layer_config_ui: Returns the number of entries in the
+ 'UI' for this layer configuration.
+
+ doc: The document in question.
+*/
+int pdf_count_layer_config_ui(fz_context *ctx, pdf_document *doc);
+
+/*
+ pdf_select_layer_ui: Select a checkbox/radiobox
+ within the 'UI' for this layer configuration.
+
+ Selecting a UI entry that is a radiobox may disable
+ other UI entries.
+
+ doc: The document in question.
-struct pdf_ocg_descriptor_s
+ ui: A value in the 0..m-1 range, where m is the value
+ returned by pdf_count_layer_config_ui.
+*/
+void pdf_select_layer_config_ui(fz_context *ctx, pdf_document *doc, int ui);
+
+/*
+ pdf_deselect_layer_ui: Select a checkbox/radiobox
+ within the 'UI' for this layer configuration.
+
+ doc: The document in question.
+
+ ui: A value in the 0..m-1 range, where m is the value
+ returned by pdf_count_layer_config_ui.
+*/
+void pdf_deselect_layer_config_ui(fz_context *ctx, pdf_document *doc, int ui);
+
+/*
+ pdf_toggle_layer_config_ui: Toggle a checkbox/radiobox
+ within the 'UI' for this layer configuration.
+
+ Toggling a UI entry that is a radiobox may disable
+ other UI entries.
+
+ doc: The document in question.
+
+ ui: A value in the 0..m-1 range, where m is the value
+ returned by pdf_count_layer_config_ui.
+*/
+void pdf_toggle_layer_config_ui(fz_context *ctx, pdf_document *doc, int ui);
+
+typedef enum
{
- int len;
- pdf_ocg_entry *ocgs;
- pdf_obj *intent;
-};
+ PDF_LAYER_UI_LABEL = 0,
+ PDF_LAYER_UI_CHECKBOX = 1,
+ PDF_LAYER_UI_RADIOBOX = 2
+} pdf_layer_config_ui_type;
+
+typedef struct
+{
+ const char *text;
+ int depth;
+ pdf_layer_config_ui_type type;
+ int selected;
+ int locked;
+} pdf_layer_config_ui;
+
+/*
+ pdf_layer_config_ui_info: Get the info for a given
+ entry in the layer config ui.
+
+ doc: The document in question.
+
+ ui: A value in the 0..m-1 range, where m is the value
+ returned by pdf_count_layer_config_ui.
+
+ info: Pointer to a structure to fill in with information
+ about the requested ui entry.
+*/
+void pdf_layer_config_ui_info(fz_context *ctx, pdf_document *doc, int ui, pdf_layer_config_ui *info);
+
+int pdf_is_hidden_ocg(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_obj *rdb, const char *usage, pdf_obj *ocg);
/*
pdf_update_page: update a page for the sake of changes caused by a call
diff --git a/include/mupdf/pdf/interpret.h b/include/mupdf/pdf/interpret.h
index 07460221..b7b85fff 100644
--- a/include/mupdf/pdf/interpret.h
+++ b/include/mupdf/pdf/interpret.h
@@ -127,7 +127,7 @@ struct pdf_processor_s
void (*op_END)(fz_context *ctx, pdf_processor *proc);
/* interpreter state that persists across content streams */
- const char *event;
+ const char *usage;
int hidden;
};
@@ -155,7 +155,7 @@ struct pdf_csi_s
};
/* Functions to set up pdf_process structures */
-pdf_processor *pdf_new_run_processor(fz_context *ctx, fz_device *dev, const fz_matrix *ctm, const char *event, pdf_gstate *gstate, int nested);
+pdf_processor *pdf_new_run_processor(fz_context *ctx, fz_device *dev, const fz_matrix *ctm, const char *usage, pdf_gstate *gstate, int nested);
pdf_processor *pdf_new_buffer_processor(fz_context *ctx, fz_buffer *buffer, int ahxencode);
pdf_processor *pdf_new_filter_processor(fz_context *ctx, pdf_processor *chain, pdf_document *doc, pdf_obj *old_res, pdf_obj *new_res);
diff --git a/include/mupdf/pdf/page.h b/include/mupdf/pdf/page.h
index a5a60be8..407fcc09 100644
--- a/include/mupdf/pdf/page.h
+++ b/include/mupdf/pdf/page.h
@@ -65,7 +65,7 @@ fz_rect *pdf_bound_page(fz_context *ctx, pdf_page *page, fz_rect *);
void pdf_run_page(fz_context *ctx, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
/*
- pdf_run_page: Interpret a loaded page and render it on a device.
+ pdf_run_page_with_usage: Interpret a loaded page and render it on a device.
page: A page loaded by pdf_load_page.
@@ -74,10 +74,13 @@ void pdf_run_page(fz_context *ctx, pdf_page *page, fz_device *dev, const fz_matr
ctm: A transformation matrix applied to the objects on the page,
e.g. to scale or rotate the page contents as desired.
+ usage: The 'usage' for displaying the file (typically
+ 'View', 'Print' or 'Export'). NULL means 'View'.
+
cookie: A pointer to an optional fz_cookie structure that can be used
to track progress, collect errors etc.
*/
-void pdf_run_page_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie);
+void pdf_run_page_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, const char *usage, fz_cookie *cookie);
/*
pdf_run_page_contents: Interpret a loaded page and render it on a device.