DjVuDocEditor is an extension of DjVuDocument class with additional capabilities for editing the document contents.
Accessing pages
Saving document to disk
Notifications.
DjVuDocEditor is an extension of DjVuDocument class with additional capabilities for editing the document contents.It can be used to:
- Create (compose) new multipage DjVu documents using single page DjVu documents. The class does not do compression.
- Insert and remove different pages of multipage DjVu documents.
- Change attributes (names, IDs and titles) of files composing the DjVu document.
- Generate thumbnail images and integrate them into the document.
Note: You must call either of the two
available init() function before you start doing
anything else with the DjVuDocEditor.
Note: You must call either of the two
available init() function before you start doing
anything else with the DjVuDocEditor.
OLD_BUNDLED and BUNDLED documents occupy only one file,
so in this case "saving" involves the automatic conversion
to BUNDLED format and storing data into the same file. OLD_INDEXED documents, on the other hand, occupy more
than one file. They could be converted to INDIRECT format
if these two formats had the same set of files. Unfortunately,
these formats are too different, and the best thing to do
is to use "save as" capability.
Like insert_page() it will insert every page into the document.
The main advantage of calling this function once for the whole
group instead of calling insert_page() for every page is
the processing of included files: The group of files may include one or more files, which are thus
shared by them. If you call insert_page() for every page,
this shared file will be inserted into the document more than once
though under different names. This is how insert_page() works:
whenever it inserts something, it checks for duplicate names with
only one purpose: invent a new name if a given one is already in
use. On the other hand, if you call
shared included files only once. This is because it can analyze
the group of files before inserting them and figure out what files
are shared and thus should be inserted only once.
If some other files include this file, the corresponding INCL
chunks will be removed to avoid dead links. If remove_unref is TRUE, the function will also remove every
file, which will become unreferenced after the removal of this file.
It is OK to make shift too big in value. Pages will just be
moved to the end (or to the beginning, depending on the shift
sign) of the document.
It may be ZERO, which means, that there are no thumbnails at all. It may be equal to the number of pages, which is what should
normally be. Finally, it may be greater than ZERO and less than the number
of pages, in which case thumbnails should be regenerated before
the document can be saved.
The function will return -1 if there are no thumbnails.
Note: There may be only one SHARED_ANNO file in any
DjVu multipage document.
Note: There may be only one SHARED_ANNO file in any
DjVu multipage document.
void init(void)
void init(const char * fname)
virtual ~DjVuDocEditor(void)
int get_orig_doc_type(void) const
bool can_be_saved(void) const
int get_save_doc_type(void) const
void save(void)
virtual void save_as(const char * where, bool bundled)
void save_pages_as(ByteStream & str, const GList<int> & page_list)
GString page_to_id(int page_num) const
void insert_page(const char * fname, int page_num=-1)
page_num - Position where the new page should be inserted at.
Negative value means "append" void insert_page(GP<DataPool> & file_pool, const char * fname, int page_num=-1)
file_name - Name, which will be assigned to this page.
If you try to save the document in INDIRECT format,
a file with this name will be created to hold the
page's data. If there is already a file in the document
with the same name, the function will derive a new
unique name from file_name, which will be assigned
to the page.
page_num - Describes where the page should be inserted.
Negative number means "append". void insert_group(const GList<GString> & fname_list, int page_num=-1, void (* refresh_cb)(void *)=0, void * cl_data=0)
page_num - Position where the new pages should be inserted at.
Negative value means "append" void remove_page(int page_num, bool remove_unref=true)
void remove_pages(const GList<int> & page_list, bool remove_unref=true)
void remove_file(const char * id, bool remove_unref=true)
void move_page(int page_num, int new_page_num)
void move_pages(const GList<int> & page_list, int shift)
void set_file_name(const char * id, const char * name)
void set_page_name(int page_num, const char * name)
void set_file_title(const char * id, const char * title)
void set_page_title(int page_num, const char * title)
Thumbnails
int get_thumbnails_num(void) const
int get_thumbnails_size(void) const
void remove_thumbnails(void)
int generate_thumbnails(int thumb_size, int page_num)
page_num - The page number to genate the thumbnail for. void generate_thumbnails(int thumb_size, bool (* cb)(int page_num, void *)=0, void * cl_data=0)
cb - The callback, which will be called after thumbnail image
for the next page has been generated. Regardless of if
the document already has thumbnail images for some of its
pages, the callback will be called pages_num times, where
pages_num is the total number of pages in the document.
The callback should return FALSE if thumbnails generating
should proceed. TRUE will stop it. void simplify_anno(void (* progress_cb)(float progress, void *)=0, void * cl_data=0)
void create_shared_anno_file(void (* progress_cb)(float progress, void *)=0, void * cl_data=0)
GP<DjVuFile> get_shared_anno_file(void)
virtual bool inherits(const char * class_name) const
Alphabetic index HTML hierarchy of classes or Java