From 4e3d351910f0927283fdc6911574ffe982ca678b Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 25 Apr 2012 20:40:29 +0100 Subject: Move guts of pdfclean into new pdf_write function. Expose pdf_write function through the document interface. --- fitz/doc_document.c | 7 +++++++ fitz/fitz-internal.h | 1 + fitz/fitz.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) (limited to 'fitz') diff --git a/fitz/doc_document.c b/fitz/doc_document.c index 22229892..83dbe53f 100644 --- a/fitz/doc_document.c +++ b/fitz/doc_document.c @@ -129,3 +129,10 @@ fz_meta(fz_document *doc, int key, void *ptr, int size) return doc->meta(doc, key, ptr, size); return FZ_META_UNKNOWN_KEY; } + +void +fz_write(fz_document *doc, char *filename, fz_write_opts *opts) +{ + if (doc && doc->write) + doc->write(doc, filename, opts); +} \ No newline at end of file diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index bd19886c..1e54c900 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -1080,6 +1080,7 @@ struct fz_document_s void (*run_page)(fz_document *doc, fz_page *page, 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); + void (*write)(fz_document *doc, char *filename, fz_write_options *opts); }; #endif diff --git a/fitz/fitz.h b/fitz/fitz.h index 04215c71..61f80756 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -2231,4 +2231,50 @@ enum FZ_META_INFO = 4, }; +typedef struct fz_write_options_s fz_write_options; + +/* + In calls to fz_write, the following options structure can be used + to control aspects of the writing process. This structure may grow + in future, and should be zero-filled to allow forwards compatiblity. +*/ +struct fz_write_options_s +{ + int doascii; /* If non-zero then attempt (where possible) to + make the output ascii. */ + int doexpand; /* Bitflags; each non zero bit indicates an aspect + of the file that should be 'expanded' on + writing. */ + int dogarbage; /* If non-zero then attempt (where possible) to + garbage collect the file before writing. */ +}; + +/* An enumeration of bitflags to use in the above 'doexpand' field of + fz_write_options. +*/ +enum +{ + fz_expand_images = 1, + fz_expand_fonts = 2, + fz_expand_all = -1 +}; + +/* + fz_write: Write a document out. + + (In development - Subject to change in future versions) + + Save a copy of the current document in its original format. + Internally the document may change. + + doc: The document to save. + + filename: The filename to save to. + + opts: NULL, or a pointer to an options structure. + + May throw exceptions. +*/ +void fz_write(fz_document *doc, char *filename, fz_write_options *opts); + #endif -- cgit v1.2.3