summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
Diffstat (limited to 'fitz')
-rw-r--r--fitz/doc_document.c40
-rw-r--r--fitz/fitz-internal.h3
-rw-r--r--fitz/fitz.h45
3 files changed, 85 insertions, 3 deletions
diff --git a/fitz/doc_document.c b/fitz/doc_document.c
index fe89a061..47157156 100644
--- a/fitz/doc_document.c
+++ b/fitz/doc_document.c
@@ -162,10 +162,46 @@ fz_bound_annot(fz_document *doc, fz_annot *annot)
}
void
+fz_run_page_contents(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie)
+{
+ if (doc && doc->run_page_contents && page)
+ doc->run_page_contents(doc, page, dev, transform, cookie);
+}
+
+void
+fz_run_annot(fz_document *doc, fz_page *page, fz_annot *annot, fz_device *dev, fz_matrix transform, fz_cookie *cookie)
+{
+ if (doc && doc->run_annot && page && annot)
+ doc->run_annot(doc, page, annot, dev, transform, cookie);
+}
+
+void
fz_run_page(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie)
{
- if (doc && doc->run_page && page)
- doc->run_page(doc, page, dev, transform, cookie);
+ fz_annot *annot;
+
+ fz_run_page_contents(doc, page, dev, transform, cookie);
+
+ if (cookie && cookie->progress_max != -1)
+ {
+ int count = 1;
+ for (annot = fz_first_annot(doc, page); annot; annot = fz_next_annot(doc, annot))
+ count++;
+ cookie->progress_max += count;
+ }
+
+ for (annot = fz_first_annot(doc, page); annot; annot = fz_next_annot(doc, annot))
+ {
+ /* Check the cookie for aborting */
+ if (cookie)
+ {
+ if (cookie->abort)
+ break;
+ cookie->progress++;
+ }
+
+ fz_run_annot(doc, page, annot, dev, transform, cookie);
+ }
}
void
diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h
index 2023f99b..9726dbf7 100644
--- a/fitz/fitz-internal.h
+++ b/fitz/fitz-internal.h
@@ -1434,7 +1434,8 @@ struct fz_document_s
fz_page *(*load_page)(fz_document *doc, int number);
fz_link *(*load_links)(fz_document *doc, fz_page *page);
fz_rect (*bound_page)(fz_document *doc, fz_page *page);
- void (*run_page)(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie);
+ void (*run_page_contents)(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie);
+ void (*run_annot)(fz_document *doc, fz_page *page, fz_annot *annot, fz_device *dev, fz_matrix transform, fz_cookie *cookie);
void (*free_page)(fz_document *doc, fz_page *page);
int (*meta)(fz_document *doc, int key, void *ptr, int size);
fz_transition *(*page_presentation)(fz_document *doc, fz_page *page, float *duration);
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 67d9c97c..590bcd45 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -2322,6 +2322,51 @@ fz_rect fz_bound_annot(fz_document *doc, fz_annot *annot);
void fz_run_page(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie);
/*
+ fz_run_page_contents: Run a page through a device. Just the main
+ page content, without the annotations, if any.
+
+ page: Page obtained from fz_load_page.
+
+ dev: Device obtained from fz_new_*_device.
+
+ transform: Transform to apply to page. May include for example
+ scaling and rotation, see fz_scale, fz_rotate and fz_concat.
+ Set to fz_identity if no transformation is desired.
+
+ cookie: Communication mechanism between caller and library
+ rendering the page. Intended for multi-threaded applications,
+ while single-threaded applications set cookie to NULL. The
+ caller may abort an ongoing rendering of a page. Cookie also
+ communicates progress information back to the caller. The
+ fields inside cookie are continually updated while the page is
+ rendering.
+*/
+void fz_run_page_contents(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie);
+
+/*
+ fz_run_annot: Run an annotation through a device.
+
+ page: Page obtained from fz_load_page.
+
+ annot: an annotation.
+
+ dev: Device obtained from fz_new_*_device.
+
+ transform: Transform to apply to page. May include for example
+ scaling and rotation, see fz_scale, fz_rotate and fz_concat.
+ Set to fz_identity if no transformation is desired.
+
+ cookie: Communication mechanism between caller and library
+ rendering the page. Intended for multi-threaded applications,
+ while single-threaded applications set cookie to NULL. The
+ caller may abort an ongoing rendering of a page. Cookie also
+ communicates progress information back to the caller. The
+ fields inside cookie are continually updated while the page is
+ rendering.
+*/
+void fz_run_annot(fz_document *doc, fz_page *page, fz_annot *annot, fz_device *dev, fz_matrix transform, fz_cookie *cookie);
+
+/*
fz_free_page: Free a loaded page.
Does not throw exceptions.