summaryrefslogtreecommitdiff
path: root/source/fitz/writer.c
blob: c25ff2f9d70ba1963fc2f67520e4287d5afc998a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "mupdf/fitz.h"

fz_document_writer *
fz_new_document_writer(fz_context *ctx, const char *path, const char *format, const char *options)
{
	if (!format)
	{
		format = strrchr(path, '.');
		if (!format)
			fz_throw(ctx, FZ_ERROR_GENERIC, "cannot detect document format");
		format += 1; /* skip the '.' */
	}

	if (!fz_strcasecmp(format, "cbz"))
		return fz_new_cbz_writer(ctx, path, options);

	fz_throw(ctx, FZ_ERROR_GENERIC, "unknown document format: %s", format);
}

void
fz_drop_document_writer(fz_context *ctx, fz_document_writer *wri)
{
	if (wri->drop_imp)
		wri->drop_imp(ctx, wri);
	fz_free(ctx, wri);
}

fz_device *
fz_begin_page(fz_context *ctx, fz_document_writer *wri, const fz_rect *mediabox, fz_matrix *ctm)
{
	return wri->begin_page(ctx, wri, mediabox, ctm);
}

void
fz_end_page(fz_context *ctx, fz_document_writer *wri, fz_device *dev)
{
	wri->end_page(ctx, wri, dev);
}