/*
This file was auto-generated by mupdfwrap.py.
*/


#include "mupdf/classes.h"
#include "mupdf/exceptions.h"
#include "mupdf/internal.h"

#include "mupdf/fitz/geometry.h"

#include 
#include 


namespace mupdf
{

/* Implementation of AaContext (wrapper for fz_aa_context). */

AaContext::AaContext(const fz_aa_context* internal)
{
	this->hscale = internal->hscale;
	this->vscale = internal->vscale;
	this->scale = internal->scale;
	this->bits = internal->bits;
	this->text_bits = internal->text_bits;
	this->min_line_width = internal->min_line_width;
}

AaContext::AaContext(const fz_aa_context internal)
{
	this->hscale = internal.hscale;
	this->vscale = internal.vscale;
	this->scale = internal.scale;
	this->bits = internal.bits;
	this->text_bits = internal.text_bits;
	this->min_line_width = internal.min_line_width;
}

/* Constructor using raw copy of pre-existing fz_aa_context. */
fz_aa_context* AaContext::internal()
{
	return (fz_aa_context*) &this->hscale;
}

/* Constructor using raw copy of pre-existing fz_aa_context. */
const fz_aa_context* AaContext::internal() const
{
	return (const fz_aa_context*) &this->hscale;
}

/* Implementation of Aes (wrapper for fz_aes). */

/* Wrapper for fz_aes_crypt_cbc(). */
void Aes::aes_crypt_cbc(int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
{
	return mupdf::aes_crypt_cbc(this->m_internal, mode, length, iv, input, output);
}

/* Wrapper for fz_aes_setkey_dec(). */
int Aes::aes_setkey_dec(const unsigned char *key, int keysize)
{
	return mupdf::aes_setkey_dec(this->m_internal, key, keysize);
}

/* Wrapper for fz_aes_setkey_enc(). */
int Aes::aes_setkey_enc(const unsigned char *key, int keysize)
{
	return mupdf::aes_setkey_enc(this->m_internal, key, keysize);
}

Aes::Aes(fz_aes* internal)
: m_internal(internal)
{
}

/* Implementation of AllocContext (wrapper for fz_alloc_context). */

/* Wrapper for fz_new_context_imp(). */
Context AllocContext::new_context_imp(const LocksContext& locks, size_t max_store, const char *version)
{
	fz_context* temp = mupdf::new_context_imp(this->m_internal, locks.m_internal, max_store, version);
	return Context(temp);
}

AllocContext::AllocContext(fz_alloc_context* internal)
: m_internal(internal)
{
}

/* Implementation of Arc4 (wrapper for fz_arc4). */

/* Wrapper for fz_arc4_encrypt(). */
void Arc4::arc4_encrypt(unsigned char *dest, const unsigned char *src, size_t len)
{
	return mupdf::arc4_encrypt(this->m_internal, dest, src, len);
}

/* Wrapper for fz_arc4_init(). */
void Arc4::arc4_init(const unsigned char *key, size_t len)
{
	return mupdf::arc4_init(this->m_internal, key, len);
}

Arc4::Arc4(fz_arc4* internal)
: m_internal(internal)
{
}

/* Implementation of Archive (wrapper for fz_archive). */

/* Constructor using fz_new_archive_of_size(). */
Archive::Archive(const Stream& file, int size)
{
	this->m_internal = mupdf::new_archive_of_size(file.m_internal, size);
}

/* Wrapper for fz_archive_format(). */
const char *Archive::archive_format()
{
	return mupdf::archive_format(this->m_internal);
}

/* Wrapper for fz_count_archive_entries(). */
int Archive::count_archive_entries()
{
	return mupdf::count_archive_entries(this->m_internal);
}

/* Wrapper for fz_has_archive_entry(). */
int Archive::has_archive_entry(const char *name)
{
	return mupdf::has_archive_entry(this->m_internal, name);
}

/* Wrapper for fz_list_archive_entry(). */
const char *Archive::list_archive_entry(int idx)
{
	return mupdf::list_archive_entry(this->m_internal, idx);
}

/* Wrapper for fz_open_archive_entry(). */
Stream Archive::open_archive_entry(const char *name)
{
	fz_stream* temp = mupdf::open_archive_entry(this->m_internal, name);
	return Stream(temp);
}

/* Wrapper for fz_read_archive_entry(). */
Buffer Archive::read_archive_entry(const char *name)
{
	fz_buffer* temp = mupdf::read_archive_entry(this->m_internal, name);
	return Buffer(temp);
}

Archive::Archive(fz_archive* internal)
: m_internal(internal)
{
}

Archive::~Archive()
{
	mupdf::drop_archive(m_internal);
}

/* Implementation of BandWriter (wrapper for fz_band_writer). */

/* Constructor using fz_new_band_writer_of_size(). */
BandWriter::BandWriter(size_t size, const Output& out)
{
	this->m_internal = mupdf::new_band_writer_of_size(size, out.m_internal);
}

/* Constructor using fz_new_color_pcl_band_writer(). */
/* Disabled because same args as fz_new_mono_pcl_band_writer.
BandWriter::BandWriter(const Output& out, const PclOptions& options)
{
	this->m_internal = mupdf::new_color_pcl_band_writer(out.m_internal, options.m_internal);
}

*/
/* Constructor using fz_new_mono_pcl_band_writer(). */
BandWriter::BandWriter(const Output& out, const PclOptions& options)
{
	this->m_internal = mupdf::new_mono_pcl_band_writer(out.m_internal, options.m_internal);
}

/* Constructor using fz_new_mono_pwg_band_writer(). */
BandWriter::BandWriter(const Output& out, PwgOptions& pwg)
{
	this->m_internal = mupdf::new_mono_pwg_band_writer(out.m_internal, &pwg.m_internal);
}

/* Constructor using fz_new_pam_band_writer(). */
/* Disabled because same args as fz_new_png_band_writer.
BandWriter::BandWriter(const Output& out)
{
	this->m_internal = mupdf::new_pam_band_writer(out.m_internal);
}

*/
/* Constructor using fz_new_pbm_band_writer(). */
/* Disabled because same args as fz_new_png_band_writer.
BandWriter::BandWriter(const Output& out)
{
	this->m_internal = mupdf::new_pbm_band_writer(out.m_internal);
}

*/
/* Constructor using fz_new_pclm_band_writer(). */
BandWriter::BandWriter(const Output& out, const PclmOptions& options)
{
	this->m_internal = mupdf::new_pclm_band_writer(out.m_internal, options.m_internal);
}

/* Constructor using fz_new_pkm_band_writer(). */
/* Disabled because same args as fz_new_png_band_writer.
BandWriter::BandWriter(const Output& out)
{
	this->m_internal = mupdf::new_pkm_band_writer(out.m_internal);
}

*/
/* Constructor using fz_new_png_band_writer(). */
BandWriter::BandWriter(const Output& out)
{
	this->m_internal = mupdf::new_png_band_writer(out.m_internal);
}

/* Constructor using fz_new_pnm_band_writer(). */
/* Disabled because same args as fz_new_png_band_writer.
BandWriter::BandWriter(const Output& out)
{
	this->m_internal = mupdf::new_pnm_band_writer(out.m_internal);
}

*/
/* Constructor using fz_new_ps_band_writer(). */
/* Disabled because same args as fz_new_png_band_writer.
BandWriter::BandWriter(const Output& out)
{
	this->m_internal = mupdf::new_ps_band_writer(out.m_internal);
}

*/
/* Constructor using fz_new_psd_band_writer(). */
/* Disabled because same args as fz_new_png_band_writer.
BandWriter::BandWriter(const Output& out)
{
	this->m_internal = mupdf::new_psd_band_writer(out.m_internal);
}

*/
/* Constructor using fz_new_pwg_band_writer(). */
/* Disabled because same args as fz_new_mono_pwg_band_writer.
BandWriter::BandWriter(const Output& out, PwgOptions& pwg)
{
	this->m_internal = mupdf::new_pwg_band_writer(out.m_internal, &pwg.m_internal);
}

*/
/* Custom constructor. */
BandWriter::BandWriter(Output& out, Cm cm, const PclOptions& options)
{
	fz_output*              out2 = out.m_internal;
	const fz_pcl_options*   options2 = options.m_internal;
	if (0)  {}
	else if (cm == MONO)    m_internal = mupdf::new_mono_pcl_band_writer( out2, options2);
	else if (cm == COLOR)   m_internal = mupdf::new_color_pcl_band_writer( out2, options2);
	else throw std::runtime_error( "Unrecognised fz_band_writer_s Cm type");
}

/* Custom constructor. */
BandWriter::BandWriter(Output& out, P p)
{
	fz_output*              out2 = out.m_internal;
	if (0)  {}
	else if (p == PNG)  m_internal = mupdf::new_png_band_writer( out2);
	else if (p == PNM)  m_internal = mupdf::new_pnm_band_writer( out2);
	else if (p == PAM)  m_internal = mupdf::new_pam_band_writer( out2);
	else if (p == PBM)  m_internal = mupdf::new_pbm_band_writer( out2);
	else if (p == PKM)  m_internal = mupdf::new_pkm_band_writer( out2);
	else if (p == PS)   m_internal = mupdf::new_ps_band_writer( out2);
	else if (p == PSD)  m_internal = mupdf::new_psd_band_writer( out2);
	else throw std::runtime_error( "Unrecognised fz_band_writer_s P type");
}

/* Custom constructor. */
BandWriter::BandWriter(Output& out, Cm cm, const PwgOptions& options)
{
	fz_output*              out2 = out.m_internal;
	const fz_pwg_options*   options2 = &options.m_internal;
	if (0)  {}
	else if (cm == MONO)    m_internal = mupdf::new_mono_pwg_band_writer( out2, options2);
	else if (cm == COLOR)   m_internal = mupdf::new_pwg_band_writer( out2, options2);
	else throw std::runtime_error( "Unrecognised fz_band_writer_s Cm type");
}

/* Wrapper for fz_write_band(). */
void BandWriter::write_band(int stride, int band_height, const unsigned char *samples)
{
	return mupdf::write_band(this->m_internal, stride, band_height, samples);
}

/* Wrapper for fz_write_header(). */
void BandWriter::write_header(int w, int h, int n, int alpha, int xres, int yres, int pagenum, const Colorspace& cs, const Separations& seps)
{
	return mupdf::write_header(this->m_internal, w, h, n, alpha, xres, yres, pagenum, cs.m_internal, seps.m_internal);
}

BandWriter::BandWriter(fz_band_writer* internal)
: m_internal(internal)
{
}

BandWriter::~BandWriter()
{
	mupdf::drop_band_writer(m_internal);
}

/* Implementation of Bitmap (wrapper for fz_bitmap). */

/* Constructor using fz_new_bitmap(). */
Bitmap::Bitmap(int w, int h, int n, int xres, int yres)
{
	this->m_internal = mupdf::new_bitmap(w, h, n, xres, yres);
}

/* Constructor using fz_new_bitmap_from_pixmap(). */
Bitmap::Bitmap(const Pixmap& pix, const Halftone& ht)
{
	this->m_internal = mupdf::new_bitmap_from_pixmap(pix.m_internal, ht.m_internal);
}

/* Constructor using fz_new_bitmap_from_pixmap_band(). */
Bitmap::Bitmap(const Pixmap& pix, const Halftone& ht, int band_start)
{
	this->m_internal = mupdf::new_bitmap_from_pixmap_band(pix.m_internal, ht.m_internal, band_start);
}

/* Copy constructor using fz_keep_bitmap(). */
Bitmap::Bitmap(const Bitmap& rhs)
: m_internal(mupdf::keep_bitmap(rhs.m_internal))
{
}

/* operator= using fz_keep_bitmap() and fz_drop_bitmap(). */
Bitmap& Bitmap::operator=(const Bitmap& rhs)
{
	mupdf::drop_bitmap(this->m_internal);
	mupdf::keep_bitmap(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_bitmap_details(). */
void Bitmap::bitmap_details(int *w, int *h, int *n, int *stride)
{
	return mupdf::bitmap_details(this->m_internal, w, h, n, stride);
}

/* Wrapper for fz_clear_bitmap(). */
void Bitmap::clear_bitmap()
{
	return mupdf::clear_bitmap(this->m_internal);
}

/* Wrapper for fz_save_bitmap_as_pbm(). */
void Bitmap::save_bitmap_as_pbm(const char *filename)
{
	return mupdf::save_bitmap_as_pbm(this->m_internal, filename);
}

/* Wrapper for fz_save_bitmap_as_pcl(). */
void Bitmap::save_bitmap_as_pcl(char *filename, int append, const PclOptions& pcl)
{
	return mupdf::save_bitmap_as_pcl(this->m_internal, filename, append, pcl.m_internal);
}

/* Wrapper for fz_save_bitmap_as_pkm(). */
void Bitmap::save_bitmap_as_pkm(const char *filename)
{
	return mupdf::save_bitmap_as_pkm(this->m_internal, filename);
}

/* Wrapper for fz_save_bitmap_as_pwg(). */
void Bitmap::save_bitmap_as_pwg(char *filename, int append, PwgOptions& pwg)
{
	return mupdf::save_bitmap_as_pwg(this->m_internal, filename, append, &pwg.m_internal);
}

Bitmap::Bitmap(fz_bitmap* internal)
: m_internal(internal)
{
}

Bitmap::~Bitmap()
{
	mupdf::drop_bitmap(m_internal);
}

/* Implementation of Buffer (wrapper for fz_buffer). */

/* Constructor using fz_new_buffer(). */
Buffer::Buffer(size_t capacity)
{
	this->m_internal = mupdf::new_buffer(capacity);
}

/* Constructor using fz_new_buffer_from_base64(). */
Buffer::Buffer(const char *data, size_t size)
{
	this->m_internal = mupdf::new_buffer_from_base64(data, size);
}

/* Constructor using fz_new_buffer_from_data(). */
Buffer::Buffer(unsigned char *data, size_t size)
{
	this->m_internal = mupdf::new_buffer_from_data(data, size);
}

/* Constructor using fz_new_buffer_from_display_list(). */
Buffer::Buffer(const DisplayList& list, StextOptions& options)
{
	this->m_internal = mupdf::new_buffer_from_display_list(list.m_internal, (const fz_stext_options *) &options.flags);
}

/* Constructor using fz_new_buffer_from_image_as_png(). */
Buffer::Buffer(const Image& image, ColorParams& color_params)
{
	this->m_internal = mupdf::new_buffer_from_image_as_png(image.m_internal, *(fz_color_params*) &color_params.ri);
}

/* Constructor using fz_new_buffer_from_page(). */
Buffer::Buffer(const Page& page, StextOptions& options)
{
	this->m_internal = mupdf::new_buffer_from_page(page.m_internal, (const fz_stext_options *) &options.flags);
}

/* Constructor using fz_new_buffer_from_page_number(). */
Buffer::Buffer(const Document& doc, int number, StextOptions& options)
{
	this->m_internal = mupdf::new_buffer_from_page_number(doc.m_internal, number, (const fz_stext_options *) &options.flags);
}

/* Constructor using fz_new_buffer_from_pixmap_as_png(). */
Buffer::Buffer(const Pixmap& pixmap, ColorParams& color_params)
{
	this->m_internal = mupdf::new_buffer_from_pixmap_as_png(pixmap.m_internal, *(fz_color_params*) &color_params.ri);
}

/* Constructor using fz_new_buffer_from_shared_data(). */
Buffer::Buffer(const unsigned char *data, size_t size)
{
	this->m_internal = mupdf::new_buffer_from_shared_data(data, size);
}

/* Constructor using fz_new_buffer_from_stext_page(). */
Buffer::Buffer(const StextPage& text)
{
	this->m_internal = mupdf::new_buffer_from_stext_page(text.m_internal);
}

/* Constructor using fz_read_file(). */
Buffer::Buffer(const char *filename)
{
	this->m_internal = mupdf::read_file(filename);
}

/* Copy constructor using fz_keep_buffer(). */
Buffer::Buffer(const Buffer& rhs)
: m_internal(mupdf::keep_buffer(rhs.m_internal))
{
}

/* operator= using fz_keep_buffer() and fz_drop_buffer(). */
Buffer& Buffer::operator=(const Buffer& rhs)
{
	mupdf::drop_buffer(this->m_internal);
	mupdf::keep_buffer(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_new_buffer_from_copied_data(). */
Buffer Buffer::new_buffer_from_copied_data(const unsigned char *data, size_t size)
{
	fz_buffer* temp = mupdf::new_buffer_from_copied_data(data, size);
	return Buffer(temp);
}

/* Wrapper for fz_append_bits(). */
void Buffer::append_bits(int value, int count)
{
	return mupdf::append_bits(this->m_internal, value, count);
}

/* Wrapper for fz_append_bits_pad(). */
void Buffer::append_bits_pad()
{
	return mupdf::append_bits_pad(this->m_internal);
}

/* Wrapper for fz_append_buffer(). */
void Buffer::append_buffer(const Buffer& source)
{
	return mupdf::append_buffer(this->m_internal, source.m_internal);
}

/* Wrapper for fz_append_byte(). */
void Buffer::append_byte(int c)
{
	return mupdf::append_byte(this->m_internal, c);
}

/* Wrapper for fz_append_data(). */
void Buffer::append_data(const void *data, size_t len)
{
	return mupdf::append_data(this->m_internal, data, len);
}

/* Wrapper for fz_append_int16_be(). */
void Buffer::append_int16_be(int x)
{
	return mupdf::append_int16_be(this->m_internal, x);
}

/* Wrapper for fz_append_int16_le(). */
void Buffer::append_int16_le(int x)
{
	return mupdf::append_int16_le(this->m_internal, x);
}

/* Wrapper for fz_append_int32_be(). */
void Buffer::append_int32_be(int x)
{
	return mupdf::append_int32_be(this->m_internal, x);
}

/* Wrapper for fz_append_int32_le(). */
void Buffer::append_int32_le(int x)
{
	return mupdf::append_int32_le(this->m_internal, x);
}

/* Wrapper for fz_append_pdf_string(). */
void Buffer::append_pdf_string(const char *text)
{
	return mupdf::append_pdf_string(this->m_internal, text);
}

/* Wrapper for fz_append_rune(). */
void Buffer::append_rune(int c)
{
	return mupdf::append_rune(this->m_internal, c);
}

/* Wrapper for fz_append_string(). */
void Buffer::append_string(const char *data)
{
	return mupdf::append_string(this->m_internal, data);
}

/* Wrapper for fz_append_vprintf(). */
void Buffer::append_vprintf(const char *fmt, va_list args)
{
	return mupdf::append_vprintf(this->m_internal, fmt, args);
}

/* Wrapper for fz_buffer_extract(). */
size_t Buffer::buffer_extract(unsigned char **data)
{
	return mupdf::buffer_extract(this->m_internal, data);
}

/* Wrapper for fz_buffer_storage(). */
size_t Buffer::buffer_storage(unsigned char **datap)
{
	return mupdf::buffer_storage(this->m_internal, datap);
}

/* Wrapper for fz_clear_buffer(). */
void Buffer::clear_buffer()
{
	return mupdf::clear_buffer(this->m_internal);
}

/* Wrapper for fz_grow_buffer(). */
void Buffer::grow_buffer()
{
	return mupdf::grow_buffer(this->m_internal);
}

/* Wrapper for fz_load_jbig2_globals(). */
Jbig2Globals Buffer::load_jbig2_globals()
{
	fz_jbig2_globals* temp = mupdf::load_jbig2_globals(this->m_internal);
	return Jbig2Globals(temp);
}

/* Wrapper for fz_md5_buffer(). */
void Buffer::md5_buffer(unsigned char digest[16])
{
	return mupdf::md5_buffer(this->m_internal, digest);
}

/* Wrapper for fz_new_display_list_from_svg(). */
DisplayList Buffer::new_display_list_from_svg(const char *base_uri, const Archive& zip, float *w, float *h)
{
	fz_display_list* temp = mupdf::new_display_list_from_svg(this->m_internal, base_uri, zip.m_internal, w, h);
	return DisplayList(temp);
}

/* Wrapper for fz_new_image_from_buffer(). */
Image Buffer::new_image_from_buffer()
{
	fz_image* temp = mupdf::new_image_from_buffer(this->m_internal);
	return Image(temp);
}

/* Wrapper for fz_new_image_from_svg(). */
Image Buffer::new_image_from_svg(const char *base_uri, const Archive& zip)
{
	fz_image* temp = mupdf::new_image_from_svg(this->m_internal, base_uri, zip.m_internal);
	return Image(temp);
}

/* Wrapper for fz_open_buffer(). */
Stream Buffer::open_buffer()
{
	fz_stream* temp = mupdf::open_buffer(this->m_internal);
	return Stream(temp);
}

/* Wrapper for fz_parse_xml(). */
XmlDoc Buffer::parse_xml(int preserve_white, int for_html)
{
	fz_xml_doc* temp = mupdf::parse_xml(this->m_internal, preserve_white, for_html);
	return XmlDoc(temp);
}

/* Wrapper for fz_resize_buffer(). */
void Buffer::resize_buffer(size_t capacity)
{
	return mupdf::resize_buffer(this->m_internal, capacity);
}

/* Wrapper for fz_save_buffer(). */
void Buffer::save_buffer(const char *filename)
{
	return mupdf::save_buffer(this->m_internal, filename);
}

/* Wrapper for fz_string_from_buffer(). */
const char *Buffer::string_from_buffer()
{
	return mupdf::string_from_buffer(this->m_internal);
}

/* Wrapper for fz_terminate_buffer(). */
void Buffer::terminate_buffer()
{
	return mupdf::terminate_buffer(this->m_internal);
}

/* Wrapper for fz_trim_buffer(). */
void Buffer::trim_buffer()
{
	return mupdf::trim_buffer(this->m_internal);
}

/* Wrapper for pdf_append_token(). */
void Buffer::pdf_append_token(int tok, const PdfLexbuf& lex)
{
	return mupdf::ppdf_append_token(this->m_internal, tok, lex.m_internal);
}

/* Wrapper for pdf_new_buffer_processor(). */
PdfProcessor Buffer::pdf_new_buffer_processor(int ahxencode)
{
	pdf_processor* temp = mupdf::ppdf_new_buffer_processor(this->m_internal, ahxencode);
	return PdfProcessor(temp);
}

Buffer::Buffer(fz_buffer* internal)
: m_internal(internal)
{
}

Buffer::~Buffer()
{
	mupdf::drop_buffer(m_internal);
}

/* Implementation of ColorParams (wrapper for fz_color_params). */

ColorParams::ColorParams(const fz_color_params* internal)
{
	this->ri = internal->ri;
	this->bp = internal->bp;
	this->op = internal->op;
	this->opm = internal->opm;
}

ColorParams::ColorParams(const fz_color_params internal)
{
	this->ri = internal.ri;
	this->bp = internal.bp;
	this->op = internal.op;
	this->opm = internal.opm;
}

/* Constructor using raw copy of pre-existing fz_color_params. */
fz_color_params* ColorParams::internal()
{
	return (fz_color_params*) &this->ri;
}

/* Constructor using raw copy of pre-existing fz_color_params. */
const fz_color_params* ColorParams::internal() const
{
	return (const fz_color_params*) &this->ri;
}

/* Implementation of Colorspace (wrapper for fz_colorspace). */

/* Constructor using fz_new_cal_gray_colorspace(). */
Colorspace::Colorspace(float wp[3], float bp[3], float gamma)
{
	this->m_internal = mupdf::new_cal_gray_colorspace(wp, bp, gamma);
}

/* Constructor using fz_new_cal_rgb_colorspace(). */
Colorspace::Colorspace(float wp[3], float bp[3], float gamma[3], float matrix[9])
{
	this->m_internal = mupdf::new_cal_rgb_colorspace(wp, bp, gamma, matrix);
}

/* Constructor using fz_new_colorspace(). */
Colorspace::Colorspace(enum fz_colorspace_type type, int flags, int n, const char *name)
{
	this->m_internal = mupdf::new_colorspace(type, flags, n, name);
}

/* Constructor using fz_new_icc_colorspace(). */
Colorspace::Colorspace(enum fz_colorspace_type type, int flags, const char *name, const Buffer& buf)
{
	this->m_internal = mupdf::new_icc_colorspace(type, flags, name, buf.m_internal);
}

/* Constructor using fz_new_indexed_colorspace(). */
Colorspace::Colorspace(const Colorspace& base, int high, unsigned char *lookup)
{
	this->m_internal = mupdf::new_indexed_colorspace(base.m_internal, high, lookup);
}

/* Custom constructor. */
Colorspace::Colorspace(Fixed fixed)
{
	if (0) {}
	else if ( fixed = Fixed_GRAY)   m_internal = mupdf::device_gray();
	else if ( fixed = Fixed_RGB)    m_internal = mupdf::device_rgb();
	else if ( fixed = Fixed_BGR)    m_internal = mupdf::device_bgr();
	else if ( fixed = Fixed_CMYK)   m_internal = mupdf::device_cmyk();
	else if ( fixed = Fixed_LAB)    m_internal = mupdf::device_lab();
	else {
		std::string message = "Unrecognised fixed colorspace id";
		throw ErrorGeneric(message.c_str());
	}
	mupdf::keep_colorspace(m_internal);
}

/* Custom constructor. */
Colorspace::Colorspace()
: m_internal( NULL)
{
}

/* Copy constructor using fz_keep_colorspace(). */
Colorspace::Colorspace(const Colorspace& rhs)
: m_internal(mupdf::keep_colorspace(rhs.m_internal))
{
}

/* operator= using fz_keep_colorspace() and fz_drop_colorspace(). */
Colorspace& Colorspace::operator=(const Colorspace& rhs)
{
	mupdf::drop_colorspace(this->m_internal);
	mupdf::keep_colorspace(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_clamp_color(). */
void Colorspace::clamp_color(const float *in, float *out)
{
	return mupdf::clamp_color(this->m_internal, in, out);
}

/* Wrapper for fz_colorspace_colorant(). */
const char *Colorspace::colorspace_colorant(int n)
{
	return mupdf::colorspace_colorant(this->m_internal, n);
}

/* Wrapper for fz_colorspace_device_n_has_cmyk(). */
int Colorspace::colorspace_device_n_has_cmyk()
{
	return mupdf::colorspace_device_n_has_cmyk(this->m_internal);
}

/* Wrapper for fz_colorspace_device_n_has_only_cmyk(). */
int Colorspace::colorspace_device_n_has_only_cmyk()
{
	return mupdf::colorspace_device_n_has_only_cmyk(this->m_internal);
}

/* Wrapper for fz_colorspace_is_cmyk(). */
int Colorspace::colorspace_is_cmyk()
{
	return mupdf::colorspace_is_cmyk(this->m_internal);
}

/* Wrapper for fz_colorspace_is_device(). */
int Colorspace::colorspace_is_device()
{
	return mupdf::colorspace_is_device(this->m_internal);
}

/* Wrapper for fz_colorspace_is_device_cmyk(). */
int Colorspace::colorspace_is_device_cmyk()
{
	return mupdf::colorspace_is_device_cmyk(this->m_internal);
}

/* Wrapper for fz_colorspace_is_device_gray(). */
int Colorspace::colorspace_is_device_gray()
{
	return mupdf::colorspace_is_device_gray(this->m_internal);
}

/* Wrapper for fz_colorspace_is_device_n(). */
int Colorspace::colorspace_is_device_n()
{
	return mupdf::colorspace_is_device_n(this->m_internal);
}

/* Wrapper for fz_colorspace_is_gray(). */
int Colorspace::colorspace_is_gray()
{
	return mupdf::colorspace_is_gray(this->m_internal);
}

/* Wrapper for fz_colorspace_is_indexed(). */
int Colorspace::colorspace_is_indexed()
{
	return mupdf::colorspace_is_indexed(this->m_internal);
}

/* Wrapper for fz_colorspace_is_lab(). */
int Colorspace::colorspace_is_lab()
{
	return mupdf::colorspace_is_lab(this->m_internal);
}

/* Wrapper for fz_colorspace_is_lab_icc(). */
int Colorspace::colorspace_is_lab_icc()
{
	return mupdf::colorspace_is_lab_icc(this->m_internal);
}

/* Wrapper for fz_colorspace_is_rgb(). */
int Colorspace::colorspace_is_rgb()
{
	return mupdf::colorspace_is_rgb(this->m_internal);
}

/* Wrapper for fz_colorspace_is_subtractive(). */
int Colorspace::colorspace_is_subtractive()
{
	return mupdf::colorspace_is_subtractive(this->m_internal);
}

/* Wrapper for fz_colorspace_n(). */
int Colorspace::colorspace_n()
{
	return mupdf::colorspace_n(this->m_internal);
}

/* Wrapper for fz_colorspace_name(). */
const char *Colorspace::colorspace_name()
{
	return mupdf::colorspace_name(this->m_internal);
}

/* Wrapper for fz_colorspace_name_colorant(). */
void Colorspace::colorspace_name_colorant(int n, const char *name)
{
	return mupdf::colorspace_name_colorant(this->m_internal, n, name);
}

/* Wrapper for fz_colorspace_type(). */
enum fz_colorspace_type Colorspace::colorspace_type()
{
	return mupdf::colorspace_type(this->m_internal);
}

/* Wrapper for fz_convert_color(). */
void Colorspace::convert_color(const float *sv, const Colorspace& ds, float *dv, const Colorspace& is, ColorParams& params)
{
	return mupdf::convert_color(this->m_internal, sv, ds.m_internal, dv, is.m_internal, *(fz_color_params*) ¶ms.ri);
}

/* Wrapper for fz_convert_separation_colors(). */
void Colorspace::convert_separation_colors(const float *src_color, const Separations& dst_seps, const Colorspace& dst_cs, float *dst_color, ColorParams& color_params)
{
	return mupdf::convert_separation_colors(this->m_internal, src_color, dst_seps.m_internal, dst_cs.m_internal, dst_color, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for fz_is_valid_blend_colorspace(). */
int Colorspace::is_valid_blend_colorspace()
{
	return mupdf::is_valid_blend_colorspace(this->m_internal);
}

/* Wrapper for fz_new_indexed_colorspace(). */
Colorspace Colorspace::new_indexed_colorspace(int high, unsigned char *lookup)
{
	fz_colorspace* temp = mupdf::new_indexed_colorspace(this->m_internal, high, lookup);
	return Colorspace(temp);
}

/* Wrapper for fz_new_pixmap(). */
Pixmap Colorspace::new_pixmap(int w, int h, const Separations& seps, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap(this->m_internal, w, h, seps.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_new_pixmap_with_bbox(). */
Pixmap Colorspace::new_pixmap_with_bbox(Irect& bbox, const Separations& seps, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_with_bbox(this->m_internal, *(fz_irect*) &bbox.x0, seps.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_new_pixmap_with_bbox_and_data(). */
Pixmap Colorspace::new_pixmap_with_bbox_and_data(Irect& rect, const Separations& seps, int alpha, unsigned char *samples)
{
	fz_pixmap* temp = mupdf::new_pixmap_with_bbox_and_data(this->m_internal, *(fz_irect*) &rect.x0, seps.m_internal, alpha, samples);
	return Pixmap(temp);
}

/* Wrapper for fz_new_pixmap_with_data(). */
Pixmap Colorspace::new_pixmap_with_data(int w, int h, const Separations& seps, int alpha, int stride, unsigned char *samples)
{
	fz_pixmap* temp = mupdf::new_pixmap_with_data(this->m_internal, w, h, seps.m_internal, alpha, stride, samples);
	return Pixmap(temp);
}

/* Wrapper for pdf_is_tint_colorspace(). */
int Colorspace::pdf_is_tint_colorspace()
{
	return mupdf::ppdf_is_tint_colorspace(this->m_internal);
}

Colorspace::Colorspace(fz_colorspace* internal)
: m_internal(internal)
{
}

Colorspace::~Colorspace()
{
	mupdf::drop_colorspace(m_internal);
}

/* Implementation of ColorspaceContext (wrapper for fz_colorspace_context). */

ColorspaceContext::ColorspaceContext(fz_colorspace_context* internal)
: m_internal(internal)
{
}

/* Implementation of CompressedBuffer (wrapper for fz_compressed_buffer). */

/* Wrapper for fz_compressed_buffer_size(). */
size_t CompressedBuffer::compressed_buffer_size()
{
	return mupdf::compressed_buffer_size(this->m_internal);
}

/* Wrapper for fz_open_compressed_buffer(). */
Stream CompressedBuffer::open_compressed_buffer()
{
	fz_stream* temp = mupdf::open_compressed_buffer(this->m_internal);
	return Stream(temp);
}

/* Wrapper for fz_open_image_decomp_stream_from_buffer(). */
Stream CompressedBuffer::open_image_decomp_stream_from_buffer(int *l2factor)
{
	fz_stream* temp = mupdf::open_image_decomp_stream_from_buffer(this->m_internal, l2factor);
	return Stream(temp);
}

CompressedBuffer::CompressedBuffer(fz_compressed_buffer* internal)
: m_internal(internal)
{
}

CompressedBuffer::~CompressedBuffer()
{
	mupdf::drop_compressed_buffer(m_internal);
}

/* Implementation of CompressedImage (wrapper for fz_compressed_image). */

/* Wrapper for fz_set_compressed_image_buffer(). */
void CompressedImage::set_compressed_image_buffer(const CompressedBuffer& buf)
{
	return mupdf::set_compressed_image_buffer(this->m_internal, buf.m_internal);
}

CompressedImage::CompressedImage(fz_compressed_image* internal)
: m_internal(internal)
{
}

/* Implementation of CompressionParams (wrapper for fz_compression_params). */

CompressionParams::CompressionParams(fz_compression_params* internal)
: m_internal(internal)
{
}

/* Implementation of Context (wrapper for fz_context). */

/* Constructor using fz_new_context_imp(). */
Context::Context(const AllocContext& alloc, const LocksContext& locks, size_t max_store, const char *version)
{
	this->m_internal = mupdf::new_context_imp(alloc.m_internal, locks.m_internal, max_store, version);
}

Context::Context(fz_context* internal)
: m_internal(internal)
{
}

/* Implementation of Cookie (wrapper for fz_cookie). */

/* Custom constructor. */
Cookie::Cookie()
{
	this->m_internal.abort = 0;
	this->m_internal.progress = 0;
	this->m_internal.progress_max = (size_t) -1;
	this->m_internal.errors = 0;
	this->m_internal.incomplete = 0;
}

/* Custom method. */
void Cookie::set_abort(){ m_internal.abort = 1; }

/* Custom method. */
int Cookie::get_progress(){ return m_internal.progress; }

/* Custom method. */
size_t Cookie::get_progress_max(){ return m_internal.progress_max; }

/* Custom method. */
int Cookie::get_errors(){ return m_internal.errors; }

/* Custom method. */
int Cookie::get_incomplete(){ return m_internal.incomplete; }

/* Custom method. */
void Cookie::increment_errors(){ m_internal.errors += 1; }

Cookie::Cookie(const fz_cookie* internal)
: m_internal(*internal)
{
}

int Cookie::abort()
{
	return m_internal.abort;
}

int Cookie::progress()
{
	return m_internal.progress;
}

size_t Cookie::progress_max()
{
	return m_internal.progress_max;
}

int Cookie::errors()
{
	return m_internal.errors;
}

int Cookie::incomplete()
{
	return m_internal.incomplete;
}

/* Implementation of DefaultColorspaces (wrapper for fz_default_colorspaces). */

/* Constructor using fz_new_default_colorspaces(). */
DefaultColorspaces::DefaultColorspaces()
{
	this->m_internal = mupdf::new_default_colorspaces();
}

/* Copy constructor using fz_keep_default_colorspaces(). */
DefaultColorspaces::DefaultColorspaces(const DefaultColorspaces& rhs)
: m_internal(mupdf::keep_default_colorspaces(rhs.m_internal))
{
}

/* operator= using fz_keep_default_colorspaces() and fz_drop_default_colorspaces(). */
DefaultColorspaces& DefaultColorspaces::operator=(const DefaultColorspaces& rhs)
{
	mupdf::drop_default_colorspaces(this->m_internal);
	mupdf::keep_default_colorspaces(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_clone_default_colorspaces(). */
DefaultColorspaces DefaultColorspaces::clone_default_colorspaces()
{
	fz_default_colorspaces* temp = mupdf::clone_default_colorspaces(this->m_internal);
	return DefaultColorspaces(temp);
}

/* Wrapper for fz_default_cmyk(). */
Colorspace DefaultColorspaces::default_cmyk()
{
	fz_colorspace* temp = mupdf::default_cmyk(this->m_internal);
	mupdf::keep_colorspace(temp);
	return Colorspace(temp);
}

/* Wrapper for fz_default_gray(). */
Colorspace DefaultColorspaces::default_gray()
{
	fz_colorspace* temp = mupdf::default_gray(this->m_internal);
	return Colorspace(temp);
}

/* Wrapper for fz_default_output_intent(). */
Colorspace DefaultColorspaces::default_output_intent()
{
	fz_colorspace* temp = mupdf::default_output_intent(this->m_internal);
	mupdf::keep_colorspace(temp);
	return Colorspace(temp);
}

/* Wrapper for fz_default_rgb(). */
Colorspace DefaultColorspaces::default_rgb()
{
	fz_colorspace* temp = mupdf::default_rgb(this->m_internal);
	mupdf::keep_colorspace(temp);
	return Colorspace(temp);
}

/* Wrapper for fz_set_default_cmyk(). */
void DefaultColorspaces::set_default_cmyk(const Colorspace& cs)
{
	return mupdf::set_default_cmyk(this->m_internal, cs.m_internal);
}

/* Wrapper for fz_set_default_gray(). */
void DefaultColorspaces::set_default_gray(const Colorspace& cs)
{
	return mupdf::set_default_gray(this->m_internal, cs.m_internal);
}

/* Wrapper for fz_set_default_output_intent(). */
void DefaultColorspaces::set_default_output_intent(const Colorspace& cs)
{
	return mupdf::set_default_output_intent(this->m_internal, cs.m_internal);
}

/* Wrapper for fz_set_default_rgb(). */
void DefaultColorspaces::set_default_rgb(const Colorspace& cs)
{
	return mupdf::set_default_rgb(this->m_internal, cs.m_internal);
}

/* Wrapper for pdf_update_default_colorspaces(). */
DefaultColorspaces DefaultColorspaces::pdf_update_default_colorspaces(const PdfObj& res)
{
	fz_default_colorspaces* temp = mupdf::ppdf_update_default_colorspaces(this->m_internal, res.m_internal);
	return DefaultColorspaces(temp);
}

DefaultColorspaces::DefaultColorspaces(fz_default_colorspaces* internal)
: m_internal(internal)
{
}

DefaultColorspaces::~DefaultColorspaces()
{
	mupdf::drop_default_colorspaces(m_internal);
}

/* Implementation of Device (wrapper for fz_device). */

/* Constructor using fz_new_bbox_device(). */
Device::Device(Rect& rectp)
{
	this->m_internal = mupdf::new_bbox_device((fz_rect *) &rectp.x0);
}

/* Constructor using fz_new_device_of_size(). */
Device::Device(int size)
{
	this->m_internal = mupdf::new_device_of_size(size);
}

/* Constructor using fz_new_draw_device(). */
Device::Device(Matrix& transform, const Pixmap& dest)
{
	this->m_internal = mupdf::new_draw_device(*(fz_matrix*) &transform.a, dest.m_internal);
}

/* Constructor using fz_new_draw_device_with_bbox(). */
Device::Device(Matrix& transform, const Pixmap& dest, Irect& clip)
{
	this->m_internal = mupdf::new_draw_device_with_bbox(*(fz_matrix*) &transform.a, dest.m_internal, (const fz_irect *) &clip.x0);
}

/* Constructor using fz_new_draw_device_with_bbox_proof(). */
Device::Device(Matrix& transform, const Pixmap& dest, Irect& clip, const Colorspace& cs)
{
	this->m_internal = mupdf::new_draw_device_with_bbox_proof(*(fz_matrix*) &transform.a, dest.m_internal, (const fz_irect *) &clip.x0, cs.m_internal);
}

/* Constructor using fz_new_draw_device_with_proof(). */
Device::Device(Matrix& transform, const Pixmap& dest, const Colorspace& proof_cs)
{
	this->m_internal = mupdf::new_draw_device_with_proof(*(fz_matrix*) &transform.a, dest.m_internal, proof_cs.m_internal);
}

/* Constructor using fz_new_list_device(). */
Device::Device(const DisplayList& list)
{
	this->m_internal = mupdf::new_list_device(list.m_internal);
}

/* Constructor using fz_new_stext_device(). */
Device::Device(const StextPage& page, StextOptions& options)
{
	this->m_internal = mupdf::new_stext_device(page.m_internal, (const fz_stext_options *) &options.flags);
}

/* Constructor using fz_new_svg_device(). */
Device::Device(const Output& out, float page_width, float page_height, int text_format, int reuse_images)
{
	this->m_internal = mupdf::new_svg_device(out.m_internal, page_width, page_height, text_format, reuse_images);
}

/* Constructor using fz_new_svg_device_with_id(). */
Device::Device(const Output& out, float page_width, float page_height, int text_format, int reuse_images, int *id)
{
	this->m_internal = mupdf::new_svg_device_with_id(out.m_internal, page_width, page_height, text_format, reuse_images, id);
}

/* Constructor using fz_new_test_device(). */
Device::Device(int *is_color, float threshold, int options, const Device& passthrough)
{
	this->m_internal = mupdf::new_test_device(is_color, threshold, options, passthrough.m_internal);
}

/* Constructor using fz_new_trace_device(). */
Device::Device(const Output& out)
{
	this->m_internal = mupdf::new_trace_device(out.m_internal);
}

/* Custom constructor. */
Device::Device()
: m_internal( NULL)
{
}

/* Copy constructor using fz_keep_device(). */
Device::Device(const Device& rhs)
: m_internal(mupdf::keep_device(rhs.m_internal))
{
}

/* operator= using fz_keep_device() and fz_drop_device(). */
Device& Device::operator=(const Device& rhs)
{
	mupdf::drop_device(this->m_internal);
	mupdf::keep_device(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_new_draw_device_type3(). */
Device Device::new_draw_device_type3(Matrix& transform, const Pixmap& dest)
{
	fz_device* temp = mupdf::new_draw_device_type3(*(fz_matrix*) &transform.a, dest.m_internal);
	return Device(temp);
}

/* Wrapper for fz_begin_group(). */
void Device::begin_group(Rect& area, const Colorspace& cs, int isolated, int knockout, int blendmode, float alpha)
{
	return mupdf::begin_group(this->m_internal, *(fz_rect*) &area.x0, cs.m_internal, isolated, knockout, blendmode, alpha);
}

/* Wrapper for fz_begin_layer(). */
void Device::begin_layer(const char *layer_name)
{
	return mupdf::begin_layer(this->m_internal, layer_name);
}

/* Wrapper for fz_begin_mask(). */
void Device::begin_mask(Rect& area, int luminosity, const Colorspace& colorspace, const float *bc, ColorParams& color_params)
{
	return mupdf::begin_mask(this->m_internal, *(fz_rect*) &area.x0, luminosity, colorspace.m_internal, bc, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for fz_begin_tile(). */
void Device::begin_tile(Rect& area, Rect& view, float xstep, float ystep, Matrix& ctm)
{
	return mupdf::begin_tile(this->m_internal, *(fz_rect*) &area.x0, *(fz_rect*) &view.x0, xstep, ystep, *(fz_matrix*) &ctm.a);
}

/* Wrapper for fz_begin_tile_id(). */
int Device::begin_tile_id(Rect& area, Rect& view, float xstep, float ystep, Matrix& ctm, int id)
{
	return mupdf::begin_tile_id(this->m_internal, *(fz_rect*) &area.x0, *(fz_rect*) &view.x0, xstep, ystep, *(fz_matrix*) &ctm.a, id);
}

/* Wrapper for fz_clip_image_mask(). */
void Device::clip_image_mask(const Image& image, Matrix& ctm, Rect& scissor)
{
	return mupdf::clip_image_mask(this->m_internal, image.m_internal, *(fz_matrix*) &ctm.a, *(fz_rect*) &scissor.x0);
}

/* Wrapper for fz_clip_path(). */
void Device::clip_path(const Path& path, int even_odd, Matrix& ctm, Rect& scissor)
{
	return mupdf::clip_path(this->m_internal, path.m_internal, even_odd, *(fz_matrix*) &ctm.a, *(fz_rect*) &scissor.x0);
}

/* Wrapper for fz_clip_stroke_path(). */
void Device::clip_stroke_path(const Path& path, const StrokeState& stroke, Matrix& ctm, Rect& scissor)
{
	return mupdf::clip_stroke_path(this->m_internal, path.m_internal, stroke.m_internal, *(fz_matrix*) &ctm.a, *(fz_rect*) &scissor.x0);
}

/* Wrapper for fz_clip_stroke_text(). */
void Device::clip_stroke_text(const Text& text, const StrokeState& stroke, Matrix& ctm, Rect& scissor)
{
	return mupdf::clip_stroke_text(this->m_internal, text.m_internal, stroke.m_internal, *(fz_matrix*) &ctm.a, *(fz_rect*) &scissor.x0);
}

/* Wrapper for fz_clip_text(). */
void Device::clip_text(const Text& text, Matrix& ctm, Rect& scissor)
{
	return mupdf::clip_text(this->m_internal, text.m_internal, *(fz_matrix*) &ctm.a, *(fz_rect*) &scissor.x0);
}

/* Wrapper for fz_close_device(). */
void Device::close_device()
{
	return mupdf::close_device(this->m_internal);
}

/* Wrapper for fz_device_current_scissor(). */
Rect Device::device_current_scissor()
{
	fz_rect temp = mupdf::device_current_scissor(this->m_internal);
	return Rect(&temp);
}

/* Wrapper for fz_disable_device_hints(). */
void Device::disable_device_hints(int hints)
{
	return mupdf::disable_device_hints(this->m_internal, hints);
}

/* Wrapper for fz_enable_device_hints(). */
void Device::enable_device_hints(int hints)
{
	return mupdf::enable_device_hints(this->m_internal, hints);
}

/* Wrapper for fz_end_group(). */
void Device::end_group()
{
	return mupdf::end_group(this->m_internal);
}

/* Wrapper for fz_end_layer(). */
void Device::end_layer()
{
	return mupdf::end_layer(this->m_internal);
}

/* Wrapper for fz_end_mask(). */
void Device::end_mask()
{
	return mupdf::end_mask(this->m_internal);
}

/* Wrapper for fz_end_tile(). */
void Device::end_tile()
{
	return mupdf::end_tile(this->m_internal);
}

/* Wrapper for fz_fill_image(). */
void Device::fill_image(const Image& image, Matrix& ctm, float alpha, ColorParams& color_params)
{
	return mupdf::fill_image(this->m_internal, image.m_internal, *(fz_matrix*) &ctm.a, alpha, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for fz_fill_image_mask(). */
void Device::fill_image_mask(const Image& image, Matrix& ctm, const Colorspace& colorspace, const float *color, float alpha, ColorParams& color_params)
{
	return mupdf::fill_image_mask(this->m_internal, image.m_internal, *(fz_matrix*) &ctm.a, colorspace.m_internal, color, alpha, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for fz_fill_path(). */
void Device::fill_path(const Path& path, int even_odd, Matrix& ctm, const Colorspace& colorspace, const float *color, float alpha, ColorParams& color_params)
{
	return mupdf::fill_path(this->m_internal, path.m_internal, even_odd, *(fz_matrix*) &ctm.a, colorspace.m_internal, color, alpha, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for fz_fill_shade(). */
void Device::fill_shade(const Shade& shade, Matrix& ctm, float alpha, ColorParams& color_params)
{
	return mupdf::fill_shade(this->m_internal, shade.m_internal, *(fz_matrix*) &ctm.a, alpha, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for fz_fill_text(). */
void Device::fill_text(const Text& text, Matrix& ctm, const Colorspace& colorspace, const float *color, float alpha, ColorParams& color_params)
{
	return mupdf::fill_text(this->m_internal, text.m_internal, *(fz_matrix*) &ctm.a, colorspace.m_internal, color, alpha, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for fz_ignore_text(). */
void Device::ignore_text(const Text& text, Matrix& ctm)
{
	return mupdf::ignore_text(this->m_internal, text.m_internal, *(fz_matrix*) &ctm.a);
}

/* Wrapper for fz_pop_clip(). */
void Device::pop_clip()
{
	return mupdf::pop_clip(this->m_internal);
}

/* Wrapper for fz_render_flags(). */
void Device::render_flags(int set, int clear)
{
	return mupdf::render_flags(this->m_internal, set, clear);
}

/* Wrapper for fz_render_t3_glyph_direct(). */
void Device::render_t3_glyph_direct(const Font& font, int gid, Matrix& trm, void *gstate, const DefaultColorspaces& def_cs)
{
	return mupdf::render_t3_glyph_direct(this->m_internal, font.m_internal, gid, *(fz_matrix*) &trm.a, gstate, def_cs.m_internal);
}

/* Wrapper for fz_set_default_colorspaces(). */
void Device::set_default_colorspaces(const DefaultColorspaces& default_cs)
{
	return mupdf::set_default_colorspaces(this->m_internal, default_cs.m_internal);
}

/* Wrapper for fz_stroke_path(). */
void Device::stroke_path(const Path& path, const StrokeState& stroke, Matrix& ctm, const Colorspace& colorspace, const float *color, float alpha, ColorParams& color_params)
{
	return mupdf::stroke_path(this->m_internal, path.m_internal, stroke.m_internal, *(fz_matrix*) &ctm.a, colorspace.m_internal, color, alpha, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for fz_stroke_text(). */
void Device::stroke_text(const Text& text, const StrokeState& stroke, Matrix& ctm, const Colorspace& colorspace, const float *color, float alpha, ColorParams& color_params)
{
	return mupdf::stroke_text(this->m_internal, text.m_internal, stroke.m_internal, *(fz_matrix*) &ctm.a, colorspace.m_internal, color, alpha, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for pdf_new_run_processor(). */
PdfProcessor Device::pdf_new_run_processor(Matrix& ctm, const char *usage, const PdfGstate& gstate, const DefaultColorspaces& default_cs, Cookie& cookie)
{
	pdf_processor* temp = mupdf::ppdf_new_run_processor(this->m_internal, *(fz_matrix*) &ctm.a, usage, gstate.m_internal, default_cs.m_internal, &cookie.m_internal);
	return PdfProcessor(temp);
}

Device::Device(fz_device* internal)
: m_internal(internal)
{
}

Device::~Device()
{
	mupdf::drop_device(m_internal);
}

/* Implementation of DeviceContainerStack (wrapper for fz_device_container_stack). */

DeviceContainerStack::DeviceContainerStack(fz_device_container_stack* internal)
: m_internal(internal)
{
}

/* Implementation of DisplayList (wrapper for fz_display_list). */

/* Constructor using fz_new_display_list(). */
DisplayList::DisplayList(Rect& mediabox)
{
	this->m_internal = mupdf::new_display_list(*(fz_rect*) &mediabox.x0);
}

/* Constructor using fz_new_display_list_from_page(). */
DisplayList::DisplayList(const Page& page)
{
	this->m_internal = mupdf::new_display_list_from_page(page.m_internal);
}

/* Constructor using fz_new_display_list_from_page_number(). */
DisplayList::DisplayList(const Document& doc, int number)
{
	this->m_internal = mupdf::new_display_list_from_page_number(doc.m_internal, number);
}

/* Constructor using fz_new_display_list_from_svg(). */
DisplayList::DisplayList(const Buffer& buf, const char *base_uri, const Archive& zip, float *w, float *h)
{
	this->m_internal = mupdf::new_display_list_from_svg(buf.m_internal, base_uri, zip.m_internal, w, h);
}

/* Constructor using fz_new_display_list_from_svg_xml(). */
DisplayList::DisplayList(const Xml& xml, const char *base_uri, const Archive& zip, float *w, float *h)
{
	this->m_internal = mupdf::new_display_list_from_svg_xml(xml.m_internal, base_uri, zip.m_internal, w, h);
}

/* Copy constructor using fz_keep_display_list(). */
DisplayList::DisplayList(const DisplayList& rhs)
: m_internal(mupdf::keep_display_list(rhs.m_internal))
{
}

/* operator= using fz_keep_display_list() and fz_drop_display_list(). */
DisplayList& DisplayList::operator=(const DisplayList& rhs)
{
	mupdf::drop_display_list(this->m_internal);
	mupdf::keep_display_list(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_new_display_list_from_page_contents(). */
DisplayList DisplayList::new_display_list_from_page_contents(const Page& page)
{
	fz_display_list* temp = mupdf::new_display_list_from_page_contents(page.m_internal);
	return DisplayList(temp);
}

/* Wrapper for fz_bound_display_list(). */
Rect DisplayList::bound_display_list()
{
	fz_rect temp = mupdf::bound_display_list(this->m_internal);
	return Rect(&temp);
}

/* Wrapper for fz_display_list_is_empty(). */
int DisplayList::display_list_is_empty()
{
	return mupdf::display_list_is_empty(this->m_internal);
}

/* Wrapper for fz_new_buffer_from_display_list(). */
Buffer DisplayList::new_buffer_from_display_list(StextOptions& options)
{
	fz_buffer* temp = mupdf::new_buffer_from_display_list(this->m_internal, (const fz_stext_options *) &options.flags);
	return Buffer(temp);
}

/* Wrapper for fz_new_list_device(). */
Device DisplayList::new_list_device()
{
	fz_device* temp = mupdf::new_list_device(this->m_internal);
	return Device(temp);
}

/* Wrapper for fz_new_pixmap_from_display_list(). */
Pixmap DisplayList::new_pixmap_from_display_list(Matrix& ctm, const Colorspace& cs, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_display_list(this->m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_new_pixmap_from_display_list_with_separations(). */
Pixmap DisplayList::new_pixmap_from_display_list_with_separations(Matrix& ctm, const Colorspace& cs, const Separations& seps, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_display_list_with_separations(this->m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, seps.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_run_display_list(). */
void DisplayList::run_display_list(const Device& dev, Matrix& ctm, Rect& scissor, Cookie& cookie)
{
	return mupdf::run_display_list(this->m_internal, dev.m_internal, *(fz_matrix*) &ctm.a, *(fz_rect*) &scissor.x0, &cookie.m_internal);
}

/* Wrapper for fz_search_display_list(). */
int DisplayList::search_display_list(const char *needle, Quad& hit_bbox, int hit_max)
{
	return mupdf::search_display_list(this->m_internal, needle, (fz_quad *) &hit_bbox.ul, hit_max);
}

DisplayList::DisplayList(fz_display_list* internal)
: m_internal(internal)
{
}

DisplayList::~DisplayList()
{
	mupdf::drop_display_list(m_internal);
}

/* Implementation of Document (wrapper for fz_document). */

/* Constructor using fz_open_accelerated_document(). */
Document::Document(const char *filename, const char *accel)
{
	this->m_internal = mupdf::open_accelerated_document(filename, accel);
}

/* Constructor using fz_open_accelerated_document_with_stream(). */
Document::Document(const char *magic, const Stream& stream, const Stream& accel)
{
	this->m_internal = mupdf::open_accelerated_document_with_stream(magic, stream.m_internal, accel.m_internal);
}

/* Constructor using fz_open_document(). */
Document::Document(const char *filename)
{
	this->m_internal = mupdf::open_document(filename);
}

/* Constructor using fz_open_document_with_stream(). */
Document::Document(const char *magic, const Stream& stream)
{
	this->m_internal = mupdf::open_document_with_stream(magic, stream.m_internal);
}

/* Copy constructor using fz_keep_document(). */
Document::Document(const Document& rhs)
: m_internal(mupdf::keep_document(rhs.m_internal))
{
}

/* operator= using fz_keep_document() and fz_drop_document(). */
Document& Document::operator=(const Document& rhs)
{
	mupdf::drop_document(this->m_internal);
	mupdf::keep_document(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_new_xhtml_document_from_document(). */
Document Document::new_xhtml_document_from_document(const Document& old_doc)
{
	fz_document* temp = mupdf::new_xhtml_document_from_document(old_doc.m_internal);
	return Document(temp);
}

/* Wrapper for fz_authenticate_password(). */
int Document::authenticate_password(const char *password)
{
	return mupdf::authenticate_password(this->m_internal, password);
}

/* Wrapper for fz_clamp_location(). */
Location Document::clamp_location(Location& loc)
{
	fz_location temp = mupdf::clamp_location(this->m_internal, *(fz_location*) &loc.chapter);
	return Location(&temp);
}

/* Wrapper for fz_count_chapter_pages(). */
int Document::count_chapter_pages(int chapter)
{
	return mupdf::count_chapter_pages(this->m_internal, chapter);
}

/* Wrapper for fz_count_chapters(). */
int Document::count_chapters()
{
	return mupdf::count_chapters(this->m_internal);
}

/* Wrapper for fz_count_pages(). */
int Document::count_pages()
{
	return mupdf::count_pages(this->m_internal);
}

/* Wrapper for fz_document_output_intent(). */
Colorspace Document::document_output_intent()
{
	fz_colorspace* temp = mupdf::document_output_intent(this->m_internal);
	mupdf::keep_colorspace(temp);
	return Colorspace(temp);
}

/* Wrapper for fz_document_supports_accelerator(). */
int Document::document_supports_accelerator()
{
	return mupdf::document_supports_accelerator(this->m_internal);
}

/* Wrapper for fz_has_permission(). */
int Document::has_permission(fz_permission p)
{
	return mupdf::has_permission(this->m_internal, p);
}

/* Wrapper for fz_is_document_reflowable(). */
int Document::is_document_reflowable()
{
	return mupdf::is_document_reflowable(this->m_internal);
}

/* Wrapper for fz_last_page(). */
Location Document::last_page()
{
	fz_location temp = mupdf::last_page(this->m_internal);
	return Location(&temp);
}

/* Wrapper for fz_layout_document(). */
void Document::layout_document(float w, float h, float em)
{
	return mupdf::layout_document(this->m_internal, w, h, em);
}

/* Wrapper for fz_load_chapter_page(). */
Page Document::load_chapter_page(int chapter, int page)
{
	fz_page* temp = mupdf::load_chapter_page(this->m_internal, chapter, page);
	return Page(temp);
}

/* Wrapper for fz_load_page(). */
Page Document::load_page(int number)
{
	fz_page* temp = mupdf::load_page(this->m_internal, number);
	return Page(temp);
}

/* Wrapper for fz_location_from_page_number(). */
Location Document::location_from_page_number(int number)
{
	fz_location temp = mupdf::location_from_page_number(this->m_internal, number);
	return Location(&temp);
}

/* Wrapper for fz_lookup_bookmark(). */
Location Document::lookup_bookmark(fz_bookmark mark)
{
	fz_location temp = mupdf::lookup_bookmark(this->m_internal, mark);
	return Location(&temp);
}

/* Wrapper for fz_lookup_metadata(). */
int Document::lookup_metadata(const char *key, char *buf, int size)
{
	return mupdf::lookup_metadata(this->m_internal, key, buf, size);
}

/* Wrapper for fz_make_bookmark(). */
fz_bookmark Document::make_bookmark(Location& loc)
{
	return mupdf::make_bookmark(this->m_internal, *(fz_location*) &loc.chapter);
}

/* Wrapper for fz_needs_password(). */
int Document::needs_password()
{
	return mupdf::needs_password(this->m_internal);
}

/* Wrapper for fz_new_buffer_from_page_number(). */
Buffer Document::new_buffer_from_page_number(int number, StextOptions& options)
{
	fz_buffer* temp = mupdf::new_buffer_from_page_number(this->m_internal, number, (const fz_stext_options *) &options.flags);
	return Buffer(temp);
}

/* Wrapper for fz_new_display_list_from_page_number(). */
DisplayList Document::new_display_list_from_page_number(int number)
{
	fz_display_list* temp = mupdf::new_display_list_from_page_number(this->m_internal, number);
	return DisplayList(temp);
}

/* Wrapper for fz_new_pixmap_from_page_number(). */
Pixmap Document::new_pixmap_from_page_number(int number, Matrix& ctm, const Colorspace& cs, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_page_number(this->m_internal, number, *(fz_matrix*) &ctm.a, cs.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_new_pixmap_from_page_number_with_separations(). */
Pixmap Document::new_pixmap_from_page_number_with_separations(int number, Matrix& ctm, const Colorspace& cs, const Separations& seps, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_page_number_with_separations(this->m_internal, number, *(fz_matrix*) &ctm.a, cs.m_internal, seps.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_new_xhtml_document_from_document(). */
Document Document::new_xhtml_document_from_document()
{
	fz_document* temp = mupdf::new_xhtml_document_from_document(this->m_internal);
	return Document(temp);
}

/* Wrapper for fz_next_page(). */
Location Document::next_page(Location& loc)
{
	fz_location temp = mupdf::next_page(this->m_internal, *(fz_location*) &loc.chapter);
	return Location(&temp);
}

/* Wrapper for fz_output_accelerator(). */
void Document::output_accelerator(const Output& accel)
{
	return mupdf::output_accelerator(this->m_internal, accel.m_internal);
}

/* Wrapper for fz_page_number_from_location(). */
int Document::page_number_from_location(Location& loc)
{
	return mupdf::page_number_from_location(this->m_internal, *(fz_location*) &loc.chapter);
}

/* Wrapper for fz_previous_page(). */
Location Document::previous_page(Location& loc)
{
	fz_location temp = mupdf::previous_page(this->m_internal, *(fz_location*) &loc.chapter);
	return Location(&temp);
}

/* Wrapper for fz_resolve_link(). */
Location Document::resolve_link(const char *uri, float *xp, float *yp)
{
	fz_location temp = mupdf::resolve_link(this->m_internal, uri, xp, yp);
	return Location(&temp);
}

/* Wrapper for fz_save_accelerator(). */
void Document::save_accelerator(const char *accel)
{
	return mupdf::save_accelerator(this->m_internal, accel);
}

/* Wrapper for fz_search_chapter_page_number(). */
int Document::search_chapter_page_number(int chapter, int page, const char *needle, Quad& hit_bbox, int hit_max)
{
	return mupdf::search_chapter_page_number(this->m_internal, chapter, page, needle, (fz_quad *) &hit_bbox.ul, hit_max);
}

/* Wrapper for fz_search_page_number(). */
int Document::search_page_number(int number, const char *needle, Quad& hit_bbox, int hit_max)
{
	return mupdf::search_page_number(this->m_internal, number, needle, (fz_quad *) &hit_bbox.ul, hit_max);
}

/* Wrapper for pdf_count_pages_imp(). */
int Document::pdf_count_pages_imp(int chapter)
{
	return mupdf::ppdf_count_pages_imp(this->m_internal, chapter);
}

/* Wrapper for pdf_document_from_fz_document(). */
PdfDocument Document::pdf_document_from_fz_document()
{
	pdf_document* temp = mupdf::ppdf_document_from_fz_document(this->m_internal);
	return PdfDocument(temp);
}

/* Wrapper for pdf_load_page_imp(). */
Page Document::pdf_load_page_imp(int chapter, int number)
{
	fz_page* temp = mupdf::ppdf_load_page_imp(this->m_internal, chapter, number);
	return Page(temp);
}

/* Wrapper for pdf_specifics(). */
PdfDocument Document::pdf_specifics()
{
	pdf_document* temp = mupdf::ppdf_specifics(this->m_internal);
	return PdfDocument(temp);
}

Document::Document(fz_document* internal)
: m_internal(internal)
{
}

Document::~Document()
{
	mupdf::drop_document(m_internal);
}

/* Implementation of DocumentHandler (wrapper for fz_document_handler). */

/* Wrapper for fz_register_document_handler(). */
void DocumentHandler::register_document_handler()
{
	return mupdf::register_document_handler(this->m_internal);
}

DocumentHandler::DocumentHandler(fz_document_handler* internal)
: m_internal(internal)
{
}

/* Implementation of DocumentHandlerContext (wrapper for fz_document_handler_context). */

DocumentHandlerContext::DocumentHandlerContext(fz_document_handler_context* internal)
: m_internal(internal)
{
}

/* Implementation of DocumentWriter (wrapper for fz_document_writer). */

/* Constructor using fz_new_document_writer(). */
DocumentWriter::DocumentWriter(const char *path, const char *format, const char *options)
{
	this->m_internal = mupdf::new_document_writer(path, format, options);
}

/* Constructor using fz_new_document_writer_of_size(). */
DocumentWriter::DocumentWriter(size_t size, fz_document_writer_begin_page_fn *begin_page, fz_document_writer_end_page_fn *end_page, fz_document_writer_close_writer_fn *close, fz_document_writer_drop_writer_fn *drop)
{
	this->m_internal = mupdf::new_document_writer_of_size(size, begin_page, end_page, close, drop);
}

/* Constructor using fz_new_document_writer_with_output(). */
DocumentWriter::DocumentWriter(const Output& out, const char *format, const char *options)
{
	this->m_internal = mupdf::new_document_writer_with_output(out.m_internal, format, options);
}

/* Constructor using fz_new_pdf_writer(). */
DocumentWriter::DocumentWriter(const char *path, const char *options)
{
	this->m_internal = mupdf::new_pdf_writer(path, options);
}

/* Constructor using fz_new_pdf_writer_with_output(). */
DocumentWriter::DocumentWriter(const Output& out, const char *options)
{
	this->m_internal = mupdf::new_pdf_writer_with_output(out.m_internal, options);
}

/* Constructor using fz_new_pixmap_writer(). */
DocumentWriter::DocumentWriter(const char *path, const char *options, const char *default_path, int n, void (*save)(fz_context *, fz_pixmap *, const char *))
{
	this->m_internal = mupdf::new_pixmap_writer(path, options, default_path, n, save);
}

/* Constructor using fz_new_text_writer(). */
/* Disabled because same args as fz_new_document_writer.
DocumentWriter::DocumentWriter(const char *format, const char *path, const char *options)
{
	this->m_internal = mupdf::new_text_writer(format, path, options);
}

*/
/* Constructor using fz_new_text_writer_with_output(). */
DocumentWriter::DocumentWriter(const char *format, const Output& out, const char *options)
{
	this->m_internal = mupdf::new_text_writer_with_output(format, out.m_internal, options);
}

/* Custom constructor. */
DocumentWriter::DocumentWriter(const char *path, const char *options, Type type)
{
	if (0) {}
	else if (type == Type_CBZ)          m_internal = mupdf::new_cbz_writer(path, options);
	else if (type == Type_PAM_PIXMAP)   m_internal = mupdf::new_pam_pixmap_writer(path, options);
	else if (type == Type_PBM_PIXMAP)   m_internal = mupdf::new_pbm_pixmap_writer(path, options);
	else if (type == Type_PCL)          m_internal = mupdf::new_pcl_writer(path, options);
	else if (type == Type_PCLM)         m_internal = mupdf::new_pclm_writer(path, options);
	else if (type == Type_PGM_PIXMAP)   m_internal = mupdf::new_pgm_pixmap_writer(path, options);
	else if (type == Type_PKM_PIXMAP)   m_internal = mupdf::new_pkm_pixmap_writer(path, options);
	else if (type == Type_PNG_PIXMAP)   m_internal = mupdf::new_png_pixmap_writer(path, options);
	else if (type == Type_PNM_PIXMAP)   m_internal = mupdf::new_pnm_pixmap_writer(path, options);
	else if (type == Type_PPM_PIXMAP)   m_internal = mupdf::new_ppm_pixmap_writer(path, options);
	else if (type == Type_PS)           m_internal = mupdf::new_ps_writer(path, options);
	else if (type == Type_PWG)          m_internal = mupdf::new_pwg_writer(path, options);
	else if (type == Type_SVG)          m_internal = mupdf::new_svg_writer(path, options);
	else throw ErrorAbort( "Unrecognised Type value");
}

/* Custom constructor. */
DocumentWriter::DocumentWriter(const Output& out, const char *options, OutputType output_type)
{
	if (0) {}
	else if (output_type == OutputType_CBZ)     m_internal = mupdf::new_cbz_writer_with_output(out.m_internal, options);
	else if (output_type == OutputType_PCL)     m_internal = mupdf::new_pcl_writer_with_output(out.m_internal, options);
	else if (output_type == OutputType_PCLM)    m_internal = mupdf::new_pclm_writer_with_output(out.m_internal, options);
	else if (output_type == OutputType_PS)      m_internal = mupdf::new_ps_writer_with_output(out.m_internal, options);
	else if (output_type == OutputType_PWG)     m_internal = mupdf::new_pwg_writer_with_output(out.m_internal, options);
	else throw ErrorAbort( "Unrecognised OutputType value");
}

/* Wrapper for fz_close_document_writer(). */
void DocumentWriter::close_document_writer()
{
	return mupdf::close_document_writer(this->m_internal);
}

/* Wrapper for fz_end_page(). */
void DocumentWriter::end_page()
{
	return mupdf::end_page(this->m_internal);
}

/* Custom method. */
Device DocumentWriter::begin_page(Rect& mediabox)
{
	/* fz_begin_page() doesn't transfer ownership, so
	we have to call fz_keep_device() before creating
	the Device instance. */
	fz_device* dev = mupdf::begin_page(m_internal, *(fz_rect*) &mediabox.x0);
	dev = mupdf::keep_device(dev);
	return Device(dev);
}

DocumentWriter::DocumentWriter(fz_document_writer* internal)
: m_internal(internal)
{
}

DocumentWriter::~DocumentWriter()
{
	mupdf::drop_document_writer(m_internal);
}

/* Implementation of DrawOptions (wrapper for fz_draw_options). */

/* Constructor using fz_parse_draw_options(). */
DrawOptions::DrawOptions(DrawOptions& options, const char *string)
{
	*(fz_draw_options*) &this->rotate = *mupdf::parse_draw_options((fz_draw_options *) &options.rotate, string);
}

DrawOptions::DrawOptions(const fz_draw_options* internal)
{
	this->rotate = internal->rotate;
	this->x_resolution = internal->x_resolution;
	this->y_resolution = internal->y_resolution;
	this->width = internal->width;
	this->height = internal->height;
	this->colorspace = internal->colorspace;
	this->alpha = internal->alpha;
	this->graphics = internal->graphics;
	this->text = internal->text;
}

DrawOptions::DrawOptions(const fz_draw_options internal)
{
	this->rotate = internal.rotate;
	this->x_resolution = internal.x_resolution;
	this->y_resolution = internal.y_resolution;
	this->width = internal.width;
	this->height = internal.height;
	this->colorspace = internal.colorspace;
	this->alpha = internal.alpha;
	this->graphics = internal.graphics;
	this->text = internal.text;
}

/* Constructor using raw copy of pre-existing fz_draw_options. */
fz_draw_options* DrawOptions::internal()
{
	return (fz_draw_options*) &this->rotate;
}

/* Constructor using raw copy of pre-existing fz_draw_options. */
const fz_draw_options* DrawOptions::internal() const
{
	return (const fz_draw_options*) &this->rotate;
}

/* Implementation of ErrorContext (wrapper for fz_error_context). */

ErrorContext::ErrorContext(fz_error_context* internal)
: m_internal(internal)
{
}

/* Implementation of ErrorStackSlot (wrapper for fz_error_stack_slot). */

ErrorStackSlot::ErrorStackSlot(fz_error_stack_slot* internal)
: m_internal(internal)
{
}

/* Implementation of Font (wrapper for fz_font). */

/* Constructor using fz_new_base14_font(). */
Font::Font(const char *name)
{
	this->m_internal = mupdf::new_base14_font(name);
}

/* Constructor using fz_new_builtin_font(). */
Font::Font(const char *name, int is_bold, int is_italic)
{
	this->m_internal = mupdf::new_builtin_font(name, is_bold, is_italic);
}

/* Constructor using fz_new_cjk_font(). */
Font::Font(int ordering)
{
	this->m_internal = mupdf::new_cjk_font(ordering);
}

/* Constructor using fz_new_font_from_buffer(). */
Font::Font(const char *name, const Buffer& buffer, int index, int use_glyph_bbox)
{
	this->m_internal = mupdf::new_font_from_buffer(name, buffer.m_internal, index, use_glyph_bbox);
}

/* Constructor using fz_new_font_from_file(). */
Font::Font(const char *name, const char *path, int index, int use_glyph_bbox)
{
	this->m_internal = mupdf::new_font_from_file(name, path, index, use_glyph_bbox);
}

/* Constructor using fz_new_font_from_memory(). */
Font::Font(const char *name, const unsigned char *data, int len, int index, int use_glyph_bbox)
{
	this->m_internal = mupdf::new_font_from_memory(name, data, len, index, use_glyph_bbox);
}

/* Constructor using fz_new_type3_font(). */
Font::Font(const char *name, Matrix& matrix)
{
	this->m_internal = mupdf::new_type3_font(name, *(fz_matrix*) &matrix.a);
}

/* Copy constructor using fz_keep_font(). */
Font::Font(const Font& rhs)
: m_internal(mupdf::keep_font(rhs.m_internal))
{
}

/* operator= using fz_keep_font() and fz_drop_font(). */
Font& Font::operator=(const Font& rhs)
{
	mupdf::drop_font(this->m_internal);
	mupdf::keep_font(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_advance_glyph(). */
float Font::advance_glyph(int glyph, int wmode)
{
	return mupdf::advance_glyph(this->m_internal, glyph, wmode);
}

/* Wrapper for fz_bound_glyph(). */
Rect Font::bound_glyph(int gid, Matrix& trm)
{
	fz_rect temp = mupdf::bound_glyph(this->m_internal, gid, *(fz_matrix*) &trm.a);
	return Rect(&temp);
}

/* Wrapper for fz_decouple_type3_font(). */
void Font::decouple_type3_font(void *t3doc)
{
	return mupdf::decouple_type3_font(this->m_internal, t3doc);
}

/* Wrapper for fz_encode_character(). */
int Font::encode_character(int unicode)
{
	return mupdf::encode_character(this->m_internal, unicode);
}

/* Wrapper for fz_encode_character_by_glyph_name(). */
int Font::encode_character_by_glyph_name(const char *glyphname)
{
	return mupdf::encode_character_by_glyph_name(this->m_internal, glyphname);
}

/* Wrapper for fz_encode_character_sc(). */
int Font::encode_character_sc(int unicode)
{
	return mupdf::encode_character_sc(this->m_internal, unicode);
}

/* Wrapper for fz_font_ascender(). */
float Font::font_ascender()
{
	return mupdf::font_ascender(this->m_internal);
}

/* Wrapper for fz_font_bbox(). */
Rect Font::font_bbox()
{
	fz_rect temp = mupdf::font_bbox(this->m_internal);
	return Rect(&temp);
}

/* Wrapper for fz_font_descender(). */
float Font::font_descender()
{
	return mupdf::font_descender(this->m_internal);
}

/* Wrapper for fz_font_digest(). */
void Font::font_digest(unsigned char digest[16])
{
	return mupdf::font_digest(this->m_internal, digest);
}

/* Wrapper for fz_font_flags(). */
FontFlagsT Font::font_flags()
{
	fz_font_flags_t* temp = mupdf::font_flags(this->m_internal);
	return FontFlagsT(temp);
}

/* Wrapper for fz_font_ft_face(). */
void *Font::font_ft_face()
{
	return mupdf::font_ft_face(this->m_internal);
}

/* Wrapper for fz_font_is_bold(). */
int Font::font_is_bold()
{
	return mupdf::font_is_bold(this->m_internal);
}

/* Wrapper for fz_font_is_italic(). */
int Font::font_is_italic()
{
	return mupdf::font_is_italic(this->m_internal);
}

/* Wrapper for fz_font_is_monospaced(). */
int Font::font_is_monospaced()
{
	return mupdf::font_is_monospaced(this->m_internal);
}

/* Wrapper for fz_font_is_serif(). */
int Font::font_is_serif()
{
	return mupdf::font_is_serif(this->m_internal);
}

/* Wrapper for fz_font_name(). */
const char *Font::font_name()
{
	return mupdf::font_name(this->m_internal);
}

/* Wrapper for fz_font_shaper_data(). */
ShaperDataT Font::font_shaper_data()
{
	fz_shaper_data_t* temp = mupdf::font_shaper_data(this->m_internal);
	return ShaperDataT(temp);
}

/* Wrapper for fz_font_t3_procs(). */
fz_buffer **Font::font_t3_procs()
{
	return mupdf::font_t3_procs(this->m_internal);
}

/* Wrapper for fz_get_glyph_name(). */
void Font::get_glyph_name(int glyph, char *buf, int size)
{
	return mupdf::get_glyph_name(this->m_internal, glyph, buf, size);
}

/* Wrapper for fz_glyph_cacheable(). */
int Font::glyph_cacheable(int gid)
{
	return mupdf::glyph_cacheable(this->m_internal, gid);
}

/* Wrapper for fz_outline_glyph(). */
Path Font::outline_glyph(int gid, Matrix& ctm)
{
	fz_path* temp = mupdf::outline_glyph(this->m_internal, gid, *(fz_matrix*) &ctm.a);
	return Path(temp);
}

/* Wrapper for fz_prepare_t3_glyph(). */
void Font::prepare_t3_glyph(int gid)
{
	return mupdf::prepare_t3_glyph(this->m_internal, gid);
}

/* Wrapper for fz_render_glyph_pixmap(). */
Pixmap Font::render_glyph_pixmap(int gid, Matrix& ctm, Irect& scissor, int aa)
{
	fz_pixmap* temp = mupdf::render_glyph_pixmap(this->m_internal, gid, (fz_matrix *) &ctm.a, (const fz_irect *) &scissor.x0, aa);
	return Pixmap(temp);
}

/* Wrapper for fz_run_t3_glyph(). */
void Font::run_t3_glyph(int gid, Matrix& trm, const Device& dev)
{
	return mupdf::run_t3_glyph(this->m_internal, gid, *(fz_matrix*) &trm.a, dev.m_internal);
}

/* Wrapper for fz_set_font_bbox(). */
void Font::set_font_bbox(float xmin, float ymin, float xmax, float ymax)
{
	return mupdf::set_font_bbox(this->m_internal, xmin, ymin, xmax, ymax);
}

/* Wrapper for pdf_font_writing_supported(). */
int Font::pdf_font_writing_supported()
{
	return mupdf::ppdf_font_writing_supported(this->m_internal);
}

Font::Font(fz_font* internal)
: m_internal(internal)
{
}

Font::~Font()
{
	mupdf::drop_font(m_internal);
}

/* Implementation of FontContext (wrapper for fz_font_context). */

FontContext::FontContext(fz_font_context* internal)
: m_internal(internal)
{
}

/* Implementation of FontFlagsT (wrapper for fz_font_flags_t). */

FontFlagsT::FontFlagsT(fz_font_flags_t* internal)
: m_internal(internal)
{
}

/* Implementation of Glyph (wrapper for fz_glyph). */

/* Copy constructor using fz_keep_glyph(). */
Glyph::Glyph(const Glyph& rhs)
: m_internal(mupdf::keep_glyph(rhs.m_internal))
{
}

/* operator= using fz_keep_glyph() and fz_drop_glyph(). */
Glyph& Glyph::operator=(const Glyph& rhs)
{
	mupdf::drop_glyph(this->m_internal);
	mupdf::keep_glyph(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_glyph_bbox(). */
Irect Glyph::glyph_bbox()
{
	fz_irect temp = mupdf::glyph_bbox(this->m_internal);
	return Irect(&temp);
}

/* Wrapper for fz_glyph_bbox_no_ctx(). */
Irect Glyph::glyph_bbox_no_ctx()
{
	fz_irect temp = mupdf::glyph_bbox_no_ctx(this->m_internal);
	return Irect(&temp);
}

/* Wrapper for fz_glyph_height(). */
int Glyph::glyph_height()
{
	return mupdf::glyph_height(this->m_internal);
}

/* Wrapper for fz_glyph_width(). */
int Glyph::glyph_width()
{
	return mupdf::glyph_width(this->m_internal);
}

Glyph::Glyph(fz_glyph* internal)
: m_internal(internal)
{
}

Glyph::~Glyph()
{
	mupdf::drop_glyph(m_internal);
}

/* Implementation of GlyphCache (wrapper for fz_glyph_cache). */

GlyphCache::GlyphCache(fz_glyph_cache* internal)
: m_internal(internal)
{
}

/* Implementation of Halftone (wrapper for fz_halftone). */

/* Copy constructor using fz_keep_halftone(). */
Halftone::Halftone(const Halftone& rhs)
: m_internal(mupdf::keep_halftone(rhs.m_internal))
{
}

/* operator= using fz_keep_halftone() and fz_drop_halftone(). */
Halftone& Halftone::operator=(const Halftone& rhs)
{
	mupdf::drop_halftone(this->m_internal);
	mupdf::keep_halftone(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

Halftone::Halftone(fz_halftone* internal)
: m_internal(internal)
{
}

Halftone::~Halftone()
{
	mupdf::drop_halftone(m_internal);
}

/* Implementation of HashTable (wrapper for fz_hash_table). */

/* Constructor using fz_new_hash_table(). */
HashTable::HashTable(int initialsize, int keylen, int lock, fz_hash_table_drop_fn *drop_val)
{
	this->m_internal = mupdf::new_hash_table(initialsize, keylen, lock, drop_val);
}

/* Wrapper for fz_hash_find(). */
void *HashTable::hash_find(const void *key)
{
	return mupdf::hash_find(this->m_internal, key);
}

/* Wrapper for fz_hash_for_each(). */
void HashTable::hash_for_each(void *state, fz_hash_table_for_each_fn *callback)
{
	return mupdf::hash_for_each(this->m_internal, state, callback);
}

/* Wrapper for fz_hash_insert(). */
void *HashTable::hash_insert(const void *key, void *val)
{
	return mupdf::hash_insert(this->m_internal, key, val);
}

/* Wrapper for fz_hash_remove(). */
void HashTable::hash_remove(const void *key)
{
	return mupdf::hash_remove(this->m_internal, key);
}

HashTable::HashTable(fz_hash_table* internal)
: m_internal(internal)
{
}

HashTable::~HashTable()
{
	mupdf::drop_hash_table(m_internal);
}

/* Implementation of IccProfile (wrapper for fz_icc_profile). */

IccProfile::IccProfile(fz_icc_profile* internal)
: m_internal(internal)
{
}

/* Implementation of Image (wrapper for fz_image). */

/* Constructor using fz_new_image_from_buffer(). */
Image::Image(const Buffer& buffer)
{
	this->m_internal = mupdf::new_image_from_buffer(buffer.m_internal);
}

/* Constructor using fz_new_image_from_compressed_buffer(). */
Image::Image(int w, int h, int bpc, const Colorspace& colorspace, int xres, int yres, int interpolate, int imagemask, float *decode, int *colorkey, const CompressedBuffer& buffer, const Image& mask)
{
	this->m_internal = mupdf::new_image_from_compressed_buffer(w, h, bpc, colorspace.m_internal, xres, yres, interpolate, imagemask, decode, colorkey, buffer.m_internal, mask.m_internal);
}

/* Constructor using fz_new_image_from_display_list(). */
Image::Image(float w, float h, const DisplayList& list)
{
	this->m_internal = mupdf::new_image_from_display_list(w, h, list.m_internal);
}

/* Constructor using fz_new_image_from_file(). */
Image::Image(const char *path)
{
	this->m_internal = mupdf::new_image_from_file(path);
}

/* Constructor using fz_new_image_from_pixmap(). */
Image::Image(const Pixmap& pixmap, const Image& mask)
{
	this->m_internal = mupdf::new_image_from_pixmap(pixmap.m_internal, mask.m_internal);
}

/* Constructor using fz_new_image_from_svg(). */
Image::Image(const Buffer& buf, const char *base_uri, const Archive& zip)
{
	this->m_internal = mupdf::new_image_from_svg(buf.m_internal, base_uri, zip.m_internal);
}

/* Constructor using fz_new_image_from_svg_xml(). */
Image::Image(const Xml& xml, const char *base_uri, const Archive& zip)
{
	this->m_internal = mupdf::new_image_from_svg_xml(xml.m_internal, base_uri, zip.m_internal);
}

/* Constructor using fz_new_image_of_size(). */
Image::Image(int w, int h, int bpc, const Colorspace& colorspace, int xres, int yres, int interpolate, int imagemask, float *decode, int *colorkey, const Image& mask, size_t size, fz_image_get_pixmap_fn *get_pixmap, fz_image_get_size_fn *get_size, fz_drop_image_fn *drop)
{
	this->m_internal = mupdf::new_image_of_size(w, h, bpc, colorspace.m_internal, xres, yres, interpolate, imagemask, decode, colorkey, mask.m_internal, size, get_pixmap, get_size, drop);
}

/* Copy constructor using fz_keep_image(). */
Image::Image(const Image& rhs)
: m_internal(mupdf::keep_image(rhs.m_internal))
{
}

/* operator= using fz_keep_image() and fz_drop_image(). */
Image& Image::operator=(const Image& rhs)
{
	mupdf::drop_image(this->m_internal);
	mupdf::keep_image(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_compressed_image_buffer(). */
CompressedBuffer Image::compressed_image_buffer()
{
	fz_compressed_buffer* temp = mupdf::compressed_image_buffer(this->m_internal);
	return CompressedBuffer(temp);
}

/* Wrapper for fz_get_pixmap_from_image(). */
Pixmap Image::get_pixmap_from_image(Irect& subarea, Matrix& ctm, int *w, int *h)
{
	fz_pixmap* temp = mupdf::get_pixmap_from_image(this->m_internal, (const fz_irect *) &subarea.x0, (fz_matrix *) &ctm.a, w, h);
	return Pixmap(temp);
}

/* Wrapper for fz_image_resolution(). */
void Image::image_resolution(int *xres, int *yres)
{
	return mupdf::image_resolution(this->m_internal, xres, yres);
}

/* Wrapper for fz_image_size(). */
size_t Image::image_size()
{
	return mupdf::image_size(this->m_internal);
}

/* Wrapper for fz_new_buffer_from_image_as_png(). */
Buffer Image::new_buffer_from_image_as_png(ColorParams& color_params)
{
	fz_buffer* temp = mupdf::new_buffer_from_image_as_png(this->m_internal, *(fz_color_params*) &color_params.ri);
	return Buffer(temp);
}

Image::Image(fz_image* internal)
: m_internal(internal)
{
}

Image::~Image()
{
	mupdf::drop_image(m_internal);
}

/* Implementation of Irect (wrapper for fz_irect). */

/* Constructor using fz_irect_from_rect(). */
Irect::Irect(Rect& rect)
{
	*(fz_irect*) &this->x0 = mupdf::irect_from_rect(*(fz_rect*) &rect.x0);
}

/* Constructor using fz_make_irect(). */
Irect::Irect(int x0, int y0, int x1, int y1)
{
	*(fz_irect*) &this->x0 = mupdf::make_irect(x0, y0, x1, y1);
}

/* Wrapper for fz_expand_irect(). */
Irect Irect::expand_irect(int expand)
{
	fz_irect temp = mupdf::expand_irect(*(fz_irect*) &this->x0, expand);
	return Irect(&temp);
}

/* Wrapper for fz_intersect_irect(). */
Irect Irect::intersect_irect(Irect& b)
{
	fz_irect temp = mupdf::intersect_irect(*(fz_irect*) &this->x0, *(fz_irect*) &b.x0);
	return Irect(&temp);
}

/* Wrapper for fz_is_empty_irect(). */
int Irect::is_empty_irect()
{
	return mupdf::is_empty_irect(*(fz_irect*) &this->x0);
}

/* Wrapper for fz_is_infinite_irect(). */
int Irect::is_infinite_irect()
{
	return mupdf::is_infinite_irect(*(fz_irect*) &this->x0);
}

/* Wrapper for fz_rect_from_irect(). */
Rect Irect::rect_from_irect()
{
	fz_rect temp = mupdf::rect_from_irect(*(fz_irect*) &this->x0);
	return Rect(&temp);
}

/* Wrapper for fz_translate_irect(). */
Irect Irect::translate_irect(int xoff, int yoff)
{
	fz_irect temp = mupdf::translate_irect(*(fz_irect*) &this->x0, xoff, yoff);
	return Irect(&temp);
}

Irect::Irect(const fz_irect* internal)
{
	this->x0 = internal->x0;
	this->y0 = internal->y0;
	this->x1 = internal->x1;
	this->y1 = internal->y1;
}

Irect::Irect(const fz_irect internal)
{
	this->x0 = internal.x0;
	this->y0 = internal.y0;
	this->x1 = internal.x1;
	this->y1 = internal.y1;
}

/* Constructor using raw copy of pre-existing fz_irect. */
fz_irect* Irect::internal()
{
	return (fz_irect*) &this->x0;
}

/* Constructor using raw copy of pre-existing fz_irect. */
const fz_irect* Irect::internal() const
{
	return (const fz_irect*) &this->x0;
}

/* Implementation of Jbig2Globals (wrapper for fz_jbig2_globals). */

/* Copy constructor using fz_keep_jbig2_globals(). */
Jbig2Globals::Jbig2Globals(const Jbig2Globals& rhs)
: m_internal(mupdf::keep_jbig2_globals(rhs.m_internal))
{
}

/* operator= using fz_keep_jbig2_globals() and fz_drop_jbig2_globals(). */
Jbig2Globals& Jbig2Globals::operator=(const Jbig2Globals& rhs)
{
	mupdf::drop_jbig2_globals(this->m_internal);
	mupdf::keep_jbig2_globals(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

Jbig2Globals::Jbig2Globals(fz_jbig2_globals* internal)
: m_internal(internal)
{
}

Jbig2Globals::~Jbig2Globals()
{
	mupdf::drop_jbig2_globals(m_internal);
}

/* Implementation of KeyStorable (wrapper for fz_key_storable). */

/* Copy constructor using fz_keep_key_storable(). */
KeyStorable::KeyStorable(const KeyStorable& rhs)
: m_internal((fz_key_storable*) mupdf::keep_key_storable(rhs.m_internal))
{
}

/* operator= using fz_keep_key_storable() and fz_drop_key_storable(). */
KeyStorable& KeyStorable::operator=(const KeyStorable& rhs)
{
	mupdf::drop_key_storable(this->m_internal);
	mupdf::keep_key_storable(rhs.m_internal);
	this->m_internal = (fz_key_storable*) rhs.m_internal;
	return *this;
}

KeyStorable::KeyStorable(fz_key_storable* internal)
: m_internal(internal)
{
}

KeyStorable::~KeyStorable()
{
	mupdf::drop_key_storable(m_internal);
}

/* Implementation of LayoutBlock (wrapper for fz_layout_block). */

/* Constructor using fz_new_layout(). */
LayoutBlock::LayoutBlock()
{
	this->m_internal = mupdf::new_layout();
}

/* Wrapper for fz_add_layout_char(). */
void LayoutBlock::add_layout_char(float x, float w, const char *p)
{
	return mupdf::add_layout_char(this->m_internal, x, w, p);
}

/* Wrapper for fz_add_layout_line(). */
void LayoutBlock::add_layout_line(float x, float y, float h, const char *p)
{
	return mupdf::add_layout_line(this->m_internal, x, y, h, p);
}

LayoutBlock::LayoutBlock(fz_layout_block* internal)
: m_internal(internal)
{
}

/* Implementation of LayoutChar (wrapper for fz_layout_char). */

LayoutChar::LayoutChar(fz_layout_char* internal)
: m_internal(internal)
{
}

/* Implementation of LayoutLine (wrapper for fz_layout_line). */

LayoutLine::LayoutLine(fz_layout_line* internal)
: m_internal(internal)
{
}

/* Implementation of Link (wrapper for fz_link). */

/* Constructor using fz_new_link(). */
Link::Link(Rect& bbox, void *doc, const char *uri)
{
	this->m_internal = mupdf::new_link(*(fz_rect*) &bbox.x0, doc, uri);
}

/* Copy constructor using fz_keep_link(). */
Link::Link(const Link& rhs)
: m_internal(mupdf::keep_link(rhs.m_internal))
{
}

/* operator= using fz_keep_link() and fz_drop_link(). */
Link& Link::operator=(const Link& rhs)
{
	mupdf::drop_link(this->m_internal);
	mupdf::keep_link(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Custom method. */
LinkIterator Link::begin()
{
	return LinkIterator(m_internal);
}

/* Custom method. */
LinkIterator Link::end()
{
	return LinkIterator(NULL);
}

Link::Link(fz_link* internal)
: m_internal(internal)
{
}

Link::~Link()
{
	mupdf::drop_link(m_internal);
}


LinkIterator::LinkIterator(fz_link* item)
: m_item( item)
{
}
LinkIterator& LinkIterator::operator++()
{
	m_item = Link(m_item.m_internal->next);
	return *this;
}
bool LinkIterator::operator==( const LinkIterator& rhs)
{
	return m_item.m_internal == rhs.m_item.m_internal;
}
bool LinkIterator::operator!=( const LinkIterator& rhs)
{
	return m_item.m_internal != rhs.m_item.m_internal;
}
Link LinkIterator::operator*()
{
	return m_item;
}
Link* LinkIterator::operator->()
{
	return &m_item;
}

void test(Link& item)
{
	for( LinkIterator it = item.begin(); it != item.end(); ++it) {
		(void) *it;
	}
	for ( auto i: item) {
		(void) i;
	}
}

/* Implementation of Location (wrapper for fz_location). */

/* Constructor using fz_make_location(). */
Location::Location(int chapter, int page)
{
	*(fz_location*) &this->chapter = mupdf::make_location(chapter, page);
}

Location::Location(const fz_location* internal)
{
	this->chapter = internal->chapter;
	this->page = internal->page;
}

Location::Location(const fz_location internal)
{
	this->chapter = internal.chapter;
	this->page = internal.page;
}

/* Constructor using raw copy of pre-existing fz_location. */
fz_location* Location::internal()
{
	return (fz_location*) &this->chapter;
}

/* Constructor using raw copy of pre-existing fz_location. */
const fz_location* Location::internal() const
{
	return (const fz_location*) &this->chapter;
}

/* Implementation of LocksContext (wrapper for fz_locks_context). */

LocksContext::LocksContext(fz_locks_context* internal)
: m_internal(internal)
{
}

/* Implementation of Matrix (wrapper for fz_matrix). */

/* Constructor using fz_make_matrix(). */
Matrix::Matrix(float a, float b, float c, float d, float e, float f)
{
	*(fz_matrix*) &this->a = mupdf::make_matrix(a, b, c, d, e, f);
}

/* Custom constructor. */
Matrix::Matrix()
: a(1), b(0), c(0), d(1), e(0), f(0)
{
}

/* Wrapper for fz_concat(). */
Matrix Matrix::concat(Matrix& left, Matrix& right)
{
	fz_matrix temp = mupdf::concat(*(fz_matrix*) &left.a, *(fz_matrix*) &right.a);
	return Matrix(&temp);
}

/* Wrapper for fz_scale(). */
Matrix Matrix::scale(float sx, float sy)
{
	fz_matrix temp = mupdf::scale(sx, sy);
	return Matrix(&temp);
}

/* Wrapper for fz_shear(). */
Matrix Matrix::shear(float sx, float sy)
{
	fz_matrix temp = mupdf::shear(sx, sy);
	return Matrix(&temp);
}

/* Wrapper for fz_rotate(). */
Matrix Matrix::rotate(float degrees)
{
	fz_matrix temp = mupdf::rotate(degrees);
	return Matrix(&temp);
}

/* Wrapper for fz_translate(). */
Matrix Matrix::translate(float tx, float ty)
{
	fz_matrix temp = mupdf::translate(tx, ty);
	return Matrix(&temp);
}

/* Wrapper for fz_transform_page(). */
Matrix Matrix::transform_page(Rect& mediabox, float resolution, float rotate)
{
	fz_matrix temp = mupdf::transform_page(*(fz_rect*) &mediabox.x0, resolution, rotate);
	return Matrix(&temp);
}

/* Wrapper for fz_concat(). */
Matrix Matrix::concat(Matrix& right)
{
	fz_matrix temp = mupdf::concat(*(fz_matrix*) &this->a, *(fz_matrix*) &right.a);
	return Matrix(&temp);
}

/* Wrapper for fz_invert_matrix(). */
Matrix Matrix::invert_matrix()
{
	fz_matrix temp = mupdf::invert_matrix(*(fz_matrix*) &this->a);
	return Matrix(&temp);
}

/* Wrapper for fz_is_identity(). */
int Matrix::is_identity()
{
	return mupdf::is_identity(*(fz_matrix*) &this->a);
}

/* Wrapper for fz_is_rectilinear(). */
int Matrix::is_rectilinear()
{
	return mupdf::is_rectilinear(*(fz_matrix*) &this->a);
}

/* Wrapper for fz_matrix_expansion(). */
float Matrix::matrix_expansion()
{
	return mupdf::matrix_expansion(*(fz_matrix*) &this->a);
}

/* Wrapper for fz_matrix_max_expansion(). */
float Matrix::matrix_max_expansion()
{
	return mupdf::matrix_max_expansion(*(fz_matrix*) &this->a);
}

/* Wrapper for fz_post_scale(). */
Matrix Matrix::post_scale(float sx, float sy)
{
	fz_matrix temp = mupdf::post_scale(*(fz_matrix*) &this->a, sx, sy);
	return Matrix(&temp);
}

/* Wrapper for fz_pre_rotate(). */
Matrix Matrix::pre_rotate(float degrees)
{
	fz_matrix temp = mupdf::pre_rotate(*(fz_matrix*) &this->a, degrees);
	return Matrix(&temp);
}

/* Wrapper for fz_pre_scale(). */
Matrix Matrix::pre_scale(float sx, float sy)
{
	fz_matrix temp = mupdf::pre_scale(*(fz_matrix*) &this->a, sx, sy);
	return Matrix(&temp);
}

/* Wrapper for fz_pre_shear(). */
Matrix Matrix::pre_shear(float sx, float sy)
{
	fz_matrix temp = mupdf::pre_shear(*(fz_matrix*) &this->a, sx, sy);
	return Matrix(&temp);
}

/* Wrapper for fz_pre_translate(). */
Matrix Matrix::pre_translate(float tx, float ty)
{
	fz_matrix temp = mupdf::pre_translate(*(fz_matrix*) &this->a, tx, ty);
	return Matrix(&temp);
}

/* Wrapper for fz_subpixel_adjust(). */
float Matrix::subpixel_adjust(Matrix& subpix_ctm, unsigned char *qe, unsigned char *qf)
{
	return mupdf::subpixel_adjust((fz_matrix *) &this->a, (fz_matrix *) &subpix_ctm.a, qe, qf);
}

/* Wrapper for fz_try_invert_matrix(). */
int Matrix::try_invert_matrix(Matrix& src)
{
	return mupdf::try_invert_matrix((fz_matrix *) &this->a, *(fz_matrix*) &src.a);
}

Matrix::Matrix(const fz_matrix* internal)
{
	this->a = internal->a;
	this->b = internal->b;
	this->c = internal->c;
	this->d = internal->d;
	this->e = internal->e;
	this->f = internal->f;
}

Matrix::Matrix(const fz_matrix internal)
{
	this->a = internal.a;
	this->b = internal.b;
	this->c = internal.c;
	this->d = internal.d;
	this->e = internal.e;
	this->f = internal.f;
}

/* Constructor using raw copy of pre-existing fz_matrix. */
fz_matrix* Matrix::internal()
{
	return (fz_matrix*) &this->a;
}

/* Constructor using raw copy of pre-existing fz_matrix. */
const fz_matrix* Matrix::internal() const
{
	return (const fz_matrix*) &this->a;
}

/* Implementation of Md5 (wrapper for fz_md5). */

/* Wrapper for fz_md5_final(). */
void Md5::md5_final(unsigned char digest[16])
{
	return mupdf::md5_final(this->m_internal, digest);
}

/* Wrapper for fz_md5_init(). */
void Md5::md5_init()
{
	return mupdf::md5_init(this->m_internal);
}

/* Wrapper for fz_md5_update(). */
void Md5::md5_update(const unsigned char *input, size_t inlen)
{
	return mupdf::md5_update(this->m_internal, input, inlen);
}

Md5::Md5(fz_md5* internal)
: m_internal(internal)
{
}

/* Implementation of Outline (wrapper for fz_outline). */

/* Constructor using fz_load_outline(). */
Outline::Outline(const Document& doc)
{
	this->m_internal = mupdf::load_outline(doc.m_internal);
}

/* Constructor using fz_new_outline(). */
Outline::Outline()
{
	this->m_internal = mupdf::new_outline();
}

/* Custom constructor. */
Outline::Outline(struct fz_outline* internal)
: m_internal( mupdf::keep_outline(internal))
{
}

/* Copy constructor using fz_keep_outline(). */
Outline::Outline(const Outline& rhs)
: m_internal(mupdf::keep_outline(rhs.m_internal))
{
}

/* operator= using fz_keep_outline() and fz_drop_outline(). */
Outline& Outline::operator=(const Outline& rhs)
{
	mupdf::drop_outline(this->m_internal);
	mupdf::keep_outline(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Custom method. */
OutlineIterator Outline::begin()
{
	return OutlineIterator(*this);
}

/* Custom method. */
OutlineIterator Outline::end()
{
	return OutlineIterator();
}

int Outline::refs()
{
	return m_internal->refs;
}

const char *Outline::title()
{
	return m_internal->title;
}

const char *Outline::uri()
{
	return m_internal->uri;
}

int Outline::page()
{
	return m_internal->page;
}

float Outline::x()
{
	return m_internal->x;
}

float Outline::y()
{
	return m_internal->y;
}

Outline Outline::next()
{
	mupdf::keep_outline(m_internal->next);
	return m_internal->next;
}

Outline Outline::down()
{
	mupdf::keep_outline(m_internal->down);
	return m_internal->down;
}

int Outline::is_open()
{
	return m_internal->is_open;
}

Outline::~Outline()
{
	mupdf::drop_outline(m_internal);
}


OutlineIterator::OutlineIterator(const Outline& item)
: m_item(item)
{
}
OutlineIterator::OutlineIterator()
: m_item(NULL)
{
}
OutlineIterator& OutlineIterator::operator++()
{
	if (m_item.m_internal->down) {
		m_up.push_back(m_item.m_internal);
		m_item = Outline(m_item.m_internal->down);
	}
	else if (m_item.m_internal->next) {
		m_item = Outline(m_item.m_internal->next);
	}
	else {
		/* Go up and across in the tree. */
		for(;;) {
			if (m_up.empty()) {
				m_item = Outline(NULL);
				break;
			}
			fz_outline* p = m_up.back();
			m_up.pop_back();
			if (p->next) {
				m_item = Outline(p->next);
				break;
			}
		}
	}
	return *this;
}
bool OutlineIterator::operator==(const OutlineIterator& rhs)
{
	bool ret = m_item.m_internal == rhs.m_item.m_internal;
	return ret;
}
bool OutlineIterator::operator!=(const OutlineIterator& rhs)
{
	return m_item.m_internal != rhs.m_item.m_internal;
}
Outline& OutlineIterator::operator*()
{
	return m_item;
}
Outline* OutlineIterator::operator->()
{
	return &m_item;
}

void test(Outline& item)
{
	for( OutlineIterator it = item.begin(); it != item.end(); ++it) {
		(void) *it;
	}
	for (auto i: item) {
		(void) i;
	}
}

/* Implementation of Output (wrapper for fz_output). */

/* Constructor using fz_new_arc4_output(). */
Output::Output(const Output& chain, unsigned char *key, size_t keylen)
{
	this->m_internal = mupdf::new_arc4_output(chain.m_internal, key, keylen);
}

/* Constructor using fz_new_deflate_output(). */
Output::Output(const Output& chain, int effort, int raw)
{
	this->m_internal = mupdf::new_deflate_output(chain.m_internal, effort, raw);
}

/* Constructor using fz_new_log_for_module(). */
Output::Output(const char *module)
{
	this->m_internal = mupdf::new_log_for_module(module);
}

/* Constructor using fz_new_output(). */
Output::Output(int bufsiz, void *state, fz_output_write_fn *write, fz_output_close_fn *close, fz_output_drop_fn *drop)
{
	this->m_internal = mupdf::new_output(bufsiz, state, write, close, drop);
}

/* Constructor using fz_new_output_with_buffer(). */
Output::Output(const Buffer& buf)
{
	this->m_internal = mupdf::new_output_with_buffer(buf.m_internal);
}

/* Constructor using fz_new_output_with_path(). */
Output::Output(const char *filename, int append)
{
	this->m_internal = mupdf::new_output_with_path(filename, append);
}

/* Custom constructor. */
Output::Output(Fixed out)
{
	if (0)  {}
	else if (out == Fixed_STDOUT) {
		m_internal = mupdf::stdout();
	}
	else if (out == Fixed_STDERR) {
		m_internal = mupdf::stderr();
	}
	else {
		throw ErrorAbort("Unrecognised Fixed value");
	}
}

/* Custom constructor. */
Output::Output(const Output& chain, Filter filter)
{
	if (0)  {}
	else if (filter == Filter_HEX) {
		m_internal = mupdf::new_asciihex_output(chain.m_internal);
	}
	else if (filter == Filter_85) {
		m_internal = mupdf::new_ascii85_output(chain.m_internal);
	}
	else if (filter == Filter_RLE) {
		m_internal = mupdf::new_rle_output(chain.m_internal);
	}
	else {
		throw ErrorAbort("Unrecognised Filter value");
	}
}

/* Wrapper for fz_close_output(). */
void Output::close_output()
{
	return mupdf::close_output(this->m_internal);
}

/* Wrapper for fz_debug_store(). */
void Output::debug_store()
{
	return mupdf::debug_store(this->m_internal);
}

/* Wrapper for fz_dump_glyph_cache_stats(). */
void Output::dump_glyph_cache_stats()
{
	return mupdf::dump_glyph_cache_stats(this->m_internal);
}

/* Wrapper for fz_flush_output(). */
void Output::flush_output()
{
	return mupdf::flush_output(this->m_internal);
}

/* Wrapper for fz_new_svg_device(). */
Device Output::new_svg_device(float page_width, float page_height, int text_format, int reuse_images)
{
	fz_device* temp = mupdf::new_svg_device(this->m_internal, page_width, page_height, text_format, reuse_images);
	return Device(temp);
}

/* Wrapper for fz_new_svg_device_with_id(). */
Device Output::new_svg_device_with_id(float page_width, float page_height, int text_format, int reuse_images, int *id)
{
	fz_device* temp = mupdf::new_svg_device_with_id(this->m_internal, page_width, page_height, text_format, reuse_images, id);
	return Device(temp);
}

/* Wrapper for fz_new_trace_device(). */
Device Output::new_trace_device()
{
	fz_device* temp = mupdf::new_trace_device(this->m_internal);
	return Device(temp);
}

/* Wrapper for fz_new_zip_writer_with_output(). */
ZipWriter Output::new_zip_writer_with_output()
{
	fz_zip_writer* temp = mupdf::new_zip_writer_with_output(this->m_internal);
	return ZipWriter(temp);
}

/* Wrapper for fz_output_supports_stream(). */
int Output::output_supports_stream()
{
	return mupdf::output_supports_stream(this->m_internal);
}

/* Wrapper for fz_print_stext_header_as_html(). */
void Output::print_stext_header_as_html()
{
	return mupdf::print_stext_header_as_html(this->m_internal);
}

/* Wrapper for fz_print_stext_header_as_xhtml(). */
void Output::print_stext_header_as_xhtml()
{
	return mupdf::print_stext_header_as_xhtml(this->m_internal);
}

/* Wrapper for fz_print_stext_page_as_html(). */
void Output::print_stext_page_as_html(const StextPage& page, int id)
{
	return mupdf::print_stext_page_as_html(this->m_internal, page.m_internal, id);
}

/* Wrapper for fz_print_stext_page_as_text(). */
void Output::print_stext_page_as_text(const StextPage& page)
{
	return mupdf::print_stext_page_as_text(this->m_internal, page.m_internal);
}

/* Wrapper for fz_print_stext_page_as_xhtml(). */
void Output::print_stext_page_as_xhtml(const StextPage& page, int id)
{
	return mupdf::print_stext_page_as_xhtml(this->m_internal, page.m_internal, id);
}

/* Wrapper for fz_print_stext_page_as_xml(). */
void Output::print_stext_page_as_xml(const StextPage& page, int id)
{
	return mupdf::print_stext_page_as_xml(this->m_internal, page.m_internal, id);
}

/* Wrapper for fz_print_stext_trailer_as_html(). */
void Output::print_stext_trailer_as_html()
{
	return mupdf::print_stext_trailer_as_html(this->m_internal);
}

/* Wrapper for fz_print_stext_trailer_as_xhtml(). */
void Output::print_stext_trailer_as_xhtml()
{
	return mupdf::print_stext_trailer_as_xhtml(this->m_internal);
}

/* Wrapper for fz_seek_output(). */
void Output::seek_output(int64_t off, int whence)
{
	return mupdf::seek_output(this->m_internal, off, whence);
}

/* Wrapper for fz_stream_from_output(). */
Stream Output::stream_from_output()
{
	fz_stream* temp = mupdf::stream_from_output(this->m_internal);
	return Stream(temp);
}

/* Wrapper for fz_tell_output(). */
int64_t Output::tell_output()
{
	return mupdf::tell_output(this->m_internal);
}

/* Wrapper for fz_truncate_output(). */
void Output::truncate_output()
{
	return mupdf::truncate_output(this->m_internal);
}

/* Wrapper for fz_write_base64(). */
void Output::write_base64(const unsigned char *data, size_t size, int newline)
{
	return mupdf::write_base64(this->m_internal, data, size, newline);
}

/* Wrapper for fz_write_base64_buffer(). */
void Output::write_base64_buffer(const Buffer& data, int newline)
{
	return mupdf::write_base64_buffer(this->m_internal, data.m_internal, newline);
}

/* Wrapper for fz_write_bitmap_as_pbm(). */
void Output::write_bitmap_as_pbm(const Bitmap& bitmap)
{
	return mupdf::write_bitmap_as_pbm(this->m_internal, bitmap.m_internal);
}

/* Wrapper for fz_write_bitmap_as_pcl(). */
void Output::write_bitmap_as_pcl(const Bitmap& bitmap, const PclOptions& pcl)
{
	return mupdf::write_bitmap_as_pcl(this->m_internal, bitmap.m_internal, pcl.m_internal);
}

/* Wrapper for fz_write_bitmap_as_pkm(). */
void Output::write_bitmap_as_pkm(const Bitmap& bitmap)
{
	return mupdf::write_bitmap_as_pkm(this->m_internal, bitmap.m_internal);
}

/* Wrapper for fz_write_bitmap_as_pwg(). */
void Output::write_bitmap_as_pwg(const Bitmap& bitmap, PwgOptions& pwg)
{
	return mupdf::write_bitmap_as_pwg(this->m_internal, bitmap.m_internal, &pwg.m_internal);
}

/* Wrapper for fz_write_bitmap_as_pwg_page(). */
void Output::write_bitmap_as_pwg_page(const Bitmap& bitmap, PwgOptions& pwg)
{
	return mupdf::write_bitmap_as_pwg_page(this->m_internal, bitmap.m_internal, &pwg.m_internal);
}

/* Wrapper for fz_write_byte(). */
void Output::write_byte(unsigned char x)
{
	return mupdf::write_byte(this->m_internal, x);
}

/* Wrapper for fz_write_char(). */
void Output::write_char(char x)
{
	return mupdf::write_char(this->m_internal, x);
}

/* Wrapper for fz_write_data(). */
void Output::write_data(const void *data, size_t size)
{
	return mupdf::write_data(this->m_internal, data, size);
}

/* Wrapper for fz_write_float_be(). */
void Output::write_float_be(float f)
{
	return mupdf::write_float_be(this->m_internal, f);
}

/* Wrapper for fz_write_float_le(). */
void Output::write_float_le(float f)
{
	return mupdf::write_float_le(this->m_internal, f);
}

/* Wrapper for fz_write_image_as_data_uri(). */
void Output::write_image_as_data_uri(const Image& image)
{
	return mupdf::write_image_as_data_uri(this->m_internal, image.m_internal);
}

/* Wrapper for fz_write_int16_be(). */
void Output::write_int16_be(int x)
{
	return mupdf::write_int16_be(this->m_internal, x);
}

/* Wrapper for fz_write_int16_le(). */
void Output::write_int16_le(int x)
{
	return mupdf::write_int16_le(this->m_internal, x);
}

/* Wrapper for fz_write_int32_be(). */
void Output::write_int32_be(int x)
{
	return mupdf::write_int32_be(this->m_internal, x);
}

/* Wrapper for fz_write_int32_le(). */
void Output::write_int32_le(int x)
{
	return mupdf::write_int32_le(this->m_internal, x);
}

/* Wrapper for fz_write_pixmap_as_data_uri(). */
void Output::write_pixmap_as_data_uri(const Pixmap& pixmap)
{
	return mupdf::write_pixmap_as_data_uri(this->m_internal, pixmap.m_internal);
}

/* Wrapper for fz_write_pixmap_as_pam(). */
void Output::write_pixmap_as_pam(const Pixmap& pixmap)
{
	return mupdf::write_pixmap_as_pam(this->m_internal, pixmap.m_internal);
}

/* Wrapper for fz_write_pixmap_as_pcl(). */
void Output::write_pixmap_as_pcl(const Pixmap& pixmap, const PclOptions& pcl)
{
	return mupdf::write_pixmap_as_pcl(this->m_internal, pixmap.m_internal, pcl.m_internal);
}

/* Wrapper for fz_write_pixmap_as_pclm(). */
void Output::write_pixmap_as_pclm(const Pixmap& pixmap, const PclmOptions& options)
{
	return mupdf::write_pixmap_as_pclm(this->m_internal, pixmap.m_internal, options.m_internal);
}

/* Wrapper for fz_write_pixmap_as_png(). */
void Output::write_pixmap_as_png(const Pixmap& pixmap)
{
	return mupdf::write_pixmap_as_png(this->m_internal, pixmap.m_internal);
}

/* Wrapper for fz_write_pixmap_as_pnm(). */
void Output::write_pixmap_as_pnm(const Pixmap& pixmap)
{
	return mupdf::write_pixmap_as_pnm(this->m_internal, pixmap.m_internal);
}

/* Wrapper for fz_write_pixmap_as_ps(). */
void Output::write_pixmap_as_ps(const Pixmap& pixmap)
{
	return mupdf::write_pixmap_as_ps(this->m_internal, pixmap.m_internal);
}

/* Wrapper for fz_write_pixmap_as_psd(). */
void Output::write_pixmap_as_psd(const Pixmap& pixmap)
{
	return mupdf::write_pixmap_as_psd(this->m_internal, pixmap.m_internal);
}

/* Wrapper for fz_write_pixmap_as_pwg(). */
void Output::write_pixmap_as_pwg(const Pixmap& pixmap, PwgOptions& pwg)
{
	return mupdf::write_pixmap_as_pwg(this->m_internal, pixmap.m_internal, &pwg.m_internal);
}

/* Wrapper for fz_write_pixmap_as_pwg_page(). */
void Output::write_pixmap_as_pwg_page(const Pixmap& pixmap, PwgOptions& pwg)
{
	return mupdf::write_pixmap_as_pwg_page(this->m_internal, pixmap.m_internal, &pwg.m_internal);
}

/* Wrapper for fz_write_ps_file_header(). */
void Output::write_ps_file_header()
{
	return mupdf::write_ps_file_header(this->m_internal);
}

/* Wrapper for fz_write_ps_file_trailer(). */
void Output::write_ps_file_trailer(int pages)
{
	return mupdf::write_ps_file_trailer(this->m_internal, pages);
}

/* Wrapper for fz_write_pwg_file_header(). */
void Output::write_pwg_file_header()
{
	return mupdf::write_pwg_file_header(this->m_internal);
}

/* Wrapper for fz_write_rune(). */
void Output::write_rune(int rune)
{
	return mupdf::write_rune(this->m_internal, rune);
}

/* Wrapper for fz_write_string(). */
void Output::write_string(const char *s)
{
	return mupdf::write_string(this->m_internal, s);
}

/* Wrapper for fz_write_uint16_be(). */
void Output::write_uint16_be(unsigned int x)
{
	return mupdf::write_uint16_be(this->m_internal, x);
}

/* Wrapper for fz_write_uint16_le(). */
void Output::write_uint16_le(unsigned int x)
{
	return mupdf::write_uint16_le(this->m_internal, x);
}

/* Wrapper for fz_write_uint32_be(). */
void Output::write_uint32_be(unsigned int x)
{
	return mupdf::write_uint32_be(this->m_internal, x);
}

/* Wrapper for fz_write_uint32_le(). */
void Output::write_uint32_le(unsigned int x)
{
	return mupdf::write_uint32_le(this->m_internal, x);
}

/* Wrapper for fz_write_vprintf(). */
void Output::write_vprintf(const char *fmt, va_list ap)
{
	return mupdf::write_vprintf(this->m_internal, fmt, ap);
}

/* Wrapper for pdf_new_output_processor(). */
PdfProcessor Output::pdf_new_output_processor(int ahxencode)
{
	pdf_processor* temp = mupdf::ppdf_new_output_processor(this->m_internal, ahxencode);
	return PdfProcessor(temp);
}

/* Wrapper for pdf_print_crypt(). */
void Output::pdf_print_crypt(const PdfCrypt& crypt)
{
	return mupdf::ppdf_print_crypt(this->m_internal, crypt.m_internal);
}

/* Wrapper for pdf_print_encrypted_obj(). */
void Output::pdf_print_encrypted_obj(const PdfObj& obj, int tight, int ascii, const PdfCrypt& crypt, int num, int gen)
{
	return mupdf::ppdf_print_encrypted_obj(this->m_internal, obj.m_internal, tight, ascii, crypt.m_internal, num, gen);
}

/* Wrapper for pdf_print_font(). */
void Output::pdf_print_font(const PdfFontDesc& fontdesc)
{
	return mupdf::ppdf_print_font(this->m_internal, fontdesc.m_internal);
}

/* Wrapper for pdf_print_obj(). */
void Output::pdf_print_obj(const PdfObj& obj, int tight, int ascii)
{
	return mupdf::ppdf_print_obj(this->m_internal, obj.m_internal, tight, ascii);
}

/* Wrapper for pdf_write_digest(). */
void Output::pdf_write_digest(const PdfObj& byte_range, size_t digest_offset, size_t digest_length, const PdfPkcs7Signer& signer)
{
	return mupdf::ppdf_write_digest(this->m_internal, byte_range.m_internal, digest_offset, digest_length, signer.m_internal);
}

Output::Output(fz_output* internal)
: m_internal(internal)
{
}

Output::~Output()
{
	mupdf::drop_output(m_internal);
}

/* Implementation of Overprint (wrapper for fz_overprint). */

Overprint::Overprint(fz_overprint* internal)
: m_internal(internal)
{
}

/* Implementation of Page (wrapper for fz_page). */

/* Constructor using fz_load_chapter_page(). */
Page::Page(const Document& doc, int chapter, int page)
{
	this->m_internal = mupdf::load_chapter_page(doc.m_internal, chapter, page);
}

/* Constructor using fz_load_page(). */
Page::Page(const Document& doc, int number)
{
	this->m_internal = mupdf::load_page(doc.m_internal, number);
}

/* Constructor using fz_new_page_of_size(). */
Page::Page(int size)
{
	this->m_internal = mupdf::new_page_of_size(size);
}

/* Copy constructor using fz_keep_page(). */
Page::Page(const Page& rhs)
: m_internal(mupdf::keep_page(rhs.m_internal))
{
}

/* operator= using fz_keep_page() and fz_drop_page(). */
Page& Page::operator=(const Page& rhs)
{
	mupdf::drop_page(this->m_internal);
	mupdf::keep_page(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_bound_page(). */
Rect Page::bound_page()
{
	fz_rect temp = mupdf::bound_page(this->m_internal);
	return Rect(&temp);
}

/* Wrapper for fz_load_links(). */
Link Page::load_links()
{
	fz_link* temp = mupdf::load_links(this->m_internal);
	return Link(temp);
}

/* Wrapper for fz_new_buffer_from_page(). */
Buffer Page::new_buffer_from_page(StextOptions& options)
{
	fz_buffer* temp = mupdf::new_buffer_from_page(this->m_internal, (const fz_stext_options *) &options.flags);
	return Buffer(temp);
}

/* Wrapper for fz_new_display_list_from_page(). */
DisplayList Page::new_display_list_from_page()
{
	fz_display_list* temp = mupdf::new_display_list_from_page(this->m_internal);
	return DisplayList(temp);
}

/* Wrapper for fz_new_display_list_from_page_contents(). */
DisplayList Page::new_display_list_from_page_contents()
{
	fz_display_list* temp = mupdf::new_display_list_from_page_contents(this->m_internal);
	return DisplayList(temp);
}

/* Wrapper for fz_new_pixmap_from_page(). */
Pixmap Page::new_pixmap_from_page(Matrix& ctm, const Colorspace& cs, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_page(this->m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_new_pixmap_from_page_contents(). */
Pixmap Page::new_pixmap_from_page_contents(Matrix& ctm, const Colorspace& cs, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_page_contents(this->m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_new_pixmap_from_page_contents_with_separations(). */
Pixmap Page::new_pixmap_from_page_contents_with_separations(Matrix& ctm, const Colorspace& cs, const Separations& seps, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_page_contents_with_separations(this->m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, seps.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_new_pixmap_from_page_with_separations(). */
Pixmap Page::new_pixmap_from_page_with_separations(Matrix& ctm, const Colorspace& cs, const Separations& seps, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_page_with_separations(this->m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, seps.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_page_presentation(). */
Transition Page::page_presentation(Transition& transition, float *duration)
{
	fz_transition* temp = mupdf::page_presentation(this->m_internal, (fz_transition *) &transition.type, duration);
	return Transition(temp);
}

/* Wrapper for fz_page_separations(). */
Separations Page::page_separations()
{
	fz_separations* temp = mupdf::page_separations(this->m_internal);
	return Separations(temp);
}

/* Wrapper for fz_page_uses_overprint(). */
int Page::page_uses_overprint()
{
	return mupdf::page_uses_overprint(this->m_internal);
}

/* Wrapper for fz_run_page(). */
void Page::run(const Device& dev, Matrix& transform, Cookie& cookie)
{
	return mupdf::run_page(this->m_internal, dev.m_internal, *(fz_matrix*) &transform.a, &cookie.m_internal);
}

/* Wrapper for fz_run_page_annots(). */
void Page::run_annots(const Device& dev, Matrix& transform, Cookie& cookie)
{
	return mupdf::run_page_annots(this->m_internal, dev.m_internal, *(fz_matrix*) &transform.a, &cookie.m_internal);
}

/* Wrapper for fz_run_page_contents(). */
void Page::run_contents(const Device& dev, Matrix& transform, Cookie& cookie)
{
	return mupdf::run_page_contents(this->m_internal, dev.m_internal, *(fz_matrix*) &transform.a, &cookie.m_internal);
}

/* Wrapper for fz_run_page_widgets(). */
void Page::run_widgets(const Device& dev, Matrix& transform, Cookie& cookie)
{
	return mupdf::run_page_widgets(this->m_internal, dev.m_internal, *(fz_matrix*) &transform.a, &cookie.m_internal);
}

/* Wrapper for fz_search_page(). */
int Page::search_page(const char *needle, Quad& hit_bbox, int hit_max)
{
	return mupdf::search_page(this->m_internal, needle, (fz_quad *) &hit_bbox.ul, hit_max);
}

/* Wrapper for pdf_page_from_fz_page(). */
PdfPage Page::pdf_page_from_fz_page()
{
	pdf_page* temp = mupdf::ppdf_page_from_fz_page(this->m_internal);
	return PdfPage(temp);
}

Page::Page(fz_page* internal)
: m_internal(internal)
{
}

Page::~Page()
{
	mupdf::drop_page(m_internal);
}

/* Implementation of Path (wrapper for fz_path). */

/* Constructor using fz_new_path(). */
Path::Path()
{
	this->m_internal = mupdf::new_path();
}

/* Copy constructor using fz_keep_path(). */
Path::Path(const Path& rhs)
: m_internal(mupdf::keep_path(rhs.m_internal))
{
}

/* operator= using fz_keep_path() and fz_drop_path(). */
Path& Path::operator=(const Path& rhs)
{
	mupdf::drop_path(this->m_internal);
	mupdf::keep_path(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_bound_path(). */
Rect Path::bound_path(const StrokeState& stroke, Matrix& ctm)
{
	fz_rect temp = mupdf::bound_path(this->m_internal, stroke.m_internal, *(fz_matrix*) &ctm.a);
	return Rect(&temp);
}

/* Wrapper for fz_clone_path(). */
Path Path::clone_path()
{
	fz_path* temp = mupdf::clone_path(this->m_internal);
	return Path(temp);
}

/* Wrapper for fz_closepath(). */
void Path::closepath()
{
	return mupdf::closepath(this->m_internal);
}

/* Wrapper for fz_currentpoint(). */
Point Path::currentpoint()
{
	fz_point temp = mupdf::currentpoint(this->m_internal);
	return Point(&temp);
}

/* Wrapper for fz_curveto(). */
void Path::curveto(float x0, float y0, float x1, float y1, float x2, float y2)
{
	return mupdf::curveto(this->m_internal, x0, y0, x1, y1, x2, y2);
}

/* Wrapper for fz_curvetov(). */
void Path::curvetov(float x1, float y1, float x2, float y2)
{
	return mupdf::curvetov(this->m_internal, x1, y1, x2, y2);
}

/* Wrapper for fz_curvetoy(). */
void Path::curvetoy(float x0, float y0, float x2, float y2)
{
	return mupdf::curvetoy(this->m_internal, x0, y0, x2, y2);
}

/* Wrapper for fz_lineto(). */
void Path::lineto(float x, float y)
{
	return mupdf::lineto(this->m_internal, x, y);
}

/* Wrapper for fz_moveto(). */
void Path::moveto(float x, float y)
{
	return mupdf::moveto(this->m_internal, x, y);
}

/* Wrapper for fz_packed_path_size(). */
int Path::packed_path_size()
{
	return mupdf::packed_path_size(this->m_internal);
}

/* Wrapper for fz_quadto(). */
void Path::quadto(float x0, float y0, float x1, float y1)
{
	return mupdf::quadto(this->m_internal, x0, y0, x1, y1);
}

/* Wrapper for fz_rectto(). */
void Path::rectto(float x0, float y0, float x1, float y1)
{
	return mupdf::rectto(this->m_internal, x0, y0, x1, y1);
}

/* Wrapper for fz_transform_path(). */
void Path::transform_path(Matrix& transform)
{
	return mupdf::transform_path(this->m_internal, *(fz_matrix*) &transform.a);
}

/* Wrapper for fz_trim_path(). */
void Path::trim_path()
{
	return mupdf::trim_path(this->m_internal);
}

/* Wrapper for fz_walk_path(). */
void Path::walk_path(const PathWalker& walker, void *arg)
{
	return mupdf::walk_path(this->m_internal, walker.m_internal, arg);
}

Path::Path(fz_path* internal)
: m_internal(internal)
{
}

Path::~Path()
{
	mupdf::drop_path(m_internal);
}

/* Implementation of PathWalker (wrapper for fz_path_walker). */

PathWalker::PathWalker(fz_path_walker* internal)
: m_internal(internal)
{
}

/* Implementation of PclOptions (wrapper for fz_pcl_options). */

/* Constructor using fz_parse_pcl_options(). */
PclOptions::PclOptions(const PclOptions& opts, const char *args)
{
	this->m_internal = mupdf::parse_pcl_options(opts.m_internal, args);
}

/* Wrapper for fz_pcl_preset(). */
void PclOptions::pcl_preset(const char *preset)
{
	return mupdf::pcl_preset(this->m_internal, preset);
}

PclOptions::PclOptions(fz_pcl_options* internal)
: m_internal(internal)
{
}

/* Implementation of PclmOptions (wrapper for fz_pclm_options). */

/* Constructor using fz_parse_pclm_options(). */
PclmOptions::PclmOptions(const PclmOptions& opts, const char *args)
{
	this->m_internal = mupdf::parse_pclm_options(opts.m_internal, args);
}

/* Custom constructor. */
PclmOptions::PclmOptions(const char *args)
{
	mupdf::parse_pclm_options(m_internal, args);
}

PclmOptions::PclmOptions(fz_pclm_options* internal)
: m_internal(internal)
{
}

/* Implementation of PdfAlertEvent (wrapper for pdf_alert_event). */

PdfAlertEvent::PdfAlertEvent(pdf_alert_event* internal)
: m_internal(internal)
{
}

/* Implementation of PdfAnnot (wrapper for pdf_annot). */

/* Copy constructor using pdf_keep_annot(). */
PdfAnnot::PdfAnnot(const PdfAnnot& rhs)
: m_internal(mupdf::ppdf_keep_annot(rhs.m_internal))
{
}

/* operator= using pdf_keep_annot() and pdf_drop_annot(). */
PdfAnnot& PdfAnnot::operator=(const PdfAnnot& rhs)
{
	mupdf::ppdf_drop_annot(this->m_internal);
	mupdf::ppdf_keep_annot(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for pdf_add_annot_ink_list_stroke(). */
void PdfAnnot::add_annot_ink_list_stroke()
{
	return mupdf::ppdf_add_annot_ink_list_stroke(this->m_internal);
}

/* Wrapper for pdf_add_annot_ink_list_stroke_vertex(). */
void PdfAnnot::add_annot_ink_list_stroke_vertex(Point& p)
{
	return mupdf::ppdf_add_annot_ink_list_stroke_vertex(this->m_internal, *(fz_point*) &p.x);
}

/* Wrapper for pdf_add_annot_quad_point(). */
void PdfAnnot::add_annot_quad_point(Quad& quad)
{
	return mupdf::ppdf_add_annot_quad_point(this->m_internal, *(fz_quad*) &quad.ul);
}

/* Wrapper for pdf_add_annot_vertex(). */
void PdfAnnot::add_annot_vertex(Point& p)
{
	return mupdf::ppdf_add_annot_vertex(this->m_internal, *(fz_point*) &p.x);
}

/* Wrapper for pdf_annot_MK_BC(). */
void PdfAnnot::annot_MK_BC(int *n, float color[4])
{
	return mupdf::ppdf_annot_MK_BC(this->m_internal, n, color);
}

/* Wrapper for pdf_annot_MK_BC_rgb(). */
int PdfAnnot::annot_MK_BC_rgb(float rgb[3])
{
	return mupdf::ppdf_annot_MK_BC_rgb(this->m_internal, rgb);
}

/* Wrapper for pdf_annot_MK_BG(). */
void PdfAnnot::annot_MK_BG(int *n, float color[4])
{
	return mupdf::ppdf_annot_MK_BG(this->m_internal, n, color);
}

/* Wrapper for pdf_annot_MK_BG_rgb(). */
int PdfAnnot::annot_MK_BG_rgb(float rgb[3])
{
	return mupdf::ppdf_annot_MK_BG_rgb(this->m_internal, rgb);
}

/* Wrapper for pdf_annot_author(). */
const char *PdfAnnot::annot_author()
{
	return mupdf::ppdf_annot_author(this->m_internal);
}

/* Wrapper for pdf_annot_border(). */
float PdfAnnot::annot_border()
{
	return mupdf::ppdf_annot_border(this->m_internal);
}

/* Wrapper for pdf_annot_color(). */
void PdfAnnot::annot_color(int *n, float color[4])
{
	return mupdf::ppdf_annot_color(this->m_internal, n, color);
}

/* Wrapper for pdf_annot_contents(). */
const char *PdfAnnot::annot_contents()
{
	return mupdf::ppdf_annot_contents(this->m_internal);
}

/* Wrapper for pdf_annot_default_appearance(). */
void PdfAnnot::annot_default_appearance(const char **font, float *size, float color[3])
{
	return mupdf::ppdf_annot_default_appearance(this->m_internal, font, size, color);
}

/* Wrapper for pdf_annot_event_blur(). */
void PdfAnnot::annot_event_blur()
{
	return mupdf::ppdf_annot_event_blur(this->m_internal);
}

/* Wrapper for pdf_annot_event_down(). */
void PdfAnnot::annot_event_down()
{
	return mupdf::ppdf_annot_event_down(this->m_internal);
}

/* Wrapper for pdf_annot_event_enter(). */
void PdfAnnot::annot_event_enter()
{
	return mupdf::ppdf_annot_event_enter(this->m_internal);
}

/* Wrapper for pdf_annot_event_exit(). */
void PdfAnnot::annot_event_exit()
{
	return mupdf::ppdf_annot_event_exit(this->m_internal);
}

/* Wrapper for pdf_annot_event_focus(). */
void PdfAnnot::annot_event_focus()
{
	return mupdf::ppdf_annot_event_focus(this->m_internal);
}

/* Wrapper for pdf_annot_event_page_close(). */
void PdfAnnot::annot_event_page_close()
{
	return mupdf::ppdf_annot_event_page_close(this->m_internal);
}

/* Wrapper for pdf_annot_event_page_invisible(). */
void PdfAnnot::annot_event_page_invisible()
{
	return mupdf::ppdf_annot_event_page_invisible(this->m_internal);
}

/* Wrapper for pdf_annot_event_page_open(). */
void PdfAnnot::annot_event_page_open()
{
	return mupdf::ppdf_annot_event_page_open(this->m_internal);
}

/* Wrapper for pdf_annot_event_page_visible(). */
void PdfAnnot::annot_event_page_visible()
{
	return mupdf::ppdf_annot_event_page_visible(this->m_internal);
}

/* Wrapper for pdf_annot_event_up(). */
void PdfAnnot::annot_event_up()
{
	return mupdf::ppdf_annot_event_up(this->m_internal);
}

/* Wrapper for pdf_annot_flags(). */
int PdfAnnot::annot_flags()
{
	return mupdf::ppdf_annot_flags(this->m_internal);
}

/* Wrapper for pdf_annot_has_author(). */
int PdfAnnot::annot_has_author()
{
	return mupdf::ppdf_annot_has_author(this->m_internal);
}

/* Wrapper for pdf_annot_has_icon_name(). */
int PdfAnnot::annot_has_icon_name()
{
	return mupdf::ppdf_annot_has_icon_name(this->m_internal);
}

/* Wrapper for pdf_annot_has_ink_list(). */
int PdfAnnot::annot_has_ink_list()
{
	return mupdf::ppdf_annot_has_ink_list(this->m_internal);
}

/* Wrapper for pdf_annot_has_interior_color(). */
int PdfAnnot::annot_has_interior_color()
{
	return mupdf::ppdf_annot_has_interior_color(this->m_internal);
}

/* Wrapper for pdf_annot_has_line(). */
int PdfAnnot::annot_has_line()
{
	return mupdf::ppdf_annot_has_line(this->m_internal);
}

/* Wrapper for pdf_annot_has_line_ending_styles(). */
int PdfAnnot::annot_has_line_ending_styles()
{
	return mupdf::ppdf_annot_has_line_ending_styles(this->m_internal);
}

/* Wrapper for pdf_annot_has_open(). */
int PdfAnnot::annot_has_open()
{
	return mupdf::ppdf_annot_has_open(this->m_internal);
}

/* Wrapper for pdf_annot_has_quad_points(). */
int PdfAnnot::annot_has_quad_points()
{
	return mupdf::ppdf_annot_has_quad_points(this->m_internal);
}

/* Wrapper for pdf_annot_has_vertices(). */
int PdfAnnot::annot_has_vertices()
{
	return mupdf::ppdf_annot_has_vertices(this->m_internal);
}

/* Wrapper for pdf_annot_icon_name(). */
const char *PdfAnnot::annot_icon_name()
{
	return mupdf::ppdf_annot_icon_name(this->m_internal);
}

/* Wrapper for pdf_annot_ink_list_count(). */
int PdfAnnot::annot_ink_list_count()
{
	return mupdf::ppdf_annot_ink_list_count(this->m_internal);
}

/* Wrapper for pdf_annot_ink_list_stroke_count(). */
int PdfAnnot::annot_ink_list_stroke_count(int i)
{
	return mupdf::ppdf_annot_ink_list_stroke_count(this->m_internal, i);
}

/* Wrapper for pdf_annot_ink_list_stroke_vertex(). */
Point PdfAnnot::annot_ink_list_stroke_vertex(int i, int k)
{
	fz_point temp = mupdf::ppdf_annot_ink_list_stroke_vertex(this->m_internal, i, k);
	return Point(&temp);
}

/* Wrapper for pdf_annot_interior_color(). */
void PdfAnnot::annot_interior_color(int *n, float color[4])
{
	return mupdf::ppdf_annot_interior_color(this->m_internal, n, color);
}

/* Wrapper for pdf_annot_is_open(). */
int PdfAnnot::annot_is_open()
{
	return mupdf::ppdf_annot_is_open(this->m_internal);
}

/* Wrapper for pdf_annot_language(). */
fz_text_language PdfAnnot::annot_language()
{
	return mupdf::ppdf_annot_language(this->m_internal);
}

/* Wrapper for pdf_annot_line(). */
void PdfAnnot::annot_line(Point& a, Point& b)
{
	return mupdf::ppdf_annot_line(this->m_internal, (fz_point *) &a.x, (fz_point *) &b.x);
}

/* Wrapper for pdf_annot_line_end_style(). */
enum pdf_line_ending PdfAnnot::annot_line_end_style()
{
	return mupdf::ppdf_annot_line_end_style(this->m_internal);
}

/* Wrapper for pdf_annot_line_ending_styles(). */
void PdfAnnot::annot_line_ending_styles(enum pdf_line_ending *start_style, enum pdf_line_ending *end_style)
{
	return mupdf::ppdf_annot_line_ending_styles(this->m_internal, start_style, end_style);
}

/* Wrapper for pdf_annot_line_start_style(). */
enum pdf_line_ending PdfAnnot::annot_line_start_style()
{
	return mupdf::ppdf_annot_line_start_style(this->m_internal);
}

/* Wrapper for pdf_annot_modification_date(). */
int64_t PdfAnnot::annot_modification_date()
{
	return mupdf::ppdf_annot_modification_date(this->m_internal);
}

/* Wrapper for pdf_annot_opacity(). */
float PdfAnnot::annot_opacity()
{
	return mupdf::ppdf_annot_opacity(this->m_internal);
}

/* Wrapper for pdf_annot_quad_point(). */
Quad PdfAnnot::annot_quad_point(int i)
{
	fz_quad temp = mupdf::ppdf_annot_quad_point(this->m_internal, i);
	return Quad(&temp);
}

/* Wrapper for pdf_annot_quad_point_count(). */
int PdfAnnot::annot_quad_point_count()
{
	return mupdf::ppdf_annot_quad_point_count(this->m_internal);
}

/* Wrapper for pdf_annot_quadding(). */
int PdfAnnot::annot_quadding()
{
	return mupdf::ppdf_annot_quadding(this->m_internal);
}

/* Wrapper for pdf_annot_rect(). */
Rect PdfAnnot::annot_rect()
{
	fz_rect temp = mupdf::ppdf_annot_rect(this->m_internal);
	return Rect(&temp);
}

/* Wrapper for pdf_annot_transform(). */
Matrix PdfAnnot::annot_transform()
{
	fz_matrix temp = mupdf::ppdf_annot_transform(this->m_internal);
	return Matrix(&temp);
}

/* Wrapper for pdf_annot_type(). */
enum pdf_annot_type PdfAnnot::annot_type()
{
	return mupdf::ppdf_annot_type(this->m_internal);
}

/* Wrapper for pdf_annot_vertex(). */
Point PdfAnnot::annot_vertex(int i)
{
	fz_point temp = mupdf::ppdf_annot_vertex(this->m_internal, i);
	return Point(&temp);
}

/* Wrapper for pdf_annot_vertex_count(). */
int PdfAnnot::annot_vertex_count()
{
	return mupdf::ppdf_annot_vertex_count(this->m_internal);
}

/* Wrapper for pdf_bound_annot(). */
Rect PdfAnnot::bound_annot()
{
	fz_rect temp = mupdf::ppdf_bound_annot(this->m_internal);
	return Rect(&temp);
}

/* Wrapper for pdf_bound_widget(). */
Rect PdfAnnot::bound_widget()
{
	fz_rect temp = mupdf::ppdf_bound_widget(this->m_internal);
	return Rect(&temp);
}

/* Wrapper for pdf_choice_widget_is_multiselect(). */
int PdfAnnot::choice_widget_is_multiselect()
{
	return mupdf::ppdf_choice_widget_is_multiselect(this->m_internal);
}

/* Wrapper for pdf_choice_widget_options(). */
int PdfAnnot::choice_widget_options(int exportval, const char *opts[])
{
	return mupdf::ppdf_choice_widget_options(this->m_internal, exportval, opts);
}

/* Wrapper for pdf_choice_widget_set_value(). */
void PdfAnnot::choice_widget_set_value(int n, const char *opts[])
{
	return mupdf::ppdf_choice_widget_set_value(this->m_internal, n, opts);
}

/* Wrapper for pdf_choice_widget_value(). */
int PdfAnnot::choice_widget_value(const char *opts[])
{
	return mupdf::ppdf_choice_widget_value(this->m_internal, opts);
}

/* Wrapper for pdf_clear_annot_ink_list(). */
void PdfAnnot::clear_annot_ink_list()
{
	return mupdf::ppdf_clear_annot_ink_list(this->m_internal);
}

/* Wrapper for pdf_clear_annot_quad_points(). */
void PdfAnnot::clear_annot_quad_points()
{
	return mupdf::ppdf_clear_annot_quad_points(this->m_internal);
}

/* Wrapper for pdf_clear_annot_vertices(). */
void PdfAnnot::clear_annot_vertices()
{
	return mupdf::ppdf_clear_annot_vertices(this->m_internal);
}

/* Wrapper for pdf_clear_signature(). */
void PdfAnnot::clear_signature()
{
	return mupdf::ppdf_clear_signature(this->m_internal);
}

/* Wrapper for pdf_dirty_annot(). */
void PdfAnnot::dirty_annot()
{
	return mupdf::ppdf_dirty_annot(this->m_internal);
}

/* Wrapper for pdf_get_widget_editing_state(). */
int PdfAnnot::get_widget_editing_state()
{
	return mupdf::ppdf_get_widget_editing_state(this->m_internal);
}

/* Wrapper for pdf_layout_text_widget(). */
LayoutBlock PdfAnnot::layout_text_widget()
{
	fz_layout_block* temp = mupdf::ppdf_layout_text_widget(this->m_internal);
	return LayoutBlock(temp);
}

/* Wrapper for pdf_new_display_list_from_annot(). */
DisplayList PdfAnnot::new_display_list_from_annot()
{
	fz_display_list* temp = mupdf::ppdf_new_display_list_from_annot(this->m_internal);
	return DisplayList(temp);
}

/* Wrapper for pdf_new_pixmap_from_annot(). */
Pixmap PdfAnnot::new_pixmap_from_annot(Matrix& ctm, const Colorspace& cs, const Separations& seps, int alpha)
{
	fz_pixmap* temp = mupdf::ppdf_new_pixmap_from_annot(this->m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, seps.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for pdf_next_annot(). */
PdfAnnot PdfAnnot::next_annot()
{
	pdf_annot* temp = mupdf::ppdf_next_annot(this->m_internal);
	return PdfAnnot(temp);
}

/* Wrapper for pdf_next_widget(). */
PdfAnnot PdfAnnot::next_widget()
{
	pdf_annot* temp = mupdf::ppdf_next_widget(this->m_internal);
	return PdfAnnot(temp);
}

/* Wrapper for pdf_run_annot(). */
void PdfAnnot::run_annot(const Device& dev, Matrix& ctm, Cookie& cookie)
{
	return mupdf::ppdf_run_annot(this->m_internal, dev.m_internal, *(fz_matrix*) &ctm.a, &cookie.m_internal);
}

/* Wrapper for pdf_set_annot_author(). */
void PdfAnnot::set_annot_author(const char *author)
{
	return mupdf::ppdf_set_annot_author(this->m_internal, author);
}

/* Wrapper for pdf_set_annot_border(). */
void PdfAnnot::set_annot_border(float width)
{
	return mupdf::ppdf_set_annot_border(this->m_internal, width);
}

/* Wrapper for pdf_set_annot_color(). */
void PdfAnnot::set_annot_color(int n, const float *color)
{
	return mupdf::ppdf_set_annot_color(this->m_internal, n, color);
}

/* Wrapper for pdf_set_annot_contents(). */
void PdfAnnot::set_annot_contents(const char *text)
{
	return mupdf::ppdf_set_annot_contents(this->m_internal, text);
}

/* Wrapper for pdf_set_annot_default_appearance(). */
void PdfAnnot::set_annot_default_appearance(const char *font, float size, const float color[3])
{
	return mupdf::ppdf_set_annot_default_appearance(this->m_internal, font, size, color);
}

/* Wrapper for pdf_set_annot_flags(). */
void PdfAnnot::set_annot_flags(int flags)
{
	return mupdf::ppdf_set_annot_flags(this->m_internal, flags);
}

/* Wrapper for pdf_set_annot_icon_name(). */
void PdfAnnot::set_annot_icon_name(const char *name)
{
	return mupdf::ppdf_set_annot_icon_name(this->m_internal, name);
}

/* Wrapper for pdf_set_annot_ink_list(). */
void PdfAnnot::set_annot_ink_list(int n, const int *count, Point& v)
{
	return mupdf::ppdf_set_annot_ink_list(this->m_internal, n, count, (const fz_point *) &v.x);
}

/* Wrapper for pdf_set_annot_interior_color(). */
void PdfAnnot::set_annot_interior_color(int n, const float *color)
{
	return mupdf::ppdf_set_annot_interior_color(this->m_internal, n, color);
}

/* Wrapper for pdf_set_annot_is_open(). */
void PdfAnnot::set_annot_is_open(int is_open)
{
	return mupdf::ppdf_set_annot_is_open(this->m_internal, is_open);
}

/* Wrapper for pdf_set_annot_language(). */
void PdfAnnot::set_annot_language(fz_text_language lang)
{
	return mupdf::ppdf_set_annot_language(this->m_internal, lang);
}

/* Wrapper for pdf_set_annot_line(). */
void PdfAnnot::set_annot_line(Point& a, Point& b)
{
	return mupdf::ppdf_set_annot_line(this->m_internal, *(fz_point*) &a.x, *(fz_point*) &b.x);
}

/* Wrapper for pdf_set_annot_line_end_style(). */
void PdfAnnot::set_annot_line_end_style(enum pdf_line_ending e)
{
	return mupdf::ppdf_set_annot_line_end_style(this->m_internal, e);
}

/* Wrapper for pdf_set_annot_line_ending_styles(). */
void PdfAnnot::set_annot_line_ending_styles(enum pdf_line_ending start_style, enum pdf_line_ending end_style)
{
	return mupdf::ppdf_set_annot_line_ending_styles(this->m_internal, start_style, end_style);
}

/* Wrapper for pdf_set_annot_line_start_style(). */
void PdfAnnot::set_annot_line_start_style(enum pdf_line_ending s)
{
	return mupdf::ppdf_set_annot_line_start_style(this->m_internal, s);
}

/* Wrapper for pdf_set_annot_modification_date(). */
void PdfAnnot::set_annot_modification_date(int64_t time)
{
	return mupdf::ppdf_set_annot_modification_date(this->m_internal, time);
}

/* Wrapper for pdf_set_annot_opacity(). */
void PdfAnnot::set_annot_opacity(float opacity)
{
	return mupdf::ppdf_set_annot_opacity(this->m_internal, opacity);
}

/* Wrapper for pdf_set_annot_quad_points(). */
void PdfAnnot::set_annot_quad_points(int n, Quad& qv)
{
	return mupdf::ppdf_set_annot_quad_points(this->m_internal, n, (const fz_quad *) &qv.ul);
}

/* Wrapper for pdf_set_annot_quadding(). */
void PdfAnnot::set_annot_quadding(int q)
{
	return mupdf::ppdf_set_annot_quadding(this->m_internal, q);
}

/* Wrapper for pdf_set_annot_rect(). */
void PdfAnnot::set_annot_rect(Rect& rect)
{
	return mupdf::ppdf_set_annot_rect(this->m_internal, *(fz_rect*) &rect.x0);
}

/* Wrapper for pdf_set_annot_vertex(). */
void PdfAnnot::set_annot_vertex(int i, Point& p)
{
	return mupdf::ppdf_set_annot_vertex(this->m_internal, i, *(fz_point*) &p.x);
}

/* Wrapper for pdf_set_annot_vertices(). */
void PdfAnnot::set_annot_vertices(int n, Point& v)
{
	return mupdf::ppdf_set_annot_vertices(this->m_internal, n, (const fz_point *) &v.x);
}

/* Wrapper for pdf_set_choice_field_value(). */
int PdfAnnot::set_choice_field_value(const char *value)
{
	return mupdf::ppdf_set_choice_field_value(this->m_internal, value);
}

/* Wrapper for pdf_set_text_field_value(). */
int PdfAnnot::set_text_field_value(const char *value)
{
	return mupdf::ppdf_set_text_field_value(this->m_internal, value);
}

/* Wrapper for pdf_set_widget_editing_state(). */
void PdfAnnot::set_widget_editing_state(int editing)
{
	return mupdf::ppdf_set_widget_editing_state(this->m_internal, editing);
}

/* Wrapper for pdf_sign_signature(). */
void PdfAnnot::sign_signature(const PdfPkcs7Signer& signer)
{
	return mupdf::ppdf_sign_signature(this->m_internal, signer.m_internal);
}

/* Wrapper for pdf_text_widget_format(). */
int PdfAnnot::text_widget_format()
{
	return mupdf::ppdf_text_widget_format(this->m_internal);
}

/* Wrapper for pdf_text_widget_max_len(). */
int PdfAnnot::text_widget_max_len()
{
	return mupdf::ppdf_text_widget_max_len(this->m_internal);
}

/* Wrapper for pdf_toggle_widget(). */
int PdfAnnot::toggle_widget()
{
	return mupdf::ppdf_toggle_widget(this->m_internal);
}

/* Wrapper for pdf_update_annot(). */
int PdfAnnot::update_annot()
{
	return mupdf::ppdf_update_annot(this->m_internal);
}

/* Wrapper for pdf_update_appearance(). */
void PdfAnnot::update_appearance()
{
	return mupdf::ppdf_update_appearance(this->m_internal);
}

/* Wrapper for pdf_update_signature_appearance(). */
void PdfAnnot::update_signature_appearance(const char *name, const char *text, const char *date)
{
	return mupdf::ppdf_update_signature_appearance(this->m_internal, name, text, date);
}

/* Wrapper for pdf_update_widget(). */
int PdfAnnot::update_widget()
{
	return mupdf::ppdf_update_widget(this->m_internal);
}

/* Wrapper for pdf_validate_signature(). */
int PdfAnnot::validate_signature()
{
	return mupdf::ppdf_validate_signature(this->m_internal);
}

/* Wrapper for pdf_widget_is_signed(). */
int PdfAnnot::widget_is_signed()
{
	return mupdf::ppdf_widget_is_signed(this->m_internal);
}

/* Wrapper for pdf_widget_type(). */
enum pdf_widget_type PdfAnnot::widget_type()
{
	return mupdf::ppdf_widget_type(this->m_internal);
}

PdfAnnot::PdfAnnot(pdf_annot* internal)
: m_internal(internal)
{
}

PdfAnnot::~PdfAnnot()
{
	mupdf::ppdf_drop_annot(m_internal);
}

/* Implementation of PdfCmap (wrapper for pdf_cmap). */

/* Constructor using pdf_new_cmap(). */
PdfCmap::PdfCmap()
{
	this->m_internal = mupdf::ppdf_new_cmap();
}

/* Constructor using pdf_new_identity_cmap(). */
PdfCmap::PdfCmap(int wmode, int bytes)
{
	this->m_internal = mupdf::ppdf_new_identity_cmap(wmode, bytes);
}

/* Copy constructor using pdf_keep_cmap(). */
PdfCmap::PdfCmap(const PdfCmap& rhs)
: m_internal(mupdf::ppdf_keep_cmap(rhs.m_internal))
{
}

/* operator= using pdf_keep_cmap() and pdf_drop_cmap(). */
PdfCmap& PdfCmap::operator=(const PdfCmap& rhs)
{
	mupdf::ppdf_drop_cmap(this->m_internal);
	mupdf::ppdf_keep_cmap(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for pdf_add_codespace(). */
void PdfCmap::add_codespace(unsigned int low, unsigned int high, size_t n)
{
	return mupdf::ppdf_add_codespace(this->m_internal, low, high, n);
}

/* Wrapper for pdf_cmap_size(). */
size_t PdfCmap::cmap_size()
{
	return mupdf::ppdf_cmap_size(this->m_internal);
}

/* Wrapper for pdf_cmap_wmode(). */
int PdfCmap::cmap_wmode()
{
	return mupdf::ppdf_cmap_wmode(this->m_internal);
}

/* Wrapper for pdf_decode_cmap(). */
int PdfCmap::decode_cmap(unsigned char *s, unsigned char *e, unsigned int *cpt)
{
	return mupdf::ppdf_decode_cmap(this->m_internal, s, e, cpt);
}

/* Wrapper for pdf_lookup_cmap(). */
int PdfCmap::lookup_cmap(unsigned int cpt)
{
	return mupdf::ppdf_lookup_cmap(this->m_internal, cpt);
}

/* Wrapper for pdf_lookup_cmap_full(). */
int PdfCmap::lookup_cmap_full(unsigned int cpt, int *out)
{
	return mupdf::ppdf_lookup_cmap_full(this->m_internal, cpt, out);
}

/* Wrapper for pdf_map_one_to_many(). */
void PdfCmap::map_one_to_many(unsigned int one, int *many, size_t len)
{
	return mupdf::ppdf_map_one_to_many(this->m_internal, one, many, len);
}

/* Wrapper for pdf_map_range_to_range(). */
void PdfCmap::map_range_to_range(unsigned int srclo, unsigned int srchi, int dstlo)
{
	return mupdf::ppdf_map_range_to_range(this->m_internal, srclo, srchi, dstlo);
}

/* Wrapper for pdf_set_cmap_wmode(). */
void PdfCmap::set_cmap_wmode(int wmode)
{
	return mupdf::ppdf_set_cmap_wmode(this->m_internal, wmode);
}

/* Wrapper for pdf_set_usecmap(). */
void PdfCmap::set_usecmap(const PdfCmap& usecmap)
{
	return mupdf::ppdf_set_usecmap(this->m_internal, usecmap.m_internal);
}

/* Wrapper for pdf_sort_cmap(). */
void PdfCmap::sort_cmap()
{
	return mupdf::ppdf_sort_cmap(this->m_internal);
}

PdfCmap::PdfCmap(pdf_cmap* internal)
: m_internal(internal)
{
}

PdfCmap::~PdfCmap()
{
	mupdf::ppdf_drop_cmap(m_internal);
}

/* Implementation of PdfCrypt (wrapper for pdf_crypt). */

/* Constructor using pdf_new_crypt(). */
PdfCrypt::PdfCrypt(const PdfObj& enc, const PdfObj& id)
{
	this->m_internal = mupdf::ppdf_new_crypt(enc.m_internal, id.m_internal);
}

/* Constructor using pdf_new_encrypt(). */
PdfCrypt::PdfCrypt(const char *opwd_utf8, const char *upwd_utf8, const PdfObj& id, int permissions, int algorithm)
{
	this->m_internal = mupdf::ppdf_new_encrypt(opwd_utf8, upwd_utf8, id.m_internal, permissions, algorithm);
}

/* Wrapper for pdf_crypt_encrypt_metadata(). */
int PdfCrypt::crypt_encrypt_metadata()
{
	return mupdf::ppdf_crypt_encrypt_metadata(this->m_internal);
}

/* Wrapper for pdf_crypt_key(). */
unsigned char *PdfCrypt::crypt_key()
{
	return mupdf::ppdf_crypt_key(this->m_internal);
}

/* Wrapper for pdf_crypt_length(). */
int PdfCrypt::crypt_length()
{
	return mupdf::ppdf_crypt_length(this->m_internal);
}

/* Wrapper for pdf_crypt_method(). */
char *PdfCrypt::crypt_method()
{
	return mupdf::ppdf_crypt_method(this->m_internal);
}

/* Wrapper for pdf_crypt_obj(). */
void PdfCrypt::crypt_obj(const PdfObj& obj, int num, int gen)
{
	return mupdf::ppdf_crypt_obj(this->m_internal, obj.m_internal, num, gen);
}

/* Wrapper for pdf_crypt_owner_encryption(). */
unsigned char *PdfCrypt::crypt_owner_encryption()
{
	return mupdf::ppdf_crypt_owner_encryption(this->m_internal);
}

/* Wrapper for pdf_crypt_owner_password(). */
unsigned char *PdfCrypt::crypt_owner_password()
{
	return mupdf::ppdf_crypt_owner_password(this->m_internal);
}

/* Wrapper for pdf_crypt_permissions(). */
int PdfCrypt::crypt_permissions()
{
	return mupdf::ppdf_crypt_permissions(this->m_internal);
}

/* Wrapper for pdf_crypt_permissions_encryption(). */
unsigned char *PdfCrypt::crypt_permissions_encryption()
{
	return mupdf::ppdf_crypt_permissions_encryption(this->m_internal);
}

/* Wrapper for pdf_crypt_revision(). */
int PdfCrypt::crypt_revision()
{
	return mupdf::ppdf_crypt_revision(this->m_internal);
}

/* Wrapper for pdf_crypt_user_encryption(). */
unsigned char *PdfCrypt::crypt_user_encryption()
{
	return mupdf::ppdf_crypt_user_encryption(this->m_internal);
}

/* Wrapper for pdf_crypt_user_password(). */
unsigned char *PdfCrypt::crypt_user_password()
{
	return mupdf::ppdf_crypt_user_password(this->m_internal);
}

/* Wrapper for pdf_crypt_version(). */
int PdfCrypt::crypt_version()
{
	return mupdf::ppdf_crypt_version(this->m_internal);
}

/* Wrapper for pdf_encrypt_data(). */
void PdfCrypt::encrypt_data(int num, int gen, void (*fmt_str_out)(fz_context *, void *, const unsigned char *, size_t ), void *arg, const unsigned char *s, size_t n)
{
	return mupdf::ppdf_encrypt_data(this->m_internal, num, gen, fmt_str_out, arg, s, n);
}

/* Wrapper for pdf_encrypted_len(). */
size_t PdfCrypt::encrypted_len(int num, int gen, size_t len)
{
	return mupdf::ppdf_encrypted_len(this->m_internal, num, gen, len);
}

PdfCrypt::PdfCrypt(pdf_crypt* internal)
: m_internal(internal)
{
}

PdfCrypt::~PdfCrypt()
{
	mupdf::ppdf_drop_crypt(m_internal);
}

/* Implementation of PdfCsi (wrapper for pdf_csi). */

PdfCsi::PdfCsi(pdf_csi* internal)
: m_internal(internal)
{
}

/* Implementation of PdfDocEvent (wrapper for pdf_doc_event). */

/* Wrapper for pdf_access_alert_event(). */
PdfAlertEvent PdfDocEvent::access_alert_event()
{
	pdf_alert_event* temp = mupdf::ppdf_access_alert_event(this->m_internal);
	return PdfAlertEvent(temp);
}

/* Wrapper for pdf_access_exec_menu_item_event(). */
const char *PdfDocEvent::access_exec_menu_item_event()
{
	return mupdf::ppdf_access_exec_menu_item_event(this->m_internal);
}

/* Wrapper for pdf_access_launch_url_event(). */
PdfLaunchUrlEvent PdfDocEvent::access_launch_url_event()
{
	pdf_launch_url_event* temp = mupdf::ppdf_access_launch_url_event(this->m_internal);
	return PdfLaunchUrlEvent(temp);
}

/* Wrapper for pdf_access_mail_doc_event(). */
PdfMailDocEvent PdfDocEvent::access_mail_doc_event()
{
	pdf_mail_doc_event* temp = mupdf::ppdf_access_mail_doc_event(this->m_internal);
	return PdfMailDocEvent(temp);
}

PdfDocEvent::PdfDocEvent(pdf_doc_event* internal)
: m_internal(internal)
{
}

/* Implementation of PdfDocument (wrapper for pdf_document). */

/* Constructor using pdf_open_document(). */
PdfDocument::PdfDocument(const char *filename)
{
	this->m_internal = mupdf::ppdf_open_document(filename);
}

/* Constructor using pdf_open_document_with_stream(). */
PdfDocument::PdfDocument(const Stream& file)
{
	this->m_internal = mupdf::ppdf_open_document_with_stream(file.m_internal);
}

/* Copy constructor using pdf_keep_document(). */
PdfDocument::PdfDocument(const PdfDocument& rhs)
: m_internal(mupdf::ppdf_keep_document(rhs.m_internal))
{
}

/* operator= using pdf_keep_document() and pdf_drop_document(). */
PdfDocument& PdfDocument::operator=(const PdfDocument& rhs)
{
	mupdf::ppdf_drop_document(this->m_internal);
	mupdf::ppdf_keep_document(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for pdf_add_cid_font(). */
PdfObj PdfDocument::add_cid_font(const Font& font)
{
	pdf_obj* temp = mupdf::ppdf_add_cid_font(this->m_internal, font.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_add_cjk_font(). */
PdfObj PdfDocument::add_cjk_font(const Font& font, int script, int wmode, int serif)
{
	pdf_obj* temp = mupdf::ppdf_add_cjk_font(this->m_internal, font.m_internal, script, wmode, serif);
	return PdfObj(temp);
}

/* Wrapper for pdf_add_embedded_file(). */
PdfObj PdfDocument::add_embedded_file(const char *filename, const char *mimetype, const Buffer& contents)
{
	pdf_obj* temp = mupdf::ppdf_add_embedded_file(this->m_internal, filename, mimetype, contents.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_add_image(). */
PdfObj PdfDocument::add_image(const Image& image)
{
	pdf_obj* temp = mupdf::ppdf_add_image(this->m_internal, image.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_add_new_array(). */
PdfObj PdfDocument::add_new_array(int initial)
{
	pdf_obj* temp = mupdf::ppdf_add_new_array(this->m_internal, initial);
	return PdfObj(temp);
}

/* Wrapper for pdf_add_new_dict(). */
PdfObj PdfDocument::add_new_dict(int initial)
{
	pdf_obj* temp = mupdf::ppdf_add_new_dict(this->m_internal, initial);
	return PdfObj(temp);
}

/* Wrapper for pdf_add_object(). */
PdfObj PdfDocument::add_object(const PdfObj& obj)
{
	pdf_obj* temp = mupdf::ppdf_add_object(this->m_internal, obj.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_add_object_drop(). */
PdfObj PdfDocument::add_object_drop(const PdfObj& obj)
{
	pdf_obj* temp = mupdf::ppdf_add_object_drop(this->m_internal, obj.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_add_page(). */
PdfObj PdfDocument::add_page(Rect& mediabox, int rotate, const PdfObj& resources, const Buffer& contents)
{
	pdf_obj* temp = mupdf::ppdf_add_page(this->m_internal, *(fz_rect*) &mediabox.x0, rotate, resources.m_internal, contents.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_add_simple_font(). */
PdfObj PdfDocument::add_simple_font(const Font& font, int encoding)
{
	pdf_obj* temp = mupdf::ppdf_add_simple_font(this->m_internal, font.m_internal, encoding);
	return PdfObj(temp);
}

/* Wrapper for pdf_add_stream(). */
PdfObj PdfDocument::add_stream(const Buffer& buf, const PdfObj& obj, int compressed)
{
	pdf_obj* temp = mupdf::ppdf_add_stream(this->m_internal, buf.m_internal, obj.m_internal, compressed);
	return PdfObj(temp);
}

/* Wrapper for pdf_authenticate_password(). */
int PdfDocument::authenticate_password(const char *pw)
{
	return mupdf::ppdf_authenticate_password(this->m_internal, pw);
}

/* Wrapper for pdf_cache_object(). */
PdfXrefEntry PdfDocument::cache_object(int num)
{
	pdf_xref_entry* temp = mupdf::ppdf_cache_object(this->m_internal, num);
	return PdfXrefEntry(temp);
}

/* Wrapper for pdf_calculate_form(). */
void PdfDocument::calculate_form()
{
	return mupdf::ppdf_calculate_form(this->m_internal);
}

/* Wrapper for pdf_can_be_saved_incrementally(). */
int PdfDocument::can_be_saved_incrementally()
{
	return mupdf::ppdf_can_be_saved_incrementally(this->m_internal);
}

/* Wrapper for pdf_clear_xref(). */
void PdfDocument::clear_xref()
{
	return mupdf::ppdf_clear_xref(this->m_internal);
}

/* Wrapper for pdf_clear_xref_to_mark(). */
void PdfDocument::clear_xref_to_mark()
{
	return mupdf::ppdf_clear_xref_to_mark(this->m_internal);
}

/* Wrapper for pdf_count_layer_config_ui(). */
int PdfDocument::count_layer_config_ui()
{
	return mupdf::ppdf_count_layer_config_ui(this->m_internal);
}

/* Wrapper for pdf_count_layer_configs(). */
int PdfDocument::count_layer_configs()
{
	return mupdf::ppdf_count_layer_configs(this->m_internal);
}

/* Wrapper for pdf_count_objects(). */
int PdfDocument::count_objects()
{
	return mupdf::ppdf_count_objects(this->m_internal);
}

/* Wrapper for pdf_count_pages(). */
int PdfDocument::count_pages()
{
	return mupdf::ppdf_count_pages(this->m_internal);
}

/* Wrapper for pdf_count_signatures(). */
int PdfDocument::count_signatures()
{
	return mupdf::ppdf_count_signatures(this->m_internal);
}

/* Wrapper for pdf_count_unsaved_versions(). */
int PdfDocument::count_unsaved_versions()
{
	return mupdf::ppdf_count_unsaved_versions(this->m_internal);
}

/* Wrapper for pdf_count_versions(). */
int PdfDocument::count_versions()
{
	return mupdf::ppdf_count_versions(this->m_internal);
}

/* Wrapper for pdf_create_object(). */
int PdfDocument::create_object()
{
	return mupdf::ppdf_create_object(this->m_internal);
}

/* Wrapper for pdf_delete_object(). */
void PdfDocument::delete_object(int num)
{
	return mupdf::ppdf_delete_object(this->m_internal, num);
}

/* Wrapper for pdf_delete_page(). */
void PdfDocument::delete_page(int number)
{
	return mupdf::ppdf_delete_page(this->m_internal, number);
}

/* Wrapper for pdf_delete_page_range(). */
void PdfDocument::delete_page_range(int start, int end)
{
	return mupdf::ppdf_delete_page_range(this->m_internal, start, end);
}

/* Wrapper for pdf_deselect_layer_config_ui(). */
void PdfDocument::deselect_layer_config_ui(int ui)
{
	return mupdf::ppdf_deselect_layer_config_ui(this->m_internal, ui);
}

/* Wrapper for pdf_disable_js(). */
void PdfDocument::disable_js()
{
	return mupdf::ppdf_disable_js(this->m_internal);
}

/* Wrapper for pdf_doc_was_linearized(). */
int PdfDocument::doc_was_linearized()
{
	return mupdf::ppdf_doc_was_linearized(this->m_internal);
}

/* Wrapper for pdf_document_event_did_print(). */
void PdfDocument::document_event_did_print()
{
	return mupdf::ppdf_document_event_did_print(this->m_internal);
}

/* Wrapper for pdf_document_event_did_save(). */
void PdfDocument::document_event_did_save()
{
	return mupdf::ppdf_document_event_did_save(this->m_internal);
}

/* Wrapper for pdf_document_event_will_close(). */
void PdfDocument::document_event_will_close()
{
	return mupdf::ppdf_document_event_will_close(this->m_internal);
}

/* Wrapper for pdf_document_event_will_print(). */
void PdfDocument::document_event_will_print()
{
	return mupdf::ppdf_document_event_will_print(this->m_internal);
}

/* Wrapper for pdf_document_event_will_save(). */
void PdfDocument::document_event_will_save()
{
	return mupdf::ppdf_document_event_will_save(this->m_internal);
}

/* Wrapper for pdf_document_language(). */
fz_text_language PdfDocument::document_language()
{
	return mupdf::ppdf_document_language(this->m_internal);
}

/* Wrapper for pdf_document_output_intent(). */
Colorspace PdfDocument::document_output_intent()
{
	fz_colorspace* temp = mupdf::ppdf_document_output_intent(this->m_internal);
	return Colorspace(temp);
}

/* Wrapper for pdf_document_permissions(). */
int PdfDocument::document_permissions()
{
	return mupdf::ppdf_document_permissions(this->m_internal);
}

/* Wrapper for pdf_empty_store(). */
void PdfDocument::empty_store()
{
	return mupdf::ppdf_empty_store(this->m_internal);
}

/* Wrapper for pdf_enable_js(). */
void PdfDocument::enable_js()
{
	return mupdf::ppdf_enable_js(this->m_internal);
}

/* Wrapper for pdf_ensure_solid_xref(). */
void PdfDocument::ensure_solid_xref(int num)
{
	return mupdf::ppdf_ensure_solid_xref(this->m_internal, num);
}

/* Wrapper for pdf_event_issue_alert(). */
void PdfDocument::event_issue_alert(const PdfAlertEvent& event)
{
	return mupdf::ppdf_event_issue_alert(this->m_internal, event.m_internal);
}

/* Wrapper for pdf_event_issue_exec_menu_item(). */
void PdfDocument::event_issue_exec_menu_item(const char *item)
{
	return mupdf::ppdf_event_issue_exec_menu_item(this->m_internal, item);
}

/* Wrapper for pdf_event_issue_launch_url(). */
void PdfDocument::event_issue_launch_url(const char *url, int new_frame)
{
	return mupdf::ppdf_event_issue_launch_url(this->m_internal, url, new_frame);
}

/* Wrapper for pdf_event_issue_mail_doc(). */
void PdfDocument::event_issue_mail_doc(const PdfMailDocEvent& event)
{
	return mupdf::ppdf_event_issue_mail_doc(this->m_internal, event.m_internal);
}

/* Wrapper for pdf_event_issue_print(). */
void PdfDocument::event_issue_print()
{
	return mupdf::ppdf_event_issue_print(this->m_internal);
}

/* Wrapper for pdf_field_event_calculate(). */
void PdfDocument::field_event_calculate(const PdfObj& field)
{
	return mupdf::ppdf_field_event_calculate(this->m_internal, field.m_internal);
}

/* Wrapper for pdf_field_event_format(). */
char *PdfDocument::field_event_format(const PdfObj& field)
{
	return mupdf::ppdf_field_event_format(this->m_internal, field.m_internal);
}

/* Wrapper for pdf_field_event_keystroke(). */
int PdfDocument::field_event_keystroke(const PdfObj& field, const PdfKeystrokeEvent& evt)
{
	return mupdf::ppdf_field_event_keystroke(this->m_internal, field.m_internal, evt.m_internal);
}

/* Wrapper for pdf_field_event_validate(). */
int PdfDocument::field_event_validate(const PdfObj& field, const char *value)
{
	return mupdf::ppdf_field_event_validate(this->m_internal, field.m_internal, value);
}

/* Wrapper for pdf_field_reset(). */
void PdfDocument::field_reset(const PdfObj& field)
{
	return mupdf::ppdf_field_reset(this->m_internal, field.m_internal);
}

/* Wrapper for pdf_filter_annot_contents(). */
void PdfDocument::filter_annot_contents(const PdfAnnot& annot, const PdfFilterOptions& filter)
{
	return mupdf::ppdf_filter_annot_contents(this->m_internal, annot.m_internal, filter.m_internal);
}

/* Wrapper for pdf_filter_page_contents(). */
void PdfDocument::filter_page_contents(const PdfPage& page, const PdfFilterOptions& filter)
{
	return mupdf::ppdf_filter_page_contents(this->m_internal, page.m_internal, filter.m_internal);
}

/* Wrapper for pdf_find_font_resource(). */
PdfObj PdfDocument::find_font_resource(int type, int encoding, const Font& item, unsigned char md5[16])
{
	pdf_obj* temp = mupdf::ppdf_find_font_resource(this->m_internal, type, encoding, item.m_internal, md5);
	return PdfObj(temp);
}

/* Wrapper for pdf_find_image_resource(). */
PdfObj PdfDocument::find_image_resource(const Image& item, unsigned char md5[16])
{
	pdf_obj* temp = mupdf::ppdf_find_image_resource(this->m_internal, item.m_internal, md5);
	return PdfObj(temp);
}

/* Wrapper for pdf_find_locked_fields(). */
PdfLockedFields PdfDocument::find_locked_fields(int version)
{
	pdf_locked_fields* temp = mupdf::ppdf_find_locked_fields(this->m_internal, version);
	return PdfLockedFields(temp);
}

/* Wrapper for pdf_find_locked_fields_for_sig(). */
PdfLockedFields PdfDocument::find_locked_fields_for_sig(const PdfObj& sig)
{
	pdf_locked_fields* temp = mupdf::ppdf_find_locked_fields_for_sig(this->m_internal, sig.m_internal);
	return PdfLockedFields(temp);
}

/* Wrapper for pdf_find_version_for_obj(). */
int PdfDocument::find_version_for_obj(const PdfObj& obj)
{
	return mupdf::ppdf_find_version_for_obj(this->m_internal, obj.m_internal);
}

/* Wrapper for pdf_forget_xref(). */
void PdfDocument::forget_xref()
{
	return mupdf::ppdf_forget_xref(this->m_internal);
}

/* Wrapper for pdf_get_doc_event_callback_data(). */
void *PdfDocument::get_doc_event_callback_data()
{
	return mupdf::ppdf_get_doc_event_callback_data(this->m_internal);
}

/* Wrapper for pdf_get_populating_xref_entry(). */
PdfXrefEntry PdfDocument::get_populating_xref_entry(int i)
{
	pdf_xref_entry* temp = mupdf::ppdf_get_populating_xref_entry(this->m_internal, i);
	return PdfXrefEntry(temp);
}

/* Wrapper for pdf_get_xref_entry(). */
PdfXrefEntry PdfDocument::get_xref_entry(int i)
{
	pdf_xref_entry* temp = mupdf::ppdf_get_xref_entry(this->m_internal, i);
	return PdfXrefEntry(temp);
}

/* Wrapper for pdf_graft_object(). */
PdfObj PdfDocument::graft_object(const PdfObj& obj)
{
	pdf_obj* temp = mupdf::ppdf_graft_object(this->m_internal, obj.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_has_permission(). */
int PdfDocument::has_permission(fz_permission p)
{
	return mupdf::ppdf_has_permission(this->m_internal, p);
}

/* Wrapper for pdf_has_unsaved_changes(). */
int PdfDocument::has_unsaved_changes()
{
	return mupdf::ppdf_has_unsaved_changes(this->m_internal);
}

/* Wrapper for pdf_has_unsaved_sigs(). */
int PdfDocument::has_unsaved_sigs()
{
	return mupdf::ppdf_has_unsaved_sigs(this->m_internal);
}

/* Wrapper for pdf_insert_font_resource(). */
PdfObj PdfDocument::insert_font_resource(unsigned char md5[16], const PdfObj& obj)
{
	pdf_obj* temp = mupdf::ppdf_insert_font_resource(this->m_internal, md5, obj.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_insert_image_resource(). */
PdfObj PdfDocument::insert_image_resource(unsigned char md5[16], const PdfObj& obj)
{
	pdf_obj* temp = mupdf::ppdf_insert_image_resource(this->m_internal, md5, obj.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_insert_page(). */
void PdfDocument::insert_page(int at, const PdfObj& page)
{
	return mupdf::ppdf_insert_page(this->m_internal, at, page.m_internal);
}

/* Wrapper for pdf_invalidate_xfa(). */
void PdfDocument::invalidate_xfa()
{
	return mupdf::ppdf_invalidate_xfa(this->m_internal);
}

/* Wrapper for pdf_js_supported(). */
int PdfDocument::js_supported()
{
	return mupdf::ppdf_js_supported(this->m_internal);
}

/* Wrapper for pdf_layer_config_info(). */
void PdfDocument::layer_config_info(int config_num, const PdfLayerConfig& info)
{
	return mupdf::ppdf_layer_config_info(this->m_internal, config_num, info.m_internal);
}

/* Wrapper for pdf_layer_config_ui_info(). */
void PdfDocument::layer_config_ui_info(int ui, const PdfLayerConfigUi& info)
{
	return mupdf::ppdf_layer_config_ui_info(this->m_internal, ui, info.m_internal);
}

/* Wrapper for pdf_load_compressed_inline_image(). */
void PdfDocument::load_compressed_inline_image(const PdfObj& dict, int length, const Stream& cstm, int indexed, const CompressedImage& image)
{
	return mupdf::ppdf_load_compressed_inline_image(this->m_internal, dict.m_internal, length, cstm.m_internal, indexed, image.m_internal);
}

/* Wrapper for pdf_load_compressed_stream(). */
CompressedBuffer PdfDocument::load_compressed_stream(int num)
{
	fz_compressed_buffer* temp = mupdf::ppdf_load_compressed_stream(this->m_internal, num);
	return CompressedBuffer(temp);
}

/* Wrapper for pdf_load_default_colorspaces(). */
DefaultColorspaces PdfDocument::load_default_colorspaces(const PdfPage& page)
{
	fz_default_colorspaces* temp = mupdf::ppdf_load_default_colorspaces(this->m_internal, page.m_internal);
	return DefaultColorspaces(temp);
}

/* Wrapper for pdf_load_embedded_cmap(). */
PdfCmap PdfDocument::load_embedded_cmap(const PdfObj& ref)
{
	pdf_cmap* temp = mupdf::ppdf_load_embedded_cmap(this->m_internal, ref.m_internal);
	return PdfCmap(temp);
}

/* Wrapper for pdf_load_font(). */
PdfFontDesc PdfDocument::load_font(const PdfObj& rdb, const PdfObj& obj)
{
	pdf_font_desc* temp = mupdf::ppdf_load_font(this->m_internal, rdb.m_internal, obj.m_internal);
	return PdfFontDesc(temp);
}

/* Wrapper for pdf_load_hail_mary_font(). */
PdfFontDesc PdfDocument::load_hail_mary_font()
{
	pdf_font_desc* temp = mupdf::ppdf_load_hail_mary_font(this->m_internal);
	return PdfFontDesc(temp);
}

/* Wrapper for pdf_load_image(). */
Image PdfDocument::load_image(const PdfObj& obj)
{
	fz_image* temp = mupdf::ppdf_load_image(this->m_internal, obj.m_internal);
	return Image(temp);
}

/* Wrapper for pdf_load_inline_image(). */
Image PdfDocument::load_inline_image(const PdfObj& rdb, const PdfObj& dict, const Stream& file)
{
	fz_image* temp = mupdf::ppdf_load_inline_image(this->m_internal, rdb.m_internal, dict.m_internal, file.m_internal);
	return Image(temp);
}

/* Wrapper for pdf_load_link_annots(). */
Link PdfDocument::load_link_annots(const PdfObj& annots, int pagenum, Matrix& page_ctm)
{
	fz_link* temp = mupdf::ppdf_load_link_annots(this->m_internal, annots.m_internal, pagenum, *(fz_matrix*) &page_ctm.a);
	return Link(temp);
}

/* Wrapper for pdf_load_name_tree(). */
PdfObj PdfDocument::load_name_tree(const PdfObj& which)
{
	pdf_obj* temp = mupdf::ppdf_load_name_tree(this->m_internal, which.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_load_object(). */
PdfObj PdfDocument::load_object(int num)
{
	pdf_obj* temp = mupdf::ppdf_load_object(this->m_internal, num);
	return PdfObj(temp);
}

/* Wrapper for pdf_load_page(). */
PdfPage PdfDocument::load_page(int number)
{
	pdf_page* temp = mupdf::ppdf_load_page(this->m_internal, number);
	return PdfPage(temp);
}

/* Wrapper for pdf_load_page_tree(). */
void PdfDocument::load_page_tree()
{
	return mupdf::ppdf_load_page_tree(this->m_internal);
}

/* Wrapper for pdf_load_pattern(). */
PdfPattern PdfDocument::load_pattern(const PdfObj& obj)
{
	pdf_pattern* temp = mupdf::ppdf_load_pattern(this->m_internal, obj.m_internal);
	return PdfPattern(temp);
}

/* Wrapper for pdf_load_raw_stream_number(). */
Buffer PdfDocument::load_raw_stream_number(int num)
{
	fz_buffer* temp = mupdf::ppdf_load_raw_stream_number(this->m_internal, num);
	return Buffer(temp);
}

/* Wrapper for pdf_load_shading(). */
Shade PdfDocument::load_shading(const PdfObj& obj)
{
	fz_shade* temp = mupdf::ppdf_load_shading(this->m_internal, obj.m_internal);
	return Shade(temp);
}

/* Wrapper for pdf_load_stream_number(). */
Buffer PdfDocument::load_stream_number(int num)
{
	fz_buffer* temp = mupdf::ppdf_load_stream_number(this->m_internal, num);
	return Buffer(temp);
}

/* Wrapper for pdf_load_to_unicode(). */
void PdfDocument::load_to_unicode(const PdfFontDesc& font, const char **strings, char *collection, const PdfObj& cmapstm)
{
	return mupdf::ppdf_load_to_unicode(this->m_internal, font.m_internal, strings, collection, cmapstm.m_internal);
}

/* Wrapper for pdf_load_type3_font(). */
PdfFontDesc PdfDocument::load_type3_font(const PdfObj& rdb, const PdfObj& obj)
{
	pdf_font_desc* temp = mupdf::ppdf_load_type3_font(this->m_internal, rdb.m_internal, obj.m_internal);
	return PdfFontDesc(temp);
}

/* Wrapper for pdf_load_type3_glyphs(). */
void PdfDocument::load_type3_glyphs(const PdfFontDesc& fontdesc)
{
	return mupdf::ppdf_load_type3_glyphs(this->m_internal, fontdesc.m_internal);
}

/* Wrapper for pdf_load_unencrypted_object(). */
PdfObj PdfDocument::load_unencrypted_object(int num)
{
	pdf_obj* temp = mupdf::ppdf_load_unencrypted_object(this->m_internal, num);
	return PdfObj(temp);
}

/* Wrapper for pdf_localise_page_resources(). */
void PdfDocument::localise_page_resources()
{
	return mupdf::ppdf_localise_page_resources(this->m_internal);
}

/* Wrapper for pdf_lookup_anchor(). */
int PdfDocument::lookup_anchor(const char *name, float *xp, float *yp)
{
	return mupdf::ppdf_lookup_anchor(this->m_internal, name, xp, yp);
}

/* Wrapper for pdf_lookup_dest(). */
PdfObj PdfDocument::lookup_dest(const PdfObj& needle)
{
	pdf_obj* temp = mupdf::ppdf_lookup_dest(this->m_internal, needle.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_lookup_metadata(). */
int PdfDocument::lookup_metadata(const char *key, char *ptr, int size)
{
	return mupdf::ppdf_lookup_metadata(this->m_internal, key, ptr, size);
}

/* Wrapper for pdf_lookup_name(). */
PdfObj PdfDocument::lookup_name(const PdfObj& which, const PdfObj& needle)
{
	pdf_obj* temp = mupdf::ppdf_lookup_name(this->m_internal, which.m_internal, needle.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_lookup_page_number(). */
int PdfDocument::lookup_page_number(const PdfObj& pageobj)
{
	return mupdf::ppdf_lookup_page_number(this->m_internal, pageobj.m_internal);
}

/* Wrapper for pdf_lookup_page_obj(). */
PdfObj PdfDocument::lookup_page_obj(int needle)
{
	pdf_obj* temp = mupdf::ppdf_lookup_page_obj(this->m_internal, needle);
	return PdfObj(temp);
}

/* Wrapper for pdf_mark_xref(). */
void PdfDocument::mark_xref()
{
	return mupdf::ppdf_mark_xref(this->m_internal);
}

/* Wrapper for pdf_needs_password(). */
int PdfDocument::needs_password()
{
	return mupdf::ppdf_needs_password(this->m_internal);
}

/* Wrapper for pdf_new_array(). */
PdfObj PdfDocument::new_array(int initialcap)
{
	pdf_obj* temp = mupdf::ppdf_new_array(this->m_internal, initialcap);
	return PdfObj(temp);
}

/* Wrapper for pdf_new_dict(). */
PdfObj PdfDocument::new_dict(int initialcap)
{
	pdf_obj* temp = mupdf::ppdf_new_dict(this->m_internal, initialcap);
	return PdfObj(temp);
}

/* Wrapper for pdf_new_filter_processor(). */
PdfProcessor PdfDocument::new_filter_processor(const PdfProcessor& chain, const PdfObj& old_res, const PdfObj& new_res, int struct_parents, Matrix& transform, const PdfFilterOptions& filter)
{
	pdf_processor* temp = mupdf::ppdf_new_filter_processor(this->m_internal, chain.m_internal, old_res.m_internal, new_res.m_internal, struct_parents, *(fz_matrix*) &transform.a, filter.m_internal);
	return PdfProcessor(temp);
}

/* Wrapper for pdf_new_graft_map(). */
PdfGraftMap PdfDocument::new_graft_map()
{
	pdf_graft_map* temp = mupdf::ppdf_new_graft_map(this->m_internal);
	return PdfGraftMap(temp);
}

/* Wrapper for pdf_new_indirect(). */
PdfObj PdfDocument::new_indirect(int num, int gen)
{
	pdf_obj* temp = mupdf::ppdf_new_indirect(this->m_internal, num, gen);
	return PdfObj(temp);
}

/* Wrapper for pdf_new_matrix(). */
PdfObj PdfDocument::new_matrix(Matrix& mtx)
{
	pdf_obj* temp = mupdf::ppdf_new_matrix(this->m_internal, *(fz_matrix*) &mtx.a);
	return PdfObj(temp);
}

/* Wrapper for pdf_new_pdf_device(). */
Device PdfDocument::new_pdf_device(Matrix& topctm, Rect& mediabox, const PdfObj& resources, const Buffer& contents)
{
	fz_device* temp = mupdf::ppdf_new_pdf_device(this->m_internal, *(fz_matrix*) &topctm.a, *(fz_rect*) &mediabox.x0, resources.m_internal, contents.m_internal);
	return Device(temp);
}

/* Wrapper for pdf_new_rect(). */
PdfObj PdfDocument::new_rect(Rect& rect)
{
	pdf_obj* temp = mupdf::ppdf_new_rect(this->m_internal, *(fz_rect*) &rect.x0);
	return PdfObj(temp);
}

/* Wrapper for pdf_new_xobject(). */
PdfObj PdfDocument::new_xobject(Rect& bbox, Matrix& matrix, const PdfObj& res, const Buffer& buffer)
{
	pdf_obj* temp = mupdf::ppdf_new_xobject(this->m_internal, *(fz_rect*) &bbox.x0, *(fz_matrix*) &matrix.a, res.m_internal, buffer.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_obj_num_is_stream(). */
int PdfDocument::obj_num_is_stream(int num)
{
	return mupdf::ppdf_obj_num_is_stream(this->m_internal, num);
}

/* Wrapper for pdf_open_contents_stream(). */
Stream PdfDocument::open_contents_stream(const PdfObj& obj)
{
	fz_stream* temp = mupdf::ppdf_open_contents_stream(this->m_internal, obj.m_internal);
	return Stream(temp);
}

/* Wrapper for pdf_open_inline_stream(). */
Stream PdfDocument::open_inline_stream(const PdfObj& stmobj, int length, const Stream& chain, const CompressionParams& params)
{
	fz_stream* temp = mupdf::ppdf_open_inline_stream(this->m_internal, stmobj.m_internal, length, chain.m_internal, params.m_internal);
	return Stream(temp);
}

/* Wrapper for pdf_open_raw_stream_number(). */
Stream PdfDocument::open_raw_stream_number(int num)
{
	fz_stream* temp = mupdf::ppdf_open_raw_stream_number(this->m_internal, num);
	return Stream(temp);
}

/* Wrapper for pdf_open_stream_number(). */
Stream PdfDocument::open_stream_number(int num)
{
	fz_stream* temp = mupdf::ppdf_open_stream_number(this->m_internal, num);
	return Stream(temp);
}

/* Wrapper for pdf_open_stream_with_offset(). */
Stream PdfDocument::open_stream_with_offset(int num, const PdfObj& dict, int64_t stm_ofs)
{
	fz_stream* temp = mupdf::ppdf_open_stream_with_offset(this->m_internal, num, dict.m_internal, stm_ofs);
	return Stream(temp);
}

/* Wrapper for pdf_page_write(). */
Device PdfDocument::page_write(Rect& mediabox, PdfObj& presources, Buffer& pcontents)
{
	fz_device* temp = mupdf::ppdf_page_write(this->m_internal, *(fz_rect*) &mediabox.x0, &presources.m_internal, &pcontents.m_internal);
	return Device(temp);
}

/* Wrapper for pdf_parse_array(). */
PdfObj PdfDocument::parse_array(const Stream& f, const PdfLexbuf& buf)
{
	pdf_obj* temp = mupdf::ppdf_parse_array(this->m_internal, f.m_internal, buf.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_parse_dict(). */
PdfObj PdfDocument::parse_dict(const Stream& f, const PdfLexbuf& buf)
{
	pdf_obj* temp = mupdf::ppdf_parse_dict(this->m_internal, f.m_internal, buf.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_parse_ind_obj(). */
PdfObj PdfDocument::parse_ind_obj(const Stream& f, const PdfLexbuf& buf, int *num, int *gen, int64_t *stm_ofs, int *try_repair)
{
	pdf_obj* temp = mupdf::ppdf_parse_ind_obj(this->m_internal, f.m_internal, buf.m_internal, num, gen, stm_ofs, try_repair);
	return PdfObj(temp);
}

/* Wrapper for pdf_parse_link_action(). */
char *PdfDocument::parse_link_action(const PdfObj& obj, int pagenum)
{
	return mupdf::ppdf_parse_link_action(this->m_internal, obj.m_internal, pagenum);
}

/* Wrapper for pdf_parse_link_dest(). */
char *PdfDocument::parse_link_dest(const PdfObj& obj)
{
	return mupdf::ppdf_parse_link_dest(this->m_internal, obj.m_internal);
}

/* Wrapper for pdf_parse_stm_obj(). */
PdfObj PdfDocument::parse_stm_obj(const Stream& f, const PdfLexbuf& buf)
{
	pdf_obj* temp = mupdf::ppdf_parse_stm_obj(this->m_internal, f.m_internal, buf.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_progressive_advance(). */
PdfObj PdfDocument::progressive_advance(int pagenum)
{
	pdf_obj* temp = mupdf::ppdf_progressive_advance(this->m_internal, pagenum);
	return PdfObj(temp);
}

/* Wrapper for pdf_read_ocg(). */
void PdfDocument::read_ocg()
{
	return mupdf::ppdf_read_ocg(this->m_internal);
}

/* Wrapper for pdf_redact_page(). */
int PdfDocument::redact_page(const PdfPage& page, const PdfRedactOptions& opts)
{
	return mupdf::ppdf_redact_page(this->m_internal, page.m_internal, opts.m_internal);
}

/* Wrapper for pdf_repair_obj(). */
int PdfDocument::repair_obj(const PdfLexbuf& buf, int64_t *stmofsp, int *stmlenp, PdfObj& encrypt, PdfObj& id, PdfObj& page, int64_t *tmpofs, PdfObj& root)
{
	return mupdf::ppdf_repair_obj(this->m_internal, buf.m_internal, stmofsp, stmlenp, &encrypt.m_internal, &id.m_internal, &page.m_internal, tmpofs, &root.m_internal);
}

/* Wrapper for pdf_repair_obj_stms(). */
void PdfDocument::repair_obj_stms()
{
	return mupdf::ppdf_repair_obj_stms(this->m_internal);
}

/* Wrapper for pdf_repair_xref(). */
void PdfDocument::repair_xref()
{
	return mupdf::ppdf_repair_xref(this->m_internal);
}

/* Wrapper for pdf_replace_xref(). */
void PdfDocument::replace_xref(const PdfXrefEntry& entries, int n)
{
	return mupdf::ppdf_replace_xref(this->m_internal, entries.m_internal, n);
}

/* Wrapper for pdf_reset_form(). */
void PdfDocument::reset_form(const PdfObj& fields, int exclude)
{
	return mupdf::ppdf_reset_form(this->m_internal, fields.m_internal, exclude);
}

/* Wrapper for pdf_resolve_link(). */
int PdfDocument::resolve_link(const char *uri, float *xp, float *yp)
{
	return mupdf::ppdf_resolve_link(this->m_internal, uri, xp, yp);
}

/* Wrapper for pdf_run_glyph(). */
void PdfDocument::run_glyph(const PdfObj& resources, const Buffer& contents, const Device& dev, Matrix& ctm, void *gstate, const DefaultColorspaces& default_cs)
{
	return mupdf::ppdf_run_glyph(this->m_internal, resources.m_internal, contents.m_internal, dev.m_internal, *(fz_matrix*) &ctm.a, gstate, default_cs.m_internal);
}

/* Wrapper for pdf_run_page_with_usage(). */
void PdfDocument::run_page_with_usage(const PdfPage& page, const Device& dev, Matrix& ctm, const char *usage, Cookie& cookie)
{
	return mupdf::ppdf_run_page_with_usage(this->m_internal, page.m_internal, dev.m_internal, *(fz_matrix*) &ctm.a, usage, &cookie.m_internal);
}

/* Wrapper for pdf_save_document(). */
void PdfDocument::save_document(const char *filename, PdfWriteOptions& opts)
{
	return mupdf::ppdf_save_document(this->m_internal, filename, (pdf_write_options *) &opts.do_incremental);
}

/* Wrapper for pdf_select_layer_config(). */
void PdfDocument::select_layer_config(int config_num)
{
	return mupdf::ppdf_select_layer_config(this->m_internal, config_num);
}

/* Wrapper for pdf_select_layer_config_ui(). */
void PdfDocument::select_layer_config_ui(int ui)
{
	return mupdf::ppdf_select_layer_config_ui(this->m_internal, ui);
}

/* Wrapper for pdf_set_doc_event_callback(). */
void PdfDocument::set_doc_event_callback(pdf_doc_event_cb *event_cb, void *data)
{
	return mupdf::ppdf_set_doc_event_callback(this->m_internal, event_cb, data);
}

/* Wrapper for pdf_set_document_language(). */
void PdfDocument::set_document_language(fz_text_language lang)
{
	return mupdf::ppdf_set_document_language(this->m_internal, lang);
}

/* Wrapper for pdf_set_field_value(). */
int PdfDocument::set_field_value(const PdfObj& field, const char *text, int ignore_trigger_events)
{
	return mupdf::ppdf_set_field_value(this->m_internal, field.m_internal, text, ignore_trigger_events);
}

/* Wrapper for pdf_set_layer_config_as_default(). */
void PdfDocument::set_layer_config_as_default()
{
	return mupdf::ppdf_set_layer_config_as_default(this->m_internal);
}

/* Wrapper for pdf_set_populating_xref_trailer(). */
void PdfDocument::set_populating_xref_trailer(const PdfObj& trailer)
{
	return mupdf::ppdf_set_populating_xref_trailer(this->m_internal, trailer.m_internal);
}

/* Wrapper for pdf_signature_byte_range(). */
int PdfDocument::signature_byte_range(const PdfObj& signature, const Range& byte_range)
{
	return mupdf::ppdf_signature_byte_range(this->m_internal, signature.m_internal, byte_range.m_internal);
}

/* Wrapper for pdf_signature_contents(). */
size_t PdfDocument::signature_contents(const PdfObj& signature, char **contents)
{
	return mupdf::ppdf_signature_contents(this->m_internal, signature.m_internal, contents);
}

/* Wrapper for pdf_signature_hash_bytes(). */
Stream PdfDocument::signature_hash_bytes(const PdfObj& signature)
{
	fz_stream* temp = mupdf::ppdf_signature_hash_bytes(this->m_internal, signature.m_internal);
	return Stream(temp);
}

/* Wrapper for pdf_signature_incremental_change_since_signing(). */
int PdfDocument::signature_incremental_change_since_signing(const PdfObj& signature)
{
	return mupdf::ppdf_signature_incremental_change_since_signing(this->m_internal, signature.m_internal);
}

/* Wrapper for pdf_signature_is_signed(). */
int PdfDocument::signature_is_signed(const PdfObj& field)
{
	return mupdf::ppdf_signature_is_signed(this->m_internal, field.m_internal);
}

/* Wrapper for pdf_signature_set_value(). */
void PdfDocument::signature_set_value(const PdfObj& field, const PdfPkcs7Signer& signer, int64_t stime)
{
	return mupdf::ppdf_signature_set_value(this->m_internal, field.m_internal, signer.m_internal, stime);
}

/* Wrapper for pdf_toggle_layer_config_ui(). */
void PdfDocument::toggle_layer_config_ui(int ui)
{
	return mupdf::ppdf_toggle_layer_config_ui(this->m_internal, ui);
}

/* Wrapper for pdf_trailer(). */
PdfObj PdfDocument::trailer()
{
	pdf_obj* temp = mupdf::ppdf_trailer(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_update_object(). */
void PdfDocument::update_object(int num, const PdfObj& obj)
{
	return mupdf::ppdf_update_object(this->m_internal, num, obj.m_internal);
}

/* Wrapper for pdf_update_stream(). */
void PdfDocument::update_stream(const PdfObj& ref, const Buffer& buf, int compressed)
{
	return mupdf::ppdf_update_stream(this->m_internal, ref.m_internal, buf.m_internal, compressed);
}

/* Wrapper for pdf_update_xobject(). */
void PdfDocument::update_xobject(const PdfObj& xobj, Rect& bbox, Matrix& mat, const PdfObj& res, const Buffer& buffer)
{
	return mupdf::ppdf_update_xobject(this->m_internal, xobj.m_internal, *(fz_rect*) &bbox.x0, *(fz_matrix*) &mat.a, res.m_internal, buffer.m_internal);
}

/* Wrapper for pdf_validate_change_history(). */
int PdfDocument::validate_change_history()
{
	return mupdf::ppdf_validate_change_history(this->m_internal);
}

/* Wrapper for pdf_validate_changes(). */
int PdfDocument::validate_changes(int version)
{
	return mupdf::ppdf_validate_changes(this->m_internal, version);
}

/* Wrapper for pdf_version(). */
int PdfDocument::version()
{
	return mupdf::ppdf_version(this->m_internal);
}

/* Wrapper for pdf_was_pure_xfa(). */
int PdfDocument::was_pure_xfa()
{
	return mupdf::ppdf_was_pure_xfa(this->m_internal);
}

/* Wrapper for pdf_write_document(). */
void PdfDocument::write_document(const Output& out, PdfWriteOptions& opts)
{
	return mupdf::ppdf_write_document(this->m_internal, out.m_internal, (pdf_write_options *) &opts.do_incremental);
}

/* Wrapper for pdf_xref_ensure_incremental_object(). */
void PdfDocument::xref_ensure_incremental_object(int num)
{
	return mupdf::ppdf_xref_ensure_incremental_object(this->m_internal, num);
}

/* Wrapper for pdf_xref_is_incremental(). */
int PdfDocument::xref_is_incremental(int num)
{
	return mupdf::ppdf_xref_is_incremental(this->m_internal, num);
}

/* Wrapper for pdf_xref_len(). */
int PdfDocument::xref_len()
{
	return mupdf::ppdf_xref_len(this->m_internal);
}

/* Wrapper for pdf_xref_obj_is_unsaved_signature(). */
int PdfDocument::xref_obj_is_unsaved_signature(const PdfObj& obj)
{
	return mupdf::ppdf_xref_obj_is_unsaved_signature(this->m_internal, obj.m_internal);
}

/* Wrapper for pdf_xref_store_unsaved_signature(). */
void PdfDocument::xref_store_unsaved_signature(const PdfObj& field, const PdfPkcs7Signer& signer)
{
	return mupdf::ppdf_xref_store_unsaved_signature(this->m_internal, field.m_internal, signer.m_internal);
}

PdfDocument::PdfDocument(pdf_document* internal)
: m_internal(internal)
{
}

PdfDocument::~PdfDocument()
{
	mupdf::ppdf_drop_document(m_internal);
}

/* Implementation of PdfFilterOptions (wrapper for pdf_filter_options). */

PdfFilterOptions::PdfFilterOptions(pdf_filter_options* internal)
: m_internal(internal)
{
}

/* Implementation of PdfFontDesc (wrapper for pdf_font_desc). */

/* Constructor using pdf_new_font_desc(). */
PdfFontDesc::PdfFontDesc()
{
	this->m_internal = mupdf::ppdf_new_font_desc();
}

/* Wrapper for pdf_add_hmtx(). */
void PdfFontDesc::add_hmtx(int lo, int hi, int w)
{
	return mupdf::ppdf_add_hmtx(this->m_internal, lo, hi, w);
}

/* Wrapper for pdf_add_vmtx(). */
void PdfFontDesc::add_vmtx(int lo, int hi, int x, int y, int w)
{
	return mupdf::ppdf_add_vmtx(this->m_internal, lo, hi, x, y, w);
}

/* Wrapper for pdf_end_hmtx(). */
void PdfFontDesc::end_hmtx()
{
	return mupdf::ppdf_end_hmtx(this->m_internal);
}

/* Wrapper for pdf_end_vmtx(). */
void PdfFontDesc::end_vmtx()
{
	return mupdf::ppdf_end_vmtx(this->m_internal);
}

/* Wrapper for pdf_font_cid_to_gid(). */
int PdfFontDesc::font_cid_to_gid(int cid)
{
	return mupdf::ppdf_font_cid_to_gid(this->m_internal, cid);
}

/* Wrapper for pdf_lookup_hmtx(). */
PdfHmtx PdfFontDesc::lookup_hmtx(int cid)
{
	pdf_hmtx temp = mupdf::ppdf_lookup_hmtx(this->m_internal, cid);
	return PdfHmtx(&temp);
}

/* Wrapper for pdf_lookup_vmtx(). */
PdfVmtx PdfFontDesc::lookup_vmtx(int cid)
{
	pdf_vmtx temp = mupdf::ppdf_lookup_vmtx(this->m_internal, cid);
	return PdfVmtx(&temp);
}

/* Wrapper for pdf_set_default_hmtx(). */
void PdfFontDesc::set_default_hmtx(int w)
{
	return mupdf::ppdf_set_default_hmtx(this->m_internal, w);
}

/* Wrapper for pdf_set_default_vmtx(). */
void PdfFontDesc::set_default_vmtx(int y, int w)
{
	return mupdf::ppdf_set_default_vmtx(this->m_internal, y, w);
}

/* Wrapper for pdf_set_font_wmode(). */
void PdfFontDesc::set_font_wmode(int wmode)
{
	return mupdf::ppdf_set_font_wmode(this->m_internal, wmode);
}

PdfFontDesc::PdfFontDesc(pdf_font_desc* internal)
: m_internal(internal)
{
}

/* Implementation of PdfFunction (wrapper for pdf_function). */

/* Copy constructor using pdf_keep_function(). */
PdfFunction::PdfFunction(const PdfFunction& rhs)
: m_internal(mupdf::ppdf_keep_function(rhs.m_internal))
{
}

/* operator= using pdf_keep_function() and pdf_drop_function(). */
PdfFunction& PdfFunction::operator=(const PdfFunction& rhs)
{
	mupdf::ppdf_drop_function(this->m_internal);
	mupdf::ppdf_keep_function(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for pdf_eval_function(). */
void PdfFunction::eval_function(const float *in, int inlen, float *out, int outlen)
{
	return mupdf::ppdf_eval_function(this->m_internal, in, inlen, out, outlen);
}

/* Wrapper for pdf_function_size(). */
size_t PdfFunction::function_size()
{
	return mupdf::ppdf_function_size(this->m_internal);
}

PdfFunction::PdfFunction(pdf_function* internal)
: m_internal(internal)
{
}

PdfFunction::~PdfFunction()
{
	mupdf::ppdf_drop_function(m_internal);
}

/* Implementation of PdfGraftMap (wrapper for pdf_graft_map). */

/* Constructor using pdf_new_graft_map(). */
PdfGraftMap::PdfGraftMap(const PdfDocument& dst)
{
	this->m_internal = mupdf::ppdf_new_graft_map(dst.m_internal);
}

/* Copy constructor using pdf_keep_graft_map(). */
PdfGraftMap::PdfGraftMap(const PdfGraftMap& rhs)
: m_internal(mupdf::ppdf_keep_graft_map(rhs.m_internal))
{
}

/* operator= using pdf_keep_graft_map() and pdf_drop_graft_map(). */
PdfGraftMap& PdfGraftMap::operator=(const PdfGraftMap& rhs)
{
	mupdf::ppdf_drop_graft_map(this->m_internal);
	mupdf::ppdf_keep_graft_map(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for pdf_graft_mapped_object(). */
PdfObj PdfGraftMap::graft_mapped_object(const PdfObj& obj)
{
	pdf_obj* temp = mupdf::ppdf_graft_mapped_object(this->m_internal, obj.m_internal);
	return PdfObj(temp);
}

PdfGraftMap::PdfGraftMap(pdf_graft_map* internal)
: m_internal(internal)
{
}

PdfGraftMap::~PdfGraftMap()
{
	mupdf::ppdf_drop_graft_map(m_internal);
}

/* Implementation of PdfGstate (wrapper for pdf_gstate). */

PdfGstate::PdfGstate(pdf_gstate* internal)
: m_internal(internal)
{
}

/* Implementation of PdfHintPage (wrapper for pdf_hint_page). */

PdfHintPage::PdfHintPage(pdf_hint_page* internal)
: m_internal(internal)
{
}

/* Implementation of PdfHintShared (wrapper for pdf_hint_shared). */

PdfHintShared::PdfHintShared(pdf_hint_shared* internal)
: m_internal(internal)
{
}

/* Implementation of PdfHmtx (wrapper for pdf_hmtx). */

PdfHmtx::PdfHmtx(pdf_hmtx* internal)
: m_internal(internal)
{
}

/* Implementation of PdfJs (wrapper for pdf_js). */

/* Wrapper for pdf_js_event_init(). */
void PdfJs::js_event_init(const PdfObj& target, const char *value, int willCommit)
{
	return mupdf::ppdf_js_event_init(this->m_internal, target.m_internal, value, willCommit);
}

/* Wrapper for pdf_js_event_init_keystroke(). */
void PdfJs::js_event_init_keystroke(const PdfObj& target, const PdfKeystrokeEvent& evt)
{
	return mupdf::ppdf_js_event_init_keystroke(this->m_internal, target.m_internal, evt.m_internal);
}

/* Wrapper for pdf_js_event_result(). */
int PdfJs::js_event_result()
{
	return mupdf::ppdf_js_event_result(this->m_internal);
}

/* Wrapper for pdf_js_event_result_keystroke(). */
int PdfJs::js_event_result_keystroke(const PdfKeystrokeEvent& evt)
{
	return mupdf::ppdf_js_event_result_keystroke(this->m_internal, evt.m_internal);
}

/* Wrapper for pdf_js_event_value(). */
char *PdfJs::js_event_value()
{
	return mupdf::ppdf_js_event_value(this->m_internal);
}

/* Wrapper for pdf_js_execute(). */
void PdfJs::js_execute(const char *name, const char *code)
{
	return mupdf::ppdf_js_execute(this->m_internal, name, code);
}

PdfJs::PdfJs(pdf_js* internal)
: m_internal(internal)
{
}

PdfJs::~PdfJs()
{
	mupdf::ppdf_drop_js(m_internal);
}

/* Implementation of PdfKeystrokeEvent (wrapper for pdf_keystroke_event). */

PdfKeystrokeEvent::PdfKeystrokeEvent(pdf_keystroke_event* internal)
: m_internal(internal)
{
}

/* Implementation of PdfLaunchUrlEvent (wrapper for pdf_launch_url_event). */

PdfLaunchUrlEvent::PdfLaunchUrlEvent(pdf_launch_url_event* internal)
: m_internal(internal)
{
}

/* Implementation of PdfLayerConfig (wrapper for pdf_layer_config). */

PdfLayerConfig::PdfLayerConfig(pdf_layer_config* internal)
: m_internal(internal)
{
}

/* Implementation of PdfLayerConfigUi (wrapper for pdf_layer_config_ui). */

PdfLayerConfigUi::PdfLayerConfigUi(pdf_layer_config_ui* internal)
: m_internal(internal)
{
}

/* Implementation of PdfLexbuf (wrapper for pdf_lexbuf). */

/* Wrapper for pdf_lexbuf_fin(). */
void PdfLexbuf::lexbuf_fin()
{
	return mupdf::ppdf_lexbuf_fin(this->m_internal);
}

/* Wrapper for pdf_lexbuf_grow(). */
ptrdiff_t PdfLexbuf::lexbuf_grow()
{
	return mupdf::ppdf_lexbuf_grow(this->m_internal);
}

/* Wrapper for pdf_lexbuf_init(). */
void PdfLexbuf::lexbuf_init(int size)
{
	return mupdf::ppdf_lexbuf_init(this->m_internal, size);
}

PdfLexbuf::PdfLexbuf(pdf_lexbuf* internal)
: m_internal(internal)
{
}

/* Implementation of PdfLexbufLarge (wrapper for pdf_lexbuf_large). */

PdfLexbufLarge::PdfLexbufLarge(pdf_lexbuf_large* internal)
: m_internal(internal)
{
}

/* Implementation of PdfLockedFields (wrapper for pdf_locked_fields). */

/* Wrapper for pdf_is_field_locked(). */
int PdfLockedFields::is_field_locked(const char *name)
{
	return mupdf::ppdf_is_field_locked(this->m_internal, name);
}

PdfLockedFields::PdfLockedFields(pdf_locked_fields* internal)
: m_internal(internal)
{
}

PdfLockedFields::~PdfLockedFields()
{
	mupdf::ppdf_drop_locked_fields(m_internal);
}

/* Implementation of PdfMailDocEvent (wrapper for pdf_mail_doc_event). */

PdfMailDocEvent::PdfMailDocEvent(pdf_mail_doc_event* internal)
: m_internal(internal)
{
}

/* Implementation of PdfMrange (wrapper for pdf_mrange). */

PdfMrange::PdfMrange(pdf_mrange* internal)
: m_internal(internal)
{
}

/* Implementation of PdfObj (wrapper for pdf_obj). */

/* Constructor using pdf_new_array(). */
PdfObj::PdfObj(const PdfDocument& doc, int initialcap)
{
	this->m_internal = mupdf::ppdf_new_array(doc.m_internal, initialcap);
}

/* Constructor using pdf_new_indirect(). */
PdfObj::PdfObj(const PdfDocument& doc, int num, int gen)
{
	this->m_internal = mupdf::ppdf_new_indirect(doc.m_internal, num, gen);
}

/* Constructor using pdf_new_int(). */
PdfObj::PdfObj(int64_t i)
{
	this->m_internal = mupdf::ppdf_new_int(i);
}

/* Constructor using pdf_new_matrix(). */
PdfObj::PdfObj(const PdfDocument& doc, Matrix& mtx)
{
	this->m_internal = mupdf::ppdf_new_matrix(doc.m_internal, *(fz_matrix*) &mtx.a);
}

/* Constructor using pdf_new_name(). */
PdfObj::PdfObj(const char *str)
{
	this->m_internal = mupdf::ppdf_new_name(str);
}

/* Constructor using pdf_new_real(). */
PdfObj::PdfObj(float f)
{
	this->m_internal = mupdf::ppdf_new_real(f);
}

/* Constructor using pdf_new_rect(). */
PdfObj::PdfObj(const PdfDocument& doc, Rect& rect)
{
	this->m_internal = mupdf::ppdf_new_rect(doc.m_internal, *(fz_rect*) &rect.x0);
}

/* Constructor using pdf_new_string(). */
PdfObj::PdfObj(const char *str, size_t len)
{
	this->m_internal = mupdf::ppdf_new_string(str, len);
}

/* Constructor using pdf_new_xobject(). */
PdfObj::PdfObj(const PdfDocument& doc, Rect& bbox, Matrix& matrix, const PdfObj& res, const Buffer& buffer)
{
	this->m_internal = mupdf::ppdf_new_xobject(doc.m_internal, *(fz_rect*) &bbox.x0, *(fz_matrix*) &matrix.a, res.m_internal, buffer.m_internal);
}

/* Copy constructor using pdf_keep_obj(). */
PdfObj::PdfObj(const PdfObj& rhs)
: m_internal(mupdf::ppdf_keep_obj(rhs.m_internal))
{
}

/* operator= using pdf_keep_obj() and pdf_drop_obj(). */
PdfObj& PdfObj::operator=(const PdfObj& rhs)
{
	mupdf::ppdf_drop_obj(this->m_internal);
	mupdf::ppdf_keep_obj(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for pdf_new_text_string(). */
PdfObj PdfObj::new_text_string(const char *s)
{
	pdf_obj* temp = mupdf::ppdf_new_text_string(s);
	return PdfObj(temp);
}

/* Wrapper for pdf_new_dict(). */
PdfObj PdfObj::new_dict(const PdfDocument& doc, int initialcap)
{
	pdf_obj* temp = mupdf::ppdf_new_dict(doc.m_internal, initialcap);
	return PdfObj(temp);
}

/* Wrapper for pdf_array_contains(). */
int PdfObj::array_contains(const PdfObj& obj)
{
	return mupdf::ppdf_array_contains(this->m_internal, obj.m_internal);
}

/* Wrapper for pdf_array_delete(). */
void PdfObj::array_delete(int index)
{
	return mupdf::ppdf_array_delete(this->m_internal, index);
}

/* Wrapper for pdf_array_find(). */
int PdfObj::array_find(const PdfObj& obj)
{
	return mupdf::ppdf_array_find(this->m_internal, obj.m_internal);
}

/* Wrapper for pdf_array_get(). */
PdfObj PdfObj::array_get(int i)
{
	pdf_obj* temp = mupdf::ppdf_array_get(this->m_internal, i);
	return PdfObj(temp);
}

/* Wrapper for pdf_array_get_bool(). */
int PdfObj::array_get_bool(int index)
{
	return mupdf::ppdf_array_get_bool(this->m_internal, index);
}

/* Wrapper for pdf_array_get_int(). */
int PdfObj::array_get_int(int index)
{
	return mupdf::ppdf_array_get_int(this->m_internal, index);
}

/* Wrapper for pdf_array_get_matrix(). */
Matrix PdfObj::array_get_matrix(int index)
{
	fz_matrix temp = mupdf::ppdf_array_get_matrix(this->m_internal, index);
	return Matrix(&temp);
}

/* Wrapper for pdf_array_get_name(). */
const char *PdfObj::array_get_name(int index)
{
	return mupdf::ppdf_array_get_name(this->m_internal, index);
}

/* Wrapper for pdf_array_get_real(). */
float PdfObj::array_get_real(int index)
{
	return mupdf::ppdf_array_get_real(this->m_internal, index);
}

/* Wrapper for pdf_array_get_rect(). */
Rect PdfObj::array_get_rect(int index)
{
	fz_rect temp = mupdf::ppdf_array_get_rect(this->m_internal, index);
	return Rect(&temp);
}

/* Wrapper for pdf_array_get_string(). */
const char *PdfObj::array_get_string(int index, size_t *sizep)
{
	return mupdf::ppdf_array_get_string(this->m_internal, index, sizep);
}

/* Wrapper for pdf_array_get_text_string(). */
const char *PdfObj::array_get_text_string(int index)
{
	return mupdf::ppdf_array_get_text_string(this->m_internal, index);
}

/* Wrapper for pdf_array_insert(). */
void PdfObj::array_insert(const PdfObj& obj, int index)
{
	return mupdf::ppdf_array_insert(this->m_internal, obj.m_internal, index);
}

/* Wrapper for pdf_array_insert_drop(). */
void PdfObj::array_insert_drop(const PdfObj& obj, int index)
{
	return mupdf::ppdf_array_insert_drop(this->m_internal, obj.m_internal, index);
}

/* Wrapper for pdf_array_len(). */
int PdfObj::array_len()
{
	return mupdf::ppdf_array_len(this->m_internal);
}

/* Wrapper for pdf_array_push(). */
void PdfObj::array_push(const PdfObj& obj)
{
	return mupdf::ppdf_array_push(this->m_internal, obj.m_internal);
}

/* Wrapper for pdf_array_push_array(). */
PdfObj PdfObj::array_push_array(int initial)
{
	pdf_obj* temp = mupdf::ppdf_array_push_array(this->m_internal, initial);
	return PdfObj(temp);
}

/* Wrapper for pdf_array_push_bool(). */
void PdfObj::array_push_bool(int x)
{
	return mupdf::ppdf_array_push_bool(this->m_internal, x);
}

/* Wrapper for pdf_array_push_dict(). */
PdfObj PdfObj::array_push_dict(int initial)
{
	pdf_obj* temp = mupdf::ppdf_array_push_dict(this->m_internal, initial);
	return PdfObj(temp);
}

/* Wrapper for pdf_array_push_drop(). */
void PdfObj::array_push_drop(const PdfObj& obj)
{
	return mupdf::ppdf_array_push_drop(this->m_internal, obj.m_internal);
}

/* Wrapper for pdf_array_push_int(). */
void PdfObj::array_push_int(int64_t x)
{
	return mupdf::ppdf_array_push_int(this->m_internal, x);
}

/* Wrapper for pdf_array_push_name(). */
void PdfObj::array_push_name(const char *x)
{
	return mupdf::ppdf_array_push_name(this->m_internal, x);
}

/* Wrapper for pdf_array_push_real(). */
void PdfObj::array_push_real(double x)
{
	return mupdf::ppdf_array_push_real(this->m_internal, x);
}

/* Wrapper for pdf_array_push_string(). */
void PdfObj::array_push_string(const char *x, size_t n)
{
	return mupdf::ppdf_array_push_string(this->m_internal, x, n);
}

/* Wrapper for pdf_array_push_text_string(). */
void PdfObj::array_push_text_string(const char *x)
{
	return mupdf::ppdf_array_push_text_string(this->m_internal, x);
}

/* Wrapper for pdf_array_put(). */
void PdfObj::array_put(int i, const PdfObj& obj)
{
	return mupdf::ppdf_array_put(this->m_internal, i, obj.m_internal);
}

/* Wrapper for pdf_array_put_drop(). */
void PdfObj::array_put_drop(int i, const PdfObj& obj)
{
	return mupdf::ppdf_array_put_drop(this->m_internal, i, obj.m_internal);
}

/* Wrapper for pdf_button_field_on_state(). */
PdfObj PdfObj::button_field_on_state()
{
	pdf_obj* temp = mupdf::ppdf_button_field_on_state(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_choice_field_option(). */
const char *PdfObj::choice_field_option(int exportval, int i)
{
	return mupdf::ppdf_choice_field_option(this->m_internal, exportval, i);
}

/* Wrapper for pdf_choice_field_option_count(). */
int PdfObj::choice_field_option_count()
{
	return mupdf::ppdf_choice_field_option_count(this->m_internal);
}

/* Wrapper for pdf_clean_obj(). */
void PdfObj::clean_obj()
{
	return mupdf::ppdf_clean_obj(this->m_internal);
}

/* Wrapper for pdf_copy_array(). */
PdfObj PdfObj::copy_array()
{
	pdf_obj* temp = mupdf::ppdf_copy_array(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_copy_dict(). */
PdfObj PdfObj::copy_dict()
{
	pdf_obj* temp = mupdf::ppdf_copy_dict(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_debug_obj(). */
void PdfObj::debug_obj()
{
	return mupdf::ppdf_debug_obj(this->m_internal);
}

/* Wrapper for pdf_debug_ref(). */
void PdfObj::debug_ref()
{
	return mupdf::ppdf_debug_ref(this->m_internal);
}

/* Wrapper for pdf_deep_copy_obj(). */
PdfObj PdfObj::deep_copy_obj()
{
	pdf_obj* temp = mupdf::ppdf_deep_copy_obj(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_del(). */
void PdfObj::dict_del(const PdfObj& key)
{
	return mupdf::ppdf_dict_del(this->m_internal, key.m_internal);
}

/* Wrapper for pdf_dict_dels(). */
void PdfObj::dict_dels(const char *key)
{
	return mupdf::ppdf_dict_dels(this->m_internal, key);
}

/* Wrapper for pdf_dict_get(). */
PdfObj PdfObj::dict_get(const PdfObj& key)
{
	pdf_obj* temp = mupdf::ppdf_dict_get(this->m_internal, key.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_get_bool(). */
int PdfObj::dict_get_bool(const PdfObj& key)
{
	return mupdf::ppdf_dict_get_bool(this->m_internal, key.m_internal);
}

/* Wrapper for pdf_dict_get_inheritable(). */
PdfObj PdfObj::dict_get_inheritable(const PdfObj& key)
{
	pdf_obj* temp = mupdf::ppdf_dict_get_inheritable(this->m_internal, key.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_get_int(). */
int PdfObj::dict_get_int(const PdfObj& key)
{
	return mupdf::ppdf_dict_get_int(this->m_internal, key.m_internal);
}

/* Wrapper for pdf_dict_get_key(). */
PdfObj PdfObj::dict_get_key(int idx)
{
	pdf_obj* temp = mupdf::ppdf_dict_get_key(this->m_internal, idx);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_get_matrix(). */
Matrix PdfObj::dict_get_matrix(const PdfObj& key)
{
	fz_matrix temp = mupdf::ppdf_dict_get_matrix(this->m_internal, key.m_internal);
	return Matrix(&temp);
}

/* Wrapper for pdf_dict_get_name(). */
const char *PdfObj::dict_get_name(const PdfObj& key)
{
	return mupdf::ppdf_dict_get_name(this->m_internal, key.m_internal);
}

/* Wrapper for pdf_dict_get_put_drop(). */
void PdfObj::dict_get_put_drop(const PdfObj& key, const PdfObj& val, PdfObj& old_val)
{
	return mupdf::ppdf_dict_get_put_drop(this->m_internal, key.m_internal, val.m_internal, &old_val.m_internal);
}

/* Wrapper for pdf_dict_get_real(). */
float PdfObj::dict_get_real(const PdfObj& key)
{
	return mupdf::ppdf_dict_get_real(this->m_internal, key.m_internal);
}

/* Wrapper for pdf_dict_get_rect(). */
Rect PdfObj::dict_get_rect(const PdfObj& key)
{
	fz_rect temp = mupdf::ppdf_dict_get_rect(this->m_internal, key.m_internal);
	return Rect(&temp);
}

/* Wrapper for pdf_dict_get_string(). */
const char *PdfObj::dict_get_string(const PdfObj& key, size_t *sizep)
{
	return mupdf::ppdf_dict_get_string(this->m_internal, key.m_internal, sizep);
}

/* Wrapper for pdf_dict_get_text_string(). */
const char *PdfObj::dict_get_text_string(const PdfObj& key)
{
	return mupdf::ppdf_dict_get_text_string(this->m_internal, key.m_internal);
}

/* Wrapper for pdf_dict_get_val(). */
PdfObj PdfObj::dict_get_val(int idx)
{
	pdf_obj* temp = mupdf::ppdf_dict_get_val(this->m_internal, idx);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_geta(). */
PdfObj PdfObj::dict_geta(const PdfObj& key, const PdfObj& abbrev)
{
	pdf_obj* temp = mupdf::ppdf_dict_geta(this->m_internal, key.m_internal, abbrev.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_getp(). */
PdfObj PdfObj::dict_getp(const char *path)
{
	pdf_obj* temp = mupdf::ppdf_dict_getp(this->m_internal, path);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_gets(). */
PdfObj PdfObj::dict_gets(const char *key)
{
	pdf_obj* temp = mupdf::ppdf_dict_gets(this->m_internal, key);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_getsa(). */
PdfObj PdfObj::dict_getsa(const char *key, const char *abbrev)
{
	pdf_obj* temp = mupdf::ppdf_dict_getsa(this->m_internal, key, abbrev);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_len(). */
int PdfObj::dict_len()
{
	return mupdf::ppdf_dict_len(this->m_internal);
}

/* Wrapper for pdf_dict_put(). */
void PdfObj::dict_put(const PdfObj& key, const PdfObj& val)
{
	return mupdf::ppdf_dict_put(this->m_internal, key.m_internal, val.m_internal);
}

/* Wrapper for pdf_dict_put_array(). */
PdfObj PdfObj::dict_put_array(const PdfObj& key, int initial)
{
	pdf_obj* temp = mupdf::ppdf_dict_put_array(this->m_internal, key.m_internal, initial);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_put_bool(). */
void PdfObj::dict_put_bool(const PdfObj& key, int x)
{
	return mupdf::ppdf_dict_put_bool(this->m_internal, key.m_internal, x);
}

/* Wrapper for pdf_dict_put_dict(). */
PdfObj PdfObj::dict_put_dict(const PdfObj& key, int initial)
{
	pdf_obj* temp = mupdf::ppdf_dict_put_dict(this->m_internal, key.m_internal, initial);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_put_drop(). */
void PdfObj::dict_put_drop(const PdfObj& key, const PdfObj& val)
{
	return mupdf::ppdf_dict_put_drop(this->m_internal, key.m_internal, val.m_internal);
}

/* Wrapper for pdf_dict_put_int(). */
void PdfObj::dict_put_int(const PdfObj& key, int64_t x)
{
	return mupdf::ppdf_dict_put_int(this->m_internal, key.m_internal, x);
}

/* Wrapper for pdf_dict_put_matrix(). */
void PdfObj::dict_put_matrix(const PdfObj& key, Matrix& x)
{
	return mupdf::ppdf_dict_put_matrix(this->m_internal, key.m_internal, *(fz_matrix*) &x.a);
}

/* Wrapper for pdf_dict_put_name(). */
void PdfObj::dict_put_name(const PdfObj& key, const char *x)
{
	return mupdf::ppdf_dict_put_name(this->m_internal, key.m_internal, x);
}

/* Wrapper for pdf_dict_put_real(). */
void PdfObj::dict_put_real(const PdfObj& key, double x)
{
	return mupdf::ppdf_dict_put_real(this->m_internal, key.m_internal, x);
}

/* Wrapper for pdf_dict_put_rect(). */
void PdfObj::dict_put_rect(const PdfObj& key, Rect& x)
{
	return mupdf::ppdf_dict_put_rect(this->m_internal, key.m_internal, *(fz_rect*) &x.x0);
}

/* Wrapper for pdf_dict_put_string(). */
void PdfObj::dict_put_string(const PdfObj& key, const char *x, size_t n)
{
	return mupdf::ppdf_dict_put_string(this->m_internal, key.m_internal, x, n);
}

/* Wrapper for pdf_dict_put_text_string(). */
void PdfObj::dict_put_text_string(const PdfObj& key, const char *x)
{
	return mupdf::ppdf_dict_put_text_string(this->m_internal, key.m_internal, x);
}

/* Wrapper for pdf_dict_put_val_null(). */
void PdfObj::dict_put_val_null(int idx)
{
	return mupdf::ppdf_dict_put_val_null(this->m_internal, idx);
}

/* Wrapper for pdf_dict_putp(). */
void PdfObj::dict_putp(const char *path, const PdfObj& val)
{
	return mupdf::ppdf_dict_putp(this->m_internal, path, val.m_internal);
}

/* Wrapper for pdf_dict_putp_drop(). */
void PdfObj::dict_putp_drop(const char *path, const PdfObj& val)
{
	return mupdf::ppdf_dict_putp_drop(this->m_internal, path, val.m_internal);
}

/* Wrapper for pdf_dict_puts(). */
void PdfObj::dict_puts(const char *key, const PdfObj& val)
{
	return mupdf::ppdf_dict_puts(this->m_internal, key, val.m_internal);
}

/* Wrapper for pdf_dict_puts_dict(). */
PdfObj PdfObj::dict_puts_dict(const char *key, int initial)
{
	pdf_obj* temp = mupdf::ppdf_dict_puts_dict(this->m_internal, key, initial);
	return PdfObj(temp);
}

/* Wrapper for pdf_dict_puts_drop(). */
void PdfObj::dict_puts_drop(const char *key, const PdfObj& val)
{
	return mupdf::ppdf_dict_puts_drop(this->m_internal, key, val.m_internal);
}

/* Wrapper for pdf_dirty_obj(). */
void PdfObj::dirty_obj()
{
	return mupdf::ppdf_dirty_obj(this->m_internal);
}

/* Wrapper for pdf_embedded_file_name(). */
const char *PdfObj::embedded_file_name()
{
	return mupdf::ppdf_embedded_file_name(this->m_internal);
}

/* Wrapper for pdf_embedded_file_stream(). */
PdfObj PdfObj::embedded_file_stream()
{
	pdf_obj* temp = mupdf::ppdf_embedded_file_stream(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_embedded_file_type(). */
const char *PdfObj::embedded_file_type()
{
	return mupdf::ppdf_embedded_file_type(this->m_internal);
}

/* Wrapper for pdf_field_border_style(). */
char *PdfObj::field_border_style()
{
	return mupdf::ppdf_field_border_style(this->m_internal);
}

/* Wrapper for pdf_field_display(). */
int PdfObj::field_display()
{
	return mupdf::ppdf_field_display(this->m_internal);
}

/* Wrapper for pdf_field_flags(). */
int PdfObj::field_flags()
{
	return mupdf::ppdf_field_flags(this->m_internal);
}

/* Wrapper for pdf_field_label(). */
const char *PdfObj::field_label()
{
	return mupdf::ppdf_field_label(this->m_internal);
}

/* Wrapper for pdf_field_name(). */
char *PdfObj::field_name()
{
	return mupdf::ppdf_field_name(this->m_internal);
}

/* Wrapper for pdf_field_set_border_style(). */
void PdfObj::field_set_border_style(const char *text)
{
	return mupdf::ppdf_field_set_border_style(this->m_internal, text);
}

/* Wrapper for pdf_field_set_button_caption(). */
void PdfObj::field_set_button_caption(const char *text)
{
	return mupdf::ppdf_field_set_button_caption(this->m_internal, text);
}

/* Wrapper for pdf_field_set_display(). */
void PdfObj::field_set_display(int d)
{
	return mupdf::ppdf_field_set_display(this->m_internal, d);
}

/* Wrapper for pdf_field_set_fill_color(). */
void PdfObj::field_set_fill_color(const PdfObj& col)
{
	return mupdf::ppdf_field_set_fill_color(this->m_internal, col.m_internal);
}

/* Wrapper for pdf_field_set_text_color(). */
void PdfObj::field_set_text_color(const PdfObj& col)
{
	return mupdf::ppdf_field_set_text_color(this->m_internal, col.m_internal);
}

/* Wrapper for pdf_field_type(). */
int PdfObj::field_type()
{
	return mupdf::ppdf_field_type(this->m_internal);
}

/* Wrapper for pdf_field_value(). */
const char *PdfObj::field_value()
{
	return mupdf::ppdf_field_value(this->m_internal);
}

/* Wrapper for pdf_filter_xobject_instance(). */
PdfObj PdfObj::filter_xobject_instance(const PdfObj& page_res, Matrix& ctm, const PdfFilterOptions& filter)
{
	pdf_obj* temp = mupdf::ppdf_filter_xobject_instance(this->m_internal, page_res.m_internal, *(fz_matrix*) &ctm.a, filter.m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_flatten_inheritable_page_items(). */
void PdfObj::flatten_inheritable_page_items()
{
	return mupdf::ppdf_flatten_inheritable_page_items(this->m_internal);
}

/* Wrapper for pdf_get_bound_document(). */
PdfDocument PdfObj::get_bound_document()
{
	pdf_document* temp = mupdf::ppdf_get_bound_document(this->m_internal);
	return PdfDocument(temp);
}

/* Wrapper for pdf_get_indirect_document(). */
PdfDocument PdfObj::get_indirect_document()
{
	pdf_document* temp = mupdf::ppdf_get_indirect_document(this->m_internal);
	return PdfDocument(temp);
}

/* Wrapper for pdf_is_array(). */
int PdfObj::is_array()
{
	return mupdf::ppdf_is_array(this->m_internal);
}

/* Wrapper for pdf_is_bool(). */
int PdfObj::is_bool()
{
	return mupdf::ppdf_is_bool(this->m_internal);
}

/* Wrapper for pdf_is_dict(). */
int PdfObj::is_dict()
{
	return mupdf::ppdf_is_dict(this->m_internal);
}

/* Wrapper for pdf_is_embedded_file(). */
int PdfObj::is_embedded_file()
{
	return mupdf::ppdf_is_embedded_file(this->m_internal);
}

/* Wrapper for pdf_is_indirect(). */
int PdfObj::is_indirect()
{
	return mupdf::ppdf_is_indirect(this->m_internal);
}

/* Wrapper for pdf_is_int(). */
int PdfObj::is_int()
{
	return mupdf::ppdf_is_int(this->m_internal);
}

/* Wrapper for pdf_is_jpx_image(). */
int PdfObj::is_jpx_image()
{
	return mupdf::ppdf_is_jpx_image(this->m_internal);
}

/* Wrapper for pdf_is_name(). */
int PdfObj::is_name()
{
	return mupdf::ppdf_is_name(this->m_internal);
}

/* Wrapper for pdf_is_null(). */
int PdfObj::is_null()
{
	return mupdf::ppdf_is_null(this->m_internal);
}

/* Wrapper for pdf_is_number(). */
int PdfObj::is_number()
{
	return mupdf::ppdf_is_number(this->m_internal);
}

/* Wrapper for pdf_is_real(). */
int PdfObj::is_real()
{
	return mupdf::ppdf_is_real(this->m_internal);
}

/* Wrapper for pdf_is_stream(). */
int PdfObj::is_stream()
{
	return mupdf::ppdf_is_stream(this->m_internal);
}

/* Wrapper for pdf_is_string(). */
int PdfObj::is_string()
{
	return mupdf::ppdf_is_string(this->m_internal);
}

/* Wrapper for pdf_line_ending_from_name(). */
enum pdf_line_ending PdfObj::line_ending_from_name()
{
	return mupdf::ppdf_line_ending_from_name(this->m_internal);
}

/* Wrapper for pdf_load_colorspace(). */
Colorspace PdfObj::load_colorspace()
{
	fz_colorspace* temp = mupdf::ppdf_load_colorspace(this->m_internal);
	return Colorspace(temp);
}

/* Wrapper for pdf_load_embedded_file(). */
Buffer PdfObj::load_embedded_file()
{
	fz_buffer* temp = mupdf::ppdf_load_embedded_file(this->m_internal);
	return Buffer(temp);
}

/* Wrapper for pdf_load_function(). */
PdfFunction PdfObj::load_function(int in, int out)
{
	pdf_function* temp = mupdf::ppdf_load_function(this->m_internal, in, out);
	return PdfFunction(temp);
}

/* Wrapper for pdf_load_raw_stream(). */
Buffer PdfObj::load_raw_stream()
{
	fz_buffer* temp = mupdf::ppdf_load_raw_stream(this->m_internal);
	return Buffer(temp);
}

/* Wrapper for pdf_load_stream(). */
Buffer PdfObj::load_stream()
{
	fz_buffer* temp = mupdf::ppdf_load_stream(this->m_internal);
	return Buffer(temp);
}

/* Wrapper for pdf_load_stream_or_string_as_utf8(). */
char *PdfObj::load_stream_or_string_as_utf8()
{
	return mupdf::ppdf_load_stream_or_string_as_utf8(this->m_internal);
}

/* Wrapper for pdf_lookup_field(). */
PdfObj PdfObj::lookup_field(const char *name)
{
	pdf_obj* temp = mupdf::ppdf_lookup_field(this->m_internal, name);
	return PdfObj(temp);
}

/* Wrapper for pdf_lookup_number(). */
PdfObj PdfObj::lookup_number(int needle)
{
	pdf_obj* temp = mupdf::ppdf_lookup_number(this->m_internal, needle);
	return PdfObj(temp);
}

/* Wrapper for pdf_mark_obj(). */
int PdfObj::mark_obj()
{
	return mupdf::ppdf_mark_obj(this->m_internal);
}

/* Wrapper for pdf_name_eq(). */
int PdfObj::name_eq(const PdfObj& b)
{
	return mupdf::ppdf_name_eq(this->m_internal, b.m_internal);
}

/* Wrapper for pdf_new_crypt(). */
PdfCrypt PdfObj::new_crypt(const PdfObj& id)
{
	pdf_crypt* temp = mupdf::ppdf_new_crypt(this->m_internal, id.m_internal);
	return PdfCrypt(temp);
}

/* Wrapper for pdf_new_utf8_from_pdf_stream_obj(). */
char *PdfObj::new_utf8_from_pdf_stream_obj()
{
	return mupdf::ppdf_new_utf8_from_pdf_stream_obj(this->m_internal);
}

/* Wrapper for pdf_new_utf8_from_pdf_string_obj(). */
char *PdfObj::new_utf8_from_pdf_string_obj()
{
	return mupdf::ppdf_new_utf8_from_pdf_string_obj(this->m_internal);
}

/* Wrapper for pdf_obj_is_dirty(). */
int PdfObj::obj_is_dirty()
{
	return mupdf::ppdf_obj_is_dirty(this->m_internal);
}

/* Wrapper for pdf_obj_marked(). */
int PdfObj::obj_marked()
{
	return mupdf::ppdf_obj_marked(this->m_internal);
}

/* Wrapper for pdf_obj_memo(). */
int PdfObj::obj_memo(int bit, int *memo)
{
	return mupdf::ppdf_obj_memo(this->m_internal, bit, memo);
}

/* Wrapper for pdf_obj_parent_num(). */
int PdfObj::obj_parent_num()
{
	return mupdf::ppdf_obj_parent_num(this->m_internal);
}

/* Wrapper for pdf_obj_refs(). */
int PdfObj::obj_refs()
{
	return mupdf::ppdf_obj_refs(this->m_internal);
}

/* Wrapper for pdf_objcmp(). */
int PdfObj::objcmp(const PdfObj& b)
{
	return mupdf::ppdf_objcmp(this->m_internal, b.m_internal);
}

/* Wrapper for pdf_objcmp_resolve(). */
int PdfObj::objcmp_resolve(const PdfObj& b)
{
	return mupdf::ppdf_objcmp_resolve(this->m_internal, b.m_internal);
}

/* Wrapper for pdf_open_raw_stream(). */
Stream PdfObj::open_raw_stream()
{
	fz_stream* temp = mupdf::ppdf_open_raw_stream(this->m_internal);
	return Stream(temp);
}

/* Wrapper for pdf_open_stream(). */
Stream PdfObj::open_stream()
{
	fz_stream* temp = mupdf::ppdf_open_stream(this->m_internal);
	return Stream(temp);
}

/* Wrapper for pdf_page_obj_transform(). */
void PdfObj::page_obj_transform(Rect& page_mediabox, Matrix& page_ctm)
{
	return mupdf::ppdf_page_obj_transform(this->m_internal, (fz_rect *) &page_mediabox.x0, (fz_matrix *) &page_ctm.a);
}

/* Wrapper for pdf_resolve_indirect(). */
PdfObj PdfObj::resolve_indirect()
{
	pdf_obj* temp = mupdf::ppdf_resolve_indirect(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_resolve_indirect_chain(). */
PdfObj PdfObj::resolve_indirect_chain()
{
	pdf_obj* temp = mupdf::ppdf_resolve_indirect_chain(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_set_int(). */
void PdfObj::set_int(int64_t i)
{
	return mupdf::ppdf_set_int(this->m_internal, i);
}

/* Wrapper for pdf_set_obj_memo(). */
void PdfObj::set_obj_memo(int bit, int memo)
{
	return mupdf::ppdf_set_obj_memo(this->m_internal, bit, memo);
}

/* Wrapper for pdf_set_obj_parent(). */
void PdfObj::set_obj_parent(int num)
{
	return mupdf::ppdf_set_obj_parent(this->m_internal, num);
}

/* Wrapper for pdf_set_str_len(). */
void PdfObj::set_str_len(size_t newlen)
{
	return mupdf::ppdf_set_str_len(this->m_internal, newlen);
}

/* Wrapper for pdf_sort_dict(). */
void PdfObj::sort_dict()
{
	return mupdf::ppdf_sort_dict(this->m_internal);
}

/* Wrapper for pdf_store_item(). */
void PdfObj::store_item(void *val, size_t itemsize)
{
	return mupdf::ppdf_store_item(this->m_internal, val, itemsize);
}

/* Wrapper for pdf_to_bool(). */
int PdfObj::to_bool()
{
	return mupdf::ppdf_to_bool(this->m_internal);
}

/* Wrapper for pdf_to_gen(). */
int PdfObj::to_gen()
{
	return mupdf::ppdf_to_gen(this->m_internal);
}

/* Wrapper for pdf_to_int(). */
int PdfObj::to_int()
{
	return mupdf::ppdf_to_int(this->m_internal);
}

/* Wrapper for pdf_to_int64(). */
int64_t PdfObj::to_int64()
{
	return mupdf::ppdf_to_int64(this->m_internal);
}

/* Wrapper for pdf_to_matrix(). */
Matrix PdfObj::to_matrix()
{
	fz_matrix temp = mupdf::ppdf_to_matrix(this->m_internal);
	return Matrix(&temp);
}

/* Wrapper for pdf_to_name(). */
const char *PdfObj::to_name()
{
	return mupdf::ppdf_to_name(this->m_internal);
}

/* Wrapper for pdf_to_num(). */
int PdfObj::to_num()
{
	return mupdf::ppdf_to_num(this->m_internal);
}

/* Wrapper for pdf_to_quad(). */
Quad PdfObj::to_quad(int offset)
{
	fz_quad temp = mupdf::ppdf_to_quad(this->m_internal, offset);
	return Quad(&temp);
}

/* Wrapper for pdf_to_real(). */
float PdfObj::to_real()
{
	return mupdf::ppdf_to_real(this->m_internal);
}

/* Wrapper for pdf_to_rect(). */
Rect PdfObj::to_rect()
{
	fz_rect temp = mupdf::ppdf_to_rect(this->m_internal);
	return Rect(&temp);
}

/* Wrapper for pdf_to_str_buf(). */
char *PdfObj::to_str_buf()
{
	return mupdf::ppdf_to_str_buf(this->m_internal);
}

/* Wrapper for pdf_to_str_len(). */
size_t PdfObj::to_str_len()
{
	return mupdf::ppdf_to_str_len(this->m_internal);
}

/* Wrapper for pdf_to_string(). */
const char *PdfObj::to_string(size_t *sizep)
{
	return mupdf::ppdf_to_string(this->m_internal, sizep);
}

/* Wrapper for pdf_to_text_string(). */
const char *PdfObj::to_text_string()
{
	return mupdf::ppdf_to_text_string(this->m_internal);
}

/* Wrapper for pdf_unmark_obj(). */
void PdfObj::unmark_obj()
{
	return mupdf::ppdf_unmark_obj(this->m_internal);
}

/* Wrapper for pdf_walk_tree(). */
void PdfObj::walk_tree(const PdfObj& kid_name, void (*arrive)(fz_context *, pdf_obj *, void *, pdf_obj **), void (*leave)(fz_context *, pdf_obj *, void *), void *arg, PdfObj& names, PdfObj& values)
{
	return mupdf::ppdf_walk_tree(this->m_internal, kid_name.m_internal, arrive, leave, arg, &names.m_internal, &values.m_internal);
}

/* Wrapper for pdf_xobject_bbox(). */
Rect PdfObj::xobject_bbox()
{
	fz_rect temp = mupdf::ppdf_xobject_bbox(this->m_internal);
	return Rect(&temp);
}

/* Wrapper for pdf_xobject_colorspace(). */
Colorspace PdfObj::xobject_colorspace()
{
	fz_colorspace* temp = mupdf::ppdf_xobject_colorspace(this->m_internal);
	return Colorspace(temp);
}

/* Wrapper for pdf_xobject_isolated(). */
int PdfObj::xobject_isolated()
{
	return mupdf::ppdf_xobject_isolated(this->m_internal);
}

/* Wrapper for pdf_xobject_knockout(). */
int PdfObj::xobject_knockout()
{
	return mupdf::ppdf_xobject_knockout(this->m_internal);
}

/* Wrapper for pdf_xobject_matrix(). */
Matrix PdfObj::xobject_matrix()
{
	fz_matrix temp = mupdf::ppdf_xobject_matrix(this->m_internal);
	return Matrix(&temp);
}

/* Wrapper for pdf_xobject_resources(). */
PdfObj PdfObj::xobject_resources()
{
	pdf_obj* temp = mupdf::ppdf_xobject_resources(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_xobject_transparency(). */
int PdfObj::xobject_transparency()
{
	return mupdf::ppdf_xobject_transparency(this->m_internal);
}

PdfObj::PdfObj(pdf_obj* internal)
: m_internal(internal)
{
}

PdfObj::~PdfObj()
{
	mupdf::ppdf_drop_obj(m_internal);
}

/* Implementation of PdfOcgDescriptor (wrapper for pdf_ocg_descriptor). */

/* Wrapper for pdf_is_hidden_ocg(). */
int PdfOcgDescriptor::is_hidden_ocg(const PdfObj& rdb, const char *usage, const PdfObj& ocg)
{
	return mupdf::ppdf_is_hidden_ocg(this->m_internal, rdb.m_internal, usage, ocg.m_internal);
}

PdfOcgDescriptor::PdfOcgDescriptor(pdf_ocg_descriptor* internal)
: m_internal(internal)
{
}

/* Implementation of PdfPage (wrapper for pdf_page). */

/* Wrapper for pdf_bound_page(). */
Rect PdfPage::bound_page()
{
	fz_rect temp = mupdf::ppdf_bound_page(this->m_internal);
	return Rect(&temp);
}

/* Wrapper for pdf_create_annot(). */
PdfAnnot PdfPage::create_annot(enum pdf_annot_type type)
{
	pdf_annot* temp = mupdf::ppdf_create_annot(this->m_internal, type);
	return PdfAnnot(temp);
}

/* Wrapper for pdf_create_annot_raw(). */
PdfAnnot PdfPage::create_annot_raw(enum pdf_annot_type type)
{
	pdf_annot* temp = mupdf::ppdf_create_annot_raw(this->m_internal, type);
	return PdfAnnot(temp);
}

/* Wrapper for pdf_delete_annot(). */
void PdfPage::delete_annot(const PdfAnnot& annot)
{
	return mupdf::ppdf_delete_annot(this->m_internal, annot.m_internal);
}

/* Wrapper for pdf_first_annot(). */
PdfAnnot PdfPage::first_annot()
{
	pdf_annot* temp = mupdf::ppdf_first_annot(this->m_internal);
	return PdfAnnot(temp);
}

/* Wrapper for pdf_first_widget(). */
PdfAnnot PdfPage::first_widget()
{
	pdf_annot* temp = mupdf::ppdf_first_widget(this->m_internal);
	return PdfAnnot(temp);
}

/* Wrapper for pdf_load_annots(). */
void PdfPage::load_annots(const PdfObj& annots)
{
	return mupdf::ppdf_load_annots(this->m_internal, annots.m_internal);
}

/* Wrapper for pdf_load_links(). */
Link PdfPage::load_links()
{
	fz_link* temp = mupdf::ppdf_load_links(this->m_internal);
	return Link(temp);
}

/* Wrapper for pdf_page_contents(). */
PdfObj PdfPage::page_contents()
{
	pdf_obj* temp = mupdf::ppdf_page_contents(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_page_event_close(). */
void PdfPage::page_event_close()
{
	return mupdf::ppdf_page_event_close(this->m_internal);
}

/* Wrapper for pdf_page_event_open(). */
void PdfPage::page_event_open()
{
	return mupdf::ppdf_page_event_open(this->m_internal);
}

/* Wrapper for pdf_page_group(). */
PdfObj PdfPage::page_group()
{
	pdf_obj* temp = mupdf::ppdf_page_group(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_page_presentation(). */
Transition PdfPage::page_presentation(Transition& transition, float *duration)
{
	fz_transition* temp = mupdf::ppdf_page_presentation(this->m_internal, (fz_transition *) &transition.type, duration);
	return Transition(temp);
}

/* Wrapper for pdf_page_resources(). */
PdfObj PdfPage::page_resources()
{
	pdf_obj* temp = mupdf::ppdf_page_resources(this->m_internal);
	return PdfObj(temp);
}

/* Wrapper for pdf_page_separations(). */
Separations PdfPage::page_separations()
{
	fz_separations* temp = mupdf::ppdf_page_separations(this->m_internal);
	return Separations(temp);
}

/* Wrapper for pdf_page_transform(). */
void PdfPage::page_transform(Rect& mediabox, Matrix& ctm)
{
	return mupdf::ppdf_page_transform(this->m_internal, (fz_rect *) &mediabox.x0, (fz_matrix *) &ctm.a);
}

/* Wrapper for pdf_run_page(). */
void PdfPage::run_page(const Device& dev, Matrix& ctm, Cookie& cookie)
{
	return mupdf::ppdf_run_page(this->m_internal, dev.m_internal, *(fz_matrix*) &ctm.a, &cookie.m_internal);
}

/* Wrapper for pdf_run_page_annots(). */
void PdfPage::run_page_annots(const Device& dev, Matrix& ctm, Cookie& cookie)
{
	return mupdf::ppdf_run_page_annots(this->m_internal, dev.m_internal, *(fz_matrix*) &ctm.a, &cookie.m_internal);
}

/* Wrapper for pdf_run_page_contents(). */
void PdfPage::run_page_contents(const Device& dev, Matrix& ctm, Cookie& cookie)
{
	return mupdf::ppdf_run_page_contents(this->m_internal, dev.m_internal, *(fz_matrix*) &ctm.a, &cookie.m_internal);
}

/* Wrapper for pdf_run_page_widgets(). */
void PdfPage::run_page_widgets(const Device& dev, Matrix& ctm, Cookie& cookie)
{
	return mupdf::ppdf_run_page_widgets(this->m_internal, dev.m_internal, *(fz_matrix*) &ctm.a, &cookie.m_internal);
}

/* Wrapper for pdf_update_page(). */
int PdfPage::update_page()
{
	return mupdf::ppdf_update_page(this->m_internal);
}

PdfPage::PdfPage(pdf_page* internal)
: m_internal(internal)
{
}

/* Implementation of PdfPattern (wrapper for pdf_pattern). */

/* Copy constructor using pdf_keep_pattern(). */
PdfPattern::PdfPattern(const PdfPattern& rhs)
: m_internal(mupdf::ppdf_keep_pattern(rhs.m_internal))
{
}

/* operator= using pdf_keep_pattern() and pdf_drop_pattern(). */
PdfPattern& PdfPattern::operator=(const PdfPattern& rhs)
{
	mupdf::ppdf_drop_pattern(this->m_internal);
	mupdf::ppdf_keep_pattern(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

PdfPattern::PdfPattern(pdf_pattern* internal)
: m_internal(internal)
{
}

PdfPattern::~PdfPattern()
{
	mupdf::ppdf_drop_pattern(m_internal);
}

/* Implementation of PdfPkcs7DesignatedName (wrapper for pdf_pkcs7_designated_name). */

/* Wrapper for pdf_signature_drop_designated_name(). */
void PdfPkcs7DesignatedName::signature_drop_designated_name()
{
	return mupdf::ppdf_signature_drop_designated_name(this->m_internal);
}

/* Wrapper for pdf_signature_format_designated_name(). */
char *PdfPkcs7DesignatedName::signature_format_designated_name()
{
	return mupdf::ppdf_signature_format_designated_name(this->m_internal);
}

PdfPkcs7DesignatedName::PdfPkcs7DesignatedName(pdf_pkcs7_designated_name* internal)
: m_internal(internal)
{
}

/* Implementation of PdfPkcs7Signer (wrapper for pdf_pkcs7_signer). */

PdfPkcs7Signer::PdfPkcs7Signer(pdf_pkcs7_signer* internal)
: m_internal(internal)
{
}

/* Implementation of PdfPkcs7Verifier (wrapper for pdf_pkcs7_verifier). */

/* Wrapper for pdf_check_certificate(). */
pdf_signature_error PdfPkcs7Verifier::check_certificate(const PdfDocument& doc, const PdfObj& signature)
{
	return mupdf::ppdf_check_certificate(this->m_internal, doc.m_internal, signature.m_internal);
}

/* Wrapper for pdf_check_digest(). */
pdf_signature_error PdfPkcs7Verifier::check_digest(const PdfDocument& doc, const PdfObj& signature)
{
	return mupdf::ppdf_check_digest(this->m_internal, doc.m_internal, signature.m_internal);
}

/* Wrapper for pdf_check_signature(). */
int PdfPkcs7Verifier::check_signature(const PdfDocument& doc, const PdfObj& signature, char *ebuf, size_t ebufsize)
{
	return mupdf::ppdf_check_signature(this->m_internal, doc.m_internal, signature.m_internal, ebuf, ebufsize);
}

/* Wrapper for pdf_signature_get_signatory(). */
PdfPkcs7DesignatedName PdfPkcs7Verifier::signature_get_signatory(const PdfDocument& doc, const PdfObj& signature)
{
	pdf_pkcs7_designated_name* temp = mupdf::ppdf_signature_get_signatory(this->m_internal, doc.m_internal, signature.m_internal);
	return PdfPkcs7DesignatedName(temp);
}

PdfPkcs7Verifier::PdfPkcs7Verifier(pdf_pkcs7_verifier* internal)
: m_internal(internal)
{
}

/* Implementation of PdfProcessor (wrapper for pdf_processor). */

/* Constructor using pdf_new_buffer_processor(). */
PdfProcessor::PdfProcessor(const Buffer& buffer, int ahxencode)
{
	this->m_internal = mupdf::ppdf_new_buffer_processor(buffer.m_internal, ahxencode);
}

/* Constructor using pdf_new_filter_processor(). */
PdfProcessor::PdfProcessor(const PdfDocument& doc, const PdfProcessor& chain, const PdfObj& old_res, const PdfObj& new_res, int struct_parents, Matrix& transform, const PdfFilterOptions& filter)
{
	this->m_internal = mupdf::ppdf_new_filter_processor(doc.m_internal, chain.m_internal, old_res.m_internal, new_res.m_internal, struct_parents, *(fz_matrix*) &transform.a, filter.m_internal);
}

/* Constructor using pdf_new_output_processor(). */
PdfProcessor::PdfProcessor(const Output& out, int ahxencode)
{
	this->m_internal = mupdf::ppdf_new_output_processor(out.m_internal, ahxencode);
}

/* Constructor using pdf_new_run_processor(). */
PdfProcessor::PdfProcessor(const Device& dev, Matrix& ctm, const char *usage, const PdfGstate& gstate, const DefaultColorspaces& default_cs, Cookie& cookie)
{
	this->m_internal = mupdf::ppdf_new_run_processor(dev.m_internal, *(fz_matrix*) &ctm.a, usage, gstate.m_internal, default_cs.m_internal, &cookie.m_internal);
}

/* Wrapper for pdf_close_processor(). */
void PdfProcessor::close_processor()
{
	return mupdf::ppdf_close_processor(this->m_internal);
}

/* Wrapper for pdf_process_annot(). */
void PdfProcessor::process_annot(const PdfDocument& doc, const PdfPage& page, const PdfAnnot& annot, Cookie& cookie)
{
	return mupdf::ppdf_process_annot(this->m_internal, doc.m_internal, page.m_internal, annot.m_internal, &cookie.m_internal);
}

/* Wrapper for pdf_process_contents(). */
void PdfProcessor::process_contents(const PdfDocument& doc, const PdfObj& obj, const PdfObj& res, Cookie& cookie)
{
	return mupdf::ppdf_process_contents(this->m_internal, doc.m_internal, obj.m_internal, res.m_internal, &cookie.m_internal);
}

/* Wrapper for pdf_process_glyph(). */
void PdfProcessor::process_glyph(const PdfDocument& doc, const PdfObj& resources, const Buffer& contents)
{
	return mupdf::ppdf_process_glyph(this->m_internal, doc.m_internal, resources.m_internal, contents.m_internal);
}

PdfProcessor::PdfProcessor(pdf_processor* internal)
: m_internal(internal)
{
}

PdfProcessor::~PdfProcessor()
{
	mupdf::ppdf_drop_processor(m_internal);
}

/* Implementation of PdfRange (wrapper for pdf_range). */

PdfRange::PdfRange(pdf_range* internal)
: m_internal(internal)
{
}

/* Implementation of PdfRedactOptions (wrapper for pdf_redact_options). */

PdfRedactOptions::PdfRedactOptions(pdf_redact_options* internal)
: m_internal(internal)
{
}

/* Implementation of PdfRevPageMap (wrapper for pdf_rev_page_map). */

PdfRevPageMap::PdfRevPageMap(pdf_rev_page_map* internal)
: m_internal(internal)
{
}

/* Implementation of PdfTextObjectState (wrapper for pdf_text_object_state). */

/* Wrapper for pdf_tos_get_text(). */
Text PdfTextObjectState::tos_get_text()
{
	fz_text* temp = mupdf::ppdf_tos_get_text(this->m_internal);
	return Text(temp);
}

/* Wrapper for pdf_tos_make_trm(). */
int PdfTextObjectState::tos_make_trm(const PdfTextState& text, const PdfFontDesc& fontdesc, int cid, Matrix& trm)
{
	return mupdf::ppdf_tos_make_trm(this->m_internal, text.m_internal, fontdesc.m_internal, cid, (fz_matrix *) &trm.a);
}

/* Wrapper for pdf_tos_move_after_char(). */
void PdfTextObjectState::tos_move_after_char()
{
	return mupdf::ppdf_tos_move_after_char(this->m_internal);
}

/* Wrapper for pdf_tos_newline(). */
void PdfTextObjectState::tos_newline(float leading)
{
	return mupdf::ppdf_tos_newline(this->m_internal, leading);
}

/* Wrapper for pdf_tos_reset(). */
void PdfTextObjectState::tos_reset(int render)
{
	return mupdf::ppdf_tos_reset(this->m_internal, render);
}

/* Wrapper for pdf_tos_set_matrix(). */
void PdfTextObjectState::tos_set_matrix(float a, float b, float c, float d, float e, float f)
{
	return mupdf::ppdf_tos_set_matrix(this->m_internal, a, b, c, d, e, f);
}

/* Wrapper for pdf_tos_translate(). */
void PdfTextObjectState::tos_translate(float tx, float ty)
{
	return mupdf::ppdf_tos_translate(this->m_internal, tx, ty);
}

PdfTextObjectState::PdfTextObjectState(pdf_text_object_state* internal)
: m_internal(internal)
{
}

/* Implementation of PdfTextState (wrapper for pdf_text_state). */

PdfTextState::PdfTextState(pdf_text_state* internal)
: m_internal(internal)
{
}

/* Implementation of PdfUnsavedSig (wrapper for pdf_unsaved_sig). */

PdfUnsavedSig::PdfUnsavedSig(pdf_unsaved_sig* internal)
: m_internal(internal)
{
}

/* Implementation of PdfVmtx (wrapper for pdf_vmtx). */

PdfVmtx::PdfVmtx(pdf_vmtx* internal)
: m_internal(internal)
{
}

/* Implementation of PdfWriteOptions (wrapper for pdf_write_options). */

/* Custom constructor. */
PdfWriteOptions::PdfWriteOptions()
{
	/* Use memcpy() otherwise we get 'invalid array assignment' errors. */
	memcpy(this->internal(), &pdf_default_write_options, sizeof(*this->internal()));
}

/* Custom constructor. */
PdfWriteOptions::PdfWriteOptions(const PdfWriteOptions& rhs)
{
	/* Use memcpy() otherwise we get 'invalid array assignment' errors. */
	*this = rhs;
}

/* Wrapper for pdf_parse_write_options(). */
PdfWriteOptions PdfWriteOptions::parse_write_options(const char *args)
{
	pdf_write_options* temp = mupdf::ppdf_parse_write_options((pdf_write_options *) &this->do_incremental, args);
	return PdfWriteOptions(temp);
}

/* Custom method. */
PdfWriteOptions& PdfWriteOptions::operator=(const PdfWriteOptions& rhs)
{
	memcpy(this->internal(), rhs.internal(), sizeof(*this->internal()));
	return *this;
}

PdfWriteOptions::PdfWriteOptions(const pdf_write_options* internal)
{
	this->do_incremental = internal->do_incremental;
	this->do_pretty = internal->do_pretty;
	this->do_ascii = internal->do_ascii;
	this->do_compress = internal->do_compress;
	this->do_compress_images = internal->do_compress_images;
	this->do_compress_fonts = internal->do_compress_fonts;
	this->do_decompress = internal->do_decompress;
	this->do_garbage = internal->do_garbage;
	this->do_linear = internal->do_linear;
	this->do_clean = internal->do_clean;
	this->do_sanitize = internal->do_sanitize;
	this->do_appearance = internal->do_appearance;
	this->do_encrypt = internal->do_encrypt;
	this->permissions = internal->permissions;
	memcpy(this->opwd_utf8, internal->opwd_utf8, sizeof(this->opwd_utf8));
	memcpy(this->upwd_utf8, internal->upwd_utf8, sizeof(this->upwd_utf8));
}

PdfWriteOptions::PdfWriteOptions(const pdf_write_options internal)
{
	this->do_incremental = internal.do_incremental;
	this->do_pretty = internal.do_pretty;
	this->do_ascii = internal.do_ascii;
	this->do_compress = internal.do_compress;
	this->do_compress_images = internal.do_compress_images;
	this->do_compress_fonts = internal.do_compress_fonts;
	this->do_decompress = internal.do_decompress;
	this->do_garbage = internal.do_garbage;
	this->do_linear = internal.do_linear;
	this->do_clean = internal.do_clean;
	this->do_sanitize = internal.do_sanitize;
	this->do_appearance = internal.do_appearance;
	this->do_encrypt = internal.do_encrypt;
	this->permissions = internal.permissions;
	memcpy(this->opwd_utf8, &internal.opwd_utf8, sizeof(this->opwd_utf8));
	memcpy(this->upwd_utf8, &internal.upwd_utf8, sizeof(this->upwd_utf8));
}

/* Constructor using raw copy of pre-existing pdf_write_options. */
pdf_write_options* PdfWriteOptions::internal()
{
	return (pdf_write_options*) &this->do_incremental;
}

/* Constructor using raw copy of pre-existing pdf_write_options. */
const pdf_write_options* PdfWriteOptions::internal() const
{
	return (const pdf_write_options*) &this->do_incremental;
}

/* Implementation of PdfXfa (wrapper for pdf_xfa). */

PdfXfa::PdfXfa(pdf_xfa* internal)
: m_internal(internal)
{
}

/* Implementation of PdfXfaEntry (wrapper for pdf_xfa_entry). */

PdfXfaEntry::PdfXfaEntry(pdf_xfa_entry* internal)
: m_internal(internal)
{
}

/* Implementation of PdfXrange (wrapper for pdf_xrange). */

PdfXrange::PdfXrange(pdf_xrange* internal)
: m_internal(internal)
{
}

/* Implementation of PdfXref (wrapper for pdf_xref). */

PdfXref::PdfXref(pdf_xref* internal)
: m_internal(internal)
{
}

/* Implementation of PdfXrefEntry (wrapper for pdf_xref_entry). */

PdfXrefEntry::PdfXrefEntry(pdf_xref_entry* internal)
: m_internal(internal)
{
}

/* Implementation of PdfXrefSubsec (wrapper for pdf_xref_subsec). */

PdfXrefSubsec::PdfXrefSubsec(pdf_xref_subsec* internal)
: m_internal(internal)
{
}

/* Implementation of Pixmap (wrapper for fz_pixmap). */

/* Constructor using fz_new_pixmap(). */
Pixmap::Pixmap(const Colorspace& cs, int w, int h, const Separations& seps, int alpha)
{
	this->m_internal = mupdf::new_pixmap(cs.m_internal, w, h, seps.m_internal, alpha);
}

/* Constructor using fz_new_pixmap_from_display_list(). */
Pixmap::Pixmap(const DisplayList& list, Matrix& ctm, const Colorspace& cs, int alpha)
{
	this->m_internal = mupdf::new_pixmap_from_display_list(list.m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, alpha);
}

/* Constructor using fz_new_pixmap_from_display_list_with_separations(). */
Pixmap::Pixmap(const DisplayList& list, Matrix& ctm, const Colorspace& cs, const Separations& seps, int alpha)
{
	this->m_internal = mupdf::new_pixmap_from_display_list_with_separations(list.m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, seps.m_internal, alpha);
}

/* Constructor using fz_new_pixmap_from_page(). */
Pixmap::Pixmap(const Page& page, Matrix& ctm, const Colorspace& cs, int alpha)
{
	this->m_internal = mupdf::new_pixmap_from_page(page.m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, alpha);
}

/* Constructor using fz_new_pixmap_from_page_number(). */
Pixmap::Pixmap(const Document& doc, int number, Matrix& ctm, const Colorspace& cs, int alpha)
{
	this->m_internal = mupdf::new_pixmap_from_page_number(doc.m_internal, number, *(fz_matrix*) &ctm.a, cs.m_internal, alpha);
}

/* Constructor using fz_new_pixmap_from_page_number_with_separations(). */
Pixmap::Pixmap(const Document& doc, int number, Matrix& ctm, const Colorspace& cs, const Separations& seps, int alpha)
{
	this->m_internal = mupdf::new_pixmap_from_page_number_with_separations(doc.m_internal, number, *(fz_matrix*) &ctm.a, cs.m_internal, seps.m_internal, alpha);
}

/* Constructor using fz_new_pixmap_from_page_with_separations(). */
Pixmap::Pixmap(const Page& page, Matrix& ctm, const Colorspace& cs, const Separations& seps, int alpha)
{
	this->m_internal = mupdf::new_pixmap_from_page_with_separations(page.m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, seps.m_internal, alpha);
}

/* Constructor using fz_new_pixmap_from_pixmap(). */
Pixmap::Pixmap(const Pixmap& pixmap, Irect& rect)
{
	this->m_internal = mupdf::new_pixmap_from_pixmap(pixmap.m_internal, (const fz_irect *) &rect.x0);
}

/* Constructor using fz_new_pixmap_with_bbox(). */
Pixmap::Pixmap(const Colorspace& colorspace, Irect& bbox, const Separations& seps, int alpha)
{
	this->m_internal = mupdf::new_pixmap_with_bbox(colorspace.m_internal, *(fz_irect*) &bbox.x0, seps.m_internal, alpha);
}

/* Constructor using fz_new_pixmap_with_bbox_and_data(). */
Pixmap::Pixmap(const Colorspace& colorspace, Irect& rect, const Separations& seps, int alpha, unsigned char *samples)
{
	this->m_internal = mupdf::new_pixmap_with_bbox_and_data(colorspace.m_internal, *(fz_irect*) &rect.x0, seps.m_internal, alpha, samples);
}

/* Constructor using fz_new_pixmap_with_data(). */
Pixmap::Pixmap(const Colorspace& colorspace, int w, int h, const Separations& seps, int alpha, int stride, unsigned char *samples)
{
	this->m_internal = mupdf::new_pixmap_with_data(colorspace.m_internal, w, h, seps.m_internal, alpha, stride, samples);
}

/* Copy constructor using fz_keep_pixmap(). */
Pixmap::Pixmap(const Pixmap& rhs)
: m_internal(mupdf::keep_pixmap(rhs.m_internal))
{
}

/* operator= using fz_keep_pixmap() and fz_drop_pixmap(). */
Pixmap& Pixmap::operator=(const Pixmap& rhs)
{
	mupdf::drop_pixmap(this->m_internal);
	mupdf::keep_pixmap(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_new_pixmap_from_page_contents(). */
Pixmap Pixmap::new_pixmap_from_page_contents(const Page& page, Matrix& ctm, const Colorspace& cs, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_page_contents(page.m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_new_pixmap_from_page_contents_with_separations(). */
Pixmap Pixmap::new_pixmap_from_page_contents_with_separations(const Page& page, Matrix& ctm, const Colorspace& cs, const Separations& seps, int alpha)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_page_contents_with_separations(page.m_internal, *(fz_matrix*) &ctm.a, cs.m_internal, seps.m_internal, alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_alpha_from_gray(). */
Pixmap Pixmap::alpha_from_gray()
{
	fz_pixmap* temp = mupdf::alpha_from_gray(this->m_internal);
	return Pixmap(temp);
}

/* Wrapper for fz_clear_pixmap(). */
void Pixmap::clear_pixmap()
{
	return mupdf::clear_pixmap(this->m_internal);
}

/* Wrapper for fz_clear_pixmap_rect_with_value(). */
void Pixmap::clear_pixmap_rect_with_value(int value, Irect& r)
{
	return mupdf::clear_pixmap_rect_with_value(this->m_internal, value, *(fz_irect*) &r.x0);
}

/* Wrapper for fz_clear_pixmap_with_value(). */
void Pixmap::clear_pixmap_with_value(int value)
{
	return mupdf::clear_pixmap_with_value(this->m_internal, value);
}

/* Wrapper for fz_clone_pixmap(). */
Pixmap Pixmap::clone_pixmap()
{
	fz_pixmap* temp = mupdf::clone_pixmap(this->m_internal);
	return Pixmap(temp);
}

/* Wrapper for fz_convert_indexed_pixmap_to_base(). */
Pixmap Pixmap::convert_indexed_pixmap_to_base()
{
	fz_pixmap* temp = mupdf::convert_indexed_pixmap_to_base(this->m_internal);
	return Pixmap(temp);
}

/* Wrapper for fz_convert_pixmap(). */
Pixmap Pixmap::convert_pixmap(const Colorspace& cs_des, const Colorspace& prf, const DefaultColorspaces& default_cs, ColorParams& color_params, int keep_alpha)
{
	fz_pixmap* temp = mupdf::convert_pixmap(this->m_internal, cs_des.m_internal, prf.m_internal, default_cs.m_internal, *(fz_color_params*) &color_params.ri, keep_alpha);
	return Pixmap(temp);
}

/* Wrapper for fz_convert_separation_pixmap_to_base(). */
Pixmap Pixmap::convert_separation_pixmap_to_base()
{
	fz_pixmap* temp = mupdf::convert_separation_pixmap_to_base(this->m_internal);
	return Pixmap(temp);
}

/* Wrapper for fz_decode_tile(). */
void Pixmap::decode_tile(const float *decode)
{
	return mupdf::decode_tile(this->m_internal, decode);
}

/* Wrapper for fz_fill_pixmap_with_color(). */
void Pixmap::fill_pixmap_with_color(const Colorspace& colorspace, float *color, ColorParams& color_params)
{
	return mupdf::fill_pixmap_with_color(this->m_internal, colorspace.m_internal, color, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for fz_gamma_pixmap(). */
void Pixmap::gamma_pixmap(float gamma)
{
	return mupdf::gamma_pixmap(this->m_internal, gamma);
}

/* Wrapper for fz_generate_transition(). */
int Pixmap::generate_transition(const Pixmap& opix, const Pixmap& npix, int time, Transition& trans)
{
	return mupdf::generate_transition(this->m_internal, opix.m_internal, npix.m_internal, time, (fz_transition *) &trans.type);
}

/* Wrapper for fz_invert_pixmap(). */
void Pixmap::invert_pixmap()
{
	return mupdf::invert_pixmap(this->m_internal);
}

/* Wrapper for fz_invert_pixmap_luminance(). */
void Pixmap::invert_pixmap_luminance()
{
	return mupdf::invert_pixmap_luminance(this->m_internal);
}

/* Wrapper for fz_invert_pixmap_rect(). */
void Pixmap::invert_pixmap_rect(Irect& rect)
{
	return mupdf::invert_pixmap_rect(this->m_internal, *(fz_irect*) &rect.x0);
}

/* Wrapper for fz_is_pixmap_monochrome(). */
int Pixmap::is_pixmap_monochrome()
{
	return mupdf::is_pixmap_monochrome(this->m_internal);
}

/* Wrapper for fz_new_bitmap_from_pixmap(). */
Bitmap Pixmap::new_bitmap_from_pixmap(const Halftone& ht)
{
	fz_bitmap* temp = mupdf::new_bitmap_from_pixmap(this->m_internal, ht.m_internal);
	return Bitmap(temp);
}

/* Wrapper for fz_new_bitmap_from_pixmap_band(). */
Bitmap Pixmap::new_bitmap_from_pixmap_band(const Halftone& ht, int band_start)
{
	fz_bitmap* temp = mupdf::new_bitmap_from_pixmap_band(this->m_internal, ht.m_internal, band_start);
	return Bitmap(temp);
}

/* Wrapper for fz_new_buffer_from_pixmap_as_png(). */
Buffer Pixmap::new_buffer_from_pixmap_as_png(ColorParams& color_params)
{
	fz_buffer* temp = mupdf::new_buffer_from_pixmap_as_png(this->m_internal, *(fz_color_params*) &color_params.ri);
	return Buffer(temp);
}

/* Wrapper for fz_new_image_from_pixmap(). */
Image Pixmap::new_image_from_pixmap(const Image& mask)
{
	fz_image* temp = mupdf::new_image_from_pixmap(this->m_internal, mask.m_internal);
	return Image(temp);
}

/* Wrapper for fz_new_pixmap_from_pixmap(). */
Pixmap Pixmap::new_pixmap_from_pixmap(Irect& rect)
{
	fz_pixmap* temp = mupdf::new_pixmap_from_pixmap(this->m_internal, (const fz_irect *) &rect.x0);
	return Pixmap(temp);
}

/* Wrapper for fz_pixmap_alpha(). */
int Pixmap::pixmap_alpha()
{
	return mupdf::pixmap_alpha(this->m_internal);
}

/* Wrapper for fz_pixmap_bbox(). */
Irect Pixmap::pixmap_bbox()
{
	fz_irect temp = mupdf::pixmap_bbox(this->m_internal);
	return Irect(&temp);
}

/* Wrapper for fz_pixmap_colorants(). */
int Pixmap::pixmap_colorants()
{
	return mupdf::pixmap_colorants(this->m_internal);
}

/* Wrapper for fz_pixmap_colorspace(). */
Colorspace Pixmap::pixmap_colorspace()
{
	fz_colorspace* temp = mupdf::pixmap_colorspace(this->m_internal);
	return Colorspace(temp);
}

/* Wrapper for fz_pixmap_components(). */
int Pixmap::pixmap_components()
{
	return mupdf::pixmap_components(this->m_internal);
}

/* Wrapper for fz_pixmap_height(). */
int Pixmap::pixmap_height()
{
	return mupdf::pixmap_height(this->m_internal);
}

/* Wrapper for fz_pixmap_samples(). */
unsigned char *Pixmap::pixmap_samples()
{
	return mupdf::pixmap_samples(this->m_internal);
}

/* Wrapper for fz_pixmap_spots(). */
int Pixmap::pixmap_spots()
{
	return mupdf::pixmap_spots(this->m_internal);
}

/* Wrapper for fz_pixmap_stride(). */
int Pixmap::pixmap_stride()
{
	return mupdf::pixmap_stride(this->m_internal);
}

/* Wrapper for fz_pixmap_width(). */
int Pixmap::pixmap_width()
{
	return mupdf::pixmap_width(this->m_internal);
}

/* Wrapper for fz_pixmap_x(). */
int Pixmap::pixmap_x()
{
	return mupdf::pixmap_x(this->m_internal);
}

/* Wrapper for fz_pixmap_y(). */
int Pixmap::pixmap_y()
{
	return mupdf::pixmap_y(this->m_internal);
}

/* Wrapper for fz_save_pixmap_as_pam(). */
void Pixmap::save_pixmap_as_pam(const char *filename)
{
	return mupdf::save_pixmap_as_pam(this->m_internal, filename);
}

/* Wrapper for fz_save_pixmap_as_pbm(). */
void Pixmap::save_pixmap_as_pbm(const char *filename)
{
	return mupdf::save_pixmap_as_pbm(this->m_internal, filename);
}

/* Wrapper for fz_save_pixmap_as_pcl(). */
void Pixmap::save_pixmap_as_pcl(char *filename, int append, const PclOptions& pcl)
{
	return mupdf::save_pixmap_as_pcl(this->m_internal, filename, append, pcl.m_internal);
}

/* Wrapper for fz_save_pixmap_as_pclm(). */
void Pixmap::save_pixmap_as_pclm(char *filename, int append, const PclmOptions& options)
{
	return mupdf::save_pixmap_as_pclm(this->m_internal, filename, append, options.m_internal);
}

/* Wrapper for fz_save_pixmap_as_pkm(). */
void Pixmap::save_pixmap_as_pkm(const char *filename)
{
	return mupdf::save_pixmap_as_pkm(this->m_internal, filename);
}

/* Wrapper for fz_save_pixmap_as_png(). */
void Pixmap::save_pixmap_as_png(const char *filename)
{
	return mupdf::save_pixmap_as_png(this->m_internal, filename);
}

/* Wrapper for fz_save_pixmap_as_pnm(). */
void Pixmap::save_pixmap_as_pnm(const char *filename)
{
	return mupdf::save_pixmap_as_pnm(this->m_internal, filename);
}

/* Wrapper for fz_save_pixmap_as_ps(). */
void Pixmap::save_pixmap_as_ps(char *filename, int append)
{
	return mupdf::save_pixmap_as_ps(this->m_internal, filename, append);
}

/* Wrapper for fz_save_pixmap_as_psd(). */
void Pixmap::save_pixmap_as_psd(const char *filename)
{
	return mupdf::save_pixmap_as_psd(this->m_internal, filename);
}

/* Wrapper for fz_save_pixmap_as_pwg(). */
void Pixmap::save_pixmap_as_pwg(char *filename, int append, PwgOptions& pwg)
{
	return mupdf::save_pixmap_as_pwg(this->m_internal, filename, append, &pwg.m_internal);
}

/* Wrapper for fz_set_pixmap_resolution(). */
void Pixmap::set_pixmap_resolution(int xres, int yres)
{
	return mupdf::set_pixmap_resolution(this->m_internal, xres, yres);
}

/* Wrapper for fz_tint_pixmap(). */
void Pixmap::tint_pixmap(int black, int white)
{
	return mupdf::tint_pixmap(this->m_internal, black, white);
}

/* Custom method. */
std::string Pixmap::md5_pixmap()
{
	unsigned char   digest[16];
	mupdf::md5_pixmap( m_internal, digest);
	return std::string( (char*) digest);
}

Pixmap::Pixmap(fz_pixmap* internal)
: m_internal(internal)
{
}

fz_storable Pixmap::storable()
{
	return m_internal->storable;
}

int Pixmap::x()
{
	return m_internal->x;
}

int Pixmap::y()
{
	return m_internal->y;
}

int Pixmap::w()
{
	return m_internal->w;
}

int Pixmap::h()
{
	return m_internal->h;
}

unsigned char Pixmap::n()
{
	return m_internal->n;
}

unsigned char Pixmap::s()
{
	return m_internal->s;
}

unsigned char Pixmap::alpha()
{
	return m_internal->alpha;
}

unsigned char Pixmap::flags()
{
	return m_internal->flags;
}

ptrdiff_t Pixmap::stride()
{
	return m_internal->stride;
}

Separations Pixmap::seps()
{
	mupdf::keep_separations(m_internal->seps);
	return m_internal->seps;
}

int Pixmap::xres()
{
	return m_internal->xres;
}

int Pixmap::yres()
{
	return m_internal->yres;
}

Colorspace Pixmap::colorspace()
{
	mupdf::keep_colorspace(m_internal->colorspace);
	return m_internal->colorspace;
}

const unsigned char *Pixmap::samples()
{
	return m_internal->samples;
}

Pixmap Pixmap::underlying()
{
	mupdf::keep_pixmap(m_internal->underlying);
	return m_internal->underlying;
}

Pixmap::~Pixmap()
{
	mupdf::drop_pixmap(m_internal);
}

/* Implementation of PixmapImage (wrapper for fz_pixmap_image). */

/* Wrapper for fz_pixmap_image_tile(). */
Pixmap PixmapImage::pixmap_image_tile()
{
	fz_pixmap* temp = mupdf::pixmap_image_tile(this->m_internal);
	return Pixmap(temp);
}

/* Wrapper for fz_set_pixmap_image_tile(). */
void PixmapImage::set_pixmap_image_tile(const Pixmap& pix)
{
	return mupdf::set_pixmap_image_tile(this->m_internal, pix.m_internal);
}

PixmapImage::PixmapImage(fz_pixmap_image* internal)
: m_internal(internal)
{
}

/* Implementation of Point (wrapper for fz_point). */

/* Custom constructor. */
Point::Point(float x, float y)
: x(x), y(y)
{
}

/* Wrapper for fz_transform_point(). */
Point Point::transform_point(Point& point, Matrix& m)
{
	fz_point temp = mupdf::transform_point(*(fz_point*) &point.x, *(fz_matrix*) &m.a);
	return Point(&temp);
}

/* Wrapper for fz_transform_point_xy(). */
Point Point::transform_point_xy(float x, float y, Matrix& m)
{
	fz_point temp = mupdf::transform_point_xy(x, y, *(fz_matrix*) &m.a);
	return Point(&temp);
}

/* Wrapper for fz_transform_vector(). */
Point Point::transform_vector(Point& vector, Matrix& m)
{
	fz_point temp = mupdf::transform_vector(*(fz_point*) &vector.x, *(fz_matrix*) &m.a);
	return Point(&temp);
}

/* Wrapper for fz_is_point_inside_quad(). */
int Point::is_point_inside_quad(Quad& q)
{
	return mupdf::is_point_inside_quad(*(fz_point*) &this->x, *(fz_quad*) &q.ul);
}

/* Wrapper for fz_is_point_inside_rect(). */
int Point::is_point_inside_rect(Rect& r)
{
	return mupdf::is_point_inside_rect(*(fz_point*) &this->x, *(fz_rect*) &r.x0);
}

/* Wrapper for fz_normalize_vector(). */
Point Point::normalize_vector()
{
	fz_point temp = mupdf::normalize_vector(*(fz_point*) &this->x);
	return Point(&temp);
}

/* Wrapper for fz_transform_point(). */
Point Point::transform_point(Matrix& m)
{
	fz_point temp = mupdf::transform_point(*(fz_point*) &this->x, *(fz_matrix*) &m.a);
	return Point(&temp);
}

/* Wrapper for fz_transform_vector(). */
Point Point::transform_vector(Matrix& m)
{
	fz_point temp = mupdf::transform_vector(*(fz_point*) &this->x, *(fz_matrix*) &m.a);
	return Point(&temp);
}

/* Custom method. */
Point& Point::transform(const Matrix& m)
{
	double  old_x = x;
	x = old_x * m.a + y * m.c + m.e;
	y = old_x * m.b + y * m.d + m.f;
	return *this;
}

Point::Point(const fz_point* internal)
{
	this->x = internal->x;
	this->y = internal->y;
}

Point::Point(const fz_point internal)
{
	this->x = internal.x;
	this->y = internal.y;
}

/* Constructor using raw copy of pre-existing fz_point. */
fz_point* Point::internal()
{
	return (fz_point*) &this->x;
}

/* Constructor using raw copy of pre-existing fz_point. */
const fz_point* Point::internal() const
{
	return (const fz_point*) &this->x;
}

/* Implementation of Pool (wrapper for fz_pool). */

/* Constructor using fz_new_pool(). */
Pool::Pool()
{
	this->m_internal = mupdf::new_pool();
}

/* Wrapper for fz_pool_alloc(). */
void *Pool::pool_alloc(size_t size)
{
	return mupdf::pool_alloc(this->m_internal, size);
}

/* Wrapper for fz_pool_size(). */
size_t Pool::pool_size()
{
	return mupdf::pool_size(this->m_internal);
}

/* Wrapper for fz_pool_strdup(). */
char *Pool::pool_strdup(const char *s)
{
	return mupdf::pool_strdup(this->m_internal, s);
}

Pool::Pool(fz_pool* internal)
: m_internal(internal)
{
}

Pool::~Pool()
{
	mupdf::drop_pool(m_internal);
}

/* Implementation of PwgOptions (wrapper for fz_pwg_options). */

PwgOptions::PwgOptions(const fz_pwg_options* internal)
: m_internal(*internal)
{
}

char * PwgOptions::media_class()
{
	return m_internal.media_class;
}

char * PwgOptions::media_color()
{
	return m_internal.media_color;
}

char * PwgOptions::media_type()
{
	return m_internal.media_type;
}

char * PwgOptions::output_type()
{
	return m_internal.output_type;
}

unsigned int PwgOptions::advance_distance()
{
	return m_internal.advance_distance;
}

int PwgOptions::advance_media()
{
	return m_internal.advance_media;
}

int PwgOptions::collate()
{
	return m_internal.collate;
}

int PwgOptions::cut_media()
{
	return m_internal.cut_media;
}

int PwgOptions::duplex()
{
	return m_internal.duplex;
}

int PwgOptions::insert_sheet()
{
	return m_internal.insert_sheet;
}

int PwgOptions::jog()
{
	return m_internal.jog;
}

int PwgOptions::leading_edge()
{
	return m_internal.leading_edge;
}

int PwgOptions::manual_feed()
{
	return m_internal.manual_feed;
}

unsigned int PwgOptions::media_position()
{
	return m_internal.media_position;
}

unsigned int PwgOptions::media_weight()
{
	return m_internal.media_weight;
}

int PwgOptions::mirror_print()
{
	return m_internal.mirror_print;
}

int PwgOptions::negative_print()
{
	return m_internal.negative_print;
}

unsigned int PwgOptions::num_copies()
{
	return m_internal.num_copies;
}

int PwgOptions::orientation()
{
	return m_internal.orientation;
}

int PwgOptions::output_face_up()
{
	return m_internal.output_face_up;
}

unsigned int * PwgOptions::PageSize()
{
	return m_internal.PageSize;
}

int PwgOptions::separations()
{
	return m_internal.separations;
}

int PwgOptions::tray_switch()
{
	return m_internal.tray_switch;
}

int PwgOptions::tumble()
{
	return m_internal.tumble;
}

int PwgOptions::media_type_num()
{
	return m_internal.media_type_num;
}

int PwgOptions::compression()
{
	return m_internal.compression;
}

unsigned int PwgOptions::row_count()
{
	return m_internal.row_count;
}

unsigned int PwgOptions::row_feed()
{
	return m_internal.row_feed;
}

unsigned int PwgOptions::row_step()
{
	return m_internal.row_step;
}

char * PwgOptions::rendering_intent()
{
	return m_internal.rendering_intent;
}

char * PwgOptions::page_size_name()
{
	return m_internal.page_size_name;
}

/* Implementation of Quad (wrapper for fz_quad). */

/* Constructor using fz_transform_quad(). */
Quad::Quad(Quad& q, Matrix& m)
{
	*(fz_quad*) &this->ul = mupdf::transform_quad(*(fz_quad*) &q.ul, *(fz_matrix*) &m.a);
}

/* Wrapper for fz_is_quad_inside_quad(). */
int Quad::is_quad_inside_quad(Quad& haystack)
{
	return mupdf::is_quad_inside_quad(*(fz_quad*) &this->ul, *(fz_quad*) &haystack.ul);
}

/* Wrapper for fz_is_quad_intersecting_quad(). */
int Quad::is_quad_intersecting_quad(Quad& b)
{
	return mupdf::is_quad_intersecting_quad(*(fz_quad*) &this->ul, *(fz_quad*) &b.ul);
}

/* Wrapper for fz_rect_from_quad(). */
Rect Quad::rect_from_quad()
{
	fz_rect temp = mupdf::rect_from_quad(*(fz_quad*) &this->ul);
	return Rect(&temp);
}

/* Wrapper for fz_transform_quad(). */
Quad Quad::transform_quad(Matrix& m)
{
	fz_quad temp = mupdf::transform_quad(*(fz_quad*) &this->ul, *(fz_matrix*) &m.a);
	return Quad(&temp);
}

Quad::Quad(const fz_quad* internal)
{
	this->ul = internal->ul;
	this->ur = internal->ur;
	this->ll = internal->ll;
	this->lr = internal->lr;
}

Quad::Quad(const fz_quad internal)
{
	this->ul = internal.ul;
	this->ur = internal.ur;
	this->ll = internal.ll;
	this->lr = internal.lr;
}

/* Constructor using raw copy of pre-existing fz_quad. */
fz_quad* Quad::internal()
{
	return (fz_quad*) &this->ul;
}

/* Constructor using raw copy of pre-existing fz_quad. */
const fz_quad* Quad::internal() const
{
	return (const fz_quad*) &this->ul;
}

/* Implementation of Range (wrapper for fz_range). */

Range::Range(fz_range* internal)
: m_internal(internal)
{
}

/* Implementation of Rect (wrapper for fz_rect). */

/* Constructor using fz_bound_display_list(). */
Rect::Rect(const DisplayList& list)
{
	*(fz_rect*) &this->x0 = mupdf::bound_display_list(list.m_internal);
}

/* Constructor using fz_rect_from_irect(). */
Rect::Rect(Irect& bbox)
{
	*(fz_rect*) &this->x0 = mupdf::rect_from_irect(*(fz_irect*) &bbox.x0);
}

/* Constructor using fz_rect_from_quad(). */
Rect::Rect(Quad& q)
{
	*(fz_rect*) &this->x0 = mupdf::rect_from_quad(*(fz_quad*) &q.ul);
}

/* Constructor using fz_transform_rect(). */
Rect::Rect(Rect& rect, Matrix& m)
{
	*(fz_rect*) &this->x0 = mupdf::transform_rect(*(fz_rect*) &rect.x0, *(fz_matrix*) &m.a);
}

/* Custom constructor. */
Rect::Rect(double x0, double y0, double x1, double y1)
:
x0(x0),
x1(x1),
y0(y0),
y1(y1)
{
}

/* Custom constructor. */
Rect::Rect(const Rect& rhs)
:
x0(rhs.x0),
x1(rhs.x1),
y0(rhs.y0),
y1(rhs.y1)
{
}

/* Custom constructor. */
Rect::Rect(Fixed fixed)
{
	if (0)  {}
	else if (fixed == Fixed_UNIT)       *this->internal() = ::fz_unit_rect;
	else if (fixed == Fixed_EMPTY)      *this->internal() = ::fz_empty_rect;
	else if (fixed == Fixed_INFINITE)   *this->internal() = ::fz_infinite_rect;
	throw ErrorAbort( "Unrecognised From value");
}

/* Wrapper for fz_intersect_rect(). */
Rect Rect::intersect_rect(Rect& a, Rect& b)
{
	fz_rect temp = mupdf::intersect_rect(*(fz_rect*) &a.x0, *(fz_rect*) &b.x0);
	return Rect(&temp);
}

/* Wrapper for fz_union_rect(). */
Rect Rect::union_rect(Rect& a, Rect& b)
{
	fz_rect temp = mupdf::union_rect(*(fz_rect*) &a.x0, *(fz_rect*) &b.x0);
	return Rect(&temp);
}

/* Wrapper for fz_adjust_rect_for_stroke(). */
Rect Rect::adjust_rect_for_stroke(const StrokeState& stroke, Matrix& ctm)
{
	fz_rect temp = mupdf::adjust_rect_for_stroke(*(fz_rect*) &this->x0, stroke.m_internal, *(fz_matrix*) &ctm.a);
	return Rect(&temp);
}

/* Wrapper for fz_contains_rect(). */
int Rect::contains_rect(Rect& b)
{
	return mupdf::contains_rect(*(fz_rect*) &this->x0, *(fz_rect*) &b.x0);
}

/* Wrapper for fz_expand_rect(). */
Rect Rect::expand_rect(float expand)
{
	fz_rect temp = mupdf::expand_rect(*(fz_rect*) &this->x0, expand);
	return Rect(&temp);
}

/* Wrapper for fz_include_point_in_rect(). */
Rect Rect::include_point_in_rect(Point& p)
{
	fz_rect temp = mupdf::include_point_in_rect(*(fz_rect*) &this->x0, *(fz_point*) &p.x);
	return Rect(&temp);
}

/* Wrapper for fz_intersect_rect(). */
Rect Rect::intersect_rect(Rect& b)
{
	fz_rect temp = mupdf::intersect_rect(*(fz_rect*) &this->x0, *(fz_rect*) &b.x0);
	return Rect(&temp);
}

/* Wrapper for fz_irect_from_rect(). */
Irect Rect::irect_from_rect()
{
	fz_irect temp = mupdf::irect_from_rect(*(fz_rect*) &this->x0);
	return Irect(&temp);
}

/* Wrapper for fz_is_empty_rect(). */
int Rect::is_empty_rect()
{
	return mupdf::is_empty_rect(*(fz_rect*) &this->x0);
}

/* Wrapper for fz_is_infinite_rect(). */
int Rect::is_infinite_rect()
{
	return mupdf::is_infinite_rect(*(fz_rect*) &this->x0);
}

/* Wrapper for fz_new_bbox_device(). */
Device Rect::new_bbox_device()
{
	fz_device* temp = mupdf::new_bbox_device((fz_rect *) &this->x0);
	return Device(temp);
}

/* Wrapper for fz_new_display_list(). */
DisplayList Rect::new_display_list()
{
	fz_display_list* temp = mupdf::new_display_list(*(fz_rect*) &this->x0);
	return DisplayList(temp);
}

/* Wrapper for fz_new_link(). */
Link Rect::new_link(void *doc, const char *uri)
{
	fz_link* temp = mupdf::new_link(*(fz_rect*) &this->x0, doc, uri);
	return Link(temp);
}

/* Wrapper for fz_quad_from_rect(). */
Quad Rect::quad_from_rect()
{
	fz_quad temp = mupdf::quad_from_rect(*(fz_rect*) &this->x0);
	return Quad(&temp);
}

/* Wrapper for fz_round_rect(). */
Irect Rect::round_rect()
{
	fz_irect temp = mupdf::round_rect(*(fz_rect*) &this->x0);
	return Irect(&temp);
}

/* Wrapper for fz_transform_page(). */
Matrix Rect::transform_page(float resolution, float rotate)
{
	fz_matrix temp = mupdf::transform_page(*(fz_rect*) &this->x0, resolution, rotate);
	return Matrix(&temp);
}

/* Wrapper for fz_transform_rect(). */
Rect Rect::transform_rect(Matrix& m)
{
	fz_rect temp = mupdf::transform_rect(*(fz_rect*) &this->x0, *(fz_matrix*) &m.a);
	return Rect(&temp);
}

/* Wrapper for fz_translate_rect(). */
Rect Rect::translate_rect(float xoff, float yoff)
{
	fz_rect temp = mupdf::translate_rect(*(fz_rect*) &this->x0, xoff, yoff);
	return Rect(&temp);
}

/* Wrapper for fz_union_rect(). */
Rect Rect::union_rect(Rect& b)
{
	fz_rect temp = mupdf::union_rect(*(fz_rect*) &this->x0, *(fz_rect*) &b.x0);
	return Rect(&temp);
}

/* Custom method. */
void Rect::transform(const Matrix& m)
{
	*(fz_rect*) &this->x0 = ::fz_transform_rect(*(fz_rect*) &this->x0, *(fz_matrix*) &m.a);
}

/* Custom method. */
bool Rect::contains(double x, double y)
{
	if (is_empty()) {
		return false;
	}
	return true
			&& x >= x0
			&& x < x1
			&& y >= y0
			&& y < y1
			;
}

/* Custom method. */
bool Rect::contains(Rect& rhs)
{
	return ::fz_contains_rect(*(fz_rect*) &x0, *(fz_rect*) &rhs.x0);
}

/* Custom method. */
bool Rect::is_empty()
{
	return ::fz_is_empty_rect(*(fz_rect*) &x0);
}

/* Custom method. */
void Rect::union_(Rect& rhs)
{
	*(fz_rect*) &x0 = ::fz_union_rect(*(fz_rect*) &x0, *(fz_rect*) &rhs.x0);
}

Rect::Rect(const fz_rect* internal)
{
	this->x0 = internal->x0;
	this->y0 = internal->y0;
	this->x1 = internal->x1;
	this->y1 = internal->y1;
}

Rect::Rect(const fz_rect internal)
{
	this->x0 = internal.x0;
	this->y0 = internal.y0;
	this->x1 = internal.x1;
	this->y1 = internal.y1;
}

/* Constructor using raw copy of pre-existing fz_rect. */
fz_rect* Rect::internal()
{
	return (fz_rect*) &this->x0;
}

/* Constructor using raw copy of pre-existing fz_rect. */
const fz_rect* Rect::internal() const
{
	return (const fz_rect*) &this->x0;
}

/* Implementation of Separations (wrapper for fz_separations). */

/* Constructor using fz_new_separations(). */
Separations::Separations(int controllable)
{
	this->m_internal = mupdf::new_separations(controllable);
}

/* Copy constructor using fz_keep_separations(). */
Separations::Separations(const Separations& rhs)
: m_internal(mupdf::keep_separations(rhs.m_internal))
{
}

/* operator= using fz_keep_separations() and fz_drop_separations(). */
Separations& Separations::operator=(const Separations& rhs)
{
	mupdf::drop_separations(this->m_internal);
	mupdf::keep_separations(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_add_separation(). */
void Separations::add_separation(const char *name, const Colorspace& cs, int cs_channel)
{
	return mupdf::add_separation(this->m_internal, name, cs.m_internal, cs_channel);
}

/* Wrapper for fz_add_separation_equivalents(). */
void Separations::add_separation_equivalents(uint32_t rgba, uint32_t cmyk, const char *name)
{
	return mupdf::add_separation_equivalents(this->m_internal, rgba, cmyk, name);
}

/* Wrapper for fz_clone_separations_for_overprint(). */
Separations Separations::clone_separations_for_overprint()
{
	fz_separations* temp = mupdf::clone_separations_for_overprint(this->m_internal);
	return Separations(temp);
}

/* Wrapper for fz_count_active_separations(). */
int Separations::count_active_separations()
{
	return mupdf::count_active_separations(this->m_internal);
}

/* Wrapper for fz_count_separations(). */
int Separations::count_separations()
{
	return mupdf::count_separations(this->m_internal);
}

/* Wrapper for fz_separation_current_behavior(). */
fz_separation_behavior Separations::separation_current_behavior(int separation)
{
	return mupdf::separation_current_behavior(this->m_internal, separation);
}

/* Wrapper for fz_separation_equivalent(). */
void Separations::separation_equivalent(int idx, const Colorspace& dst_cs, float *dst_color, const Colorspace& prf, ColorParams& color_params)
{
	return mupdf::separation_equivalent(this->m_internal, idx, dst_cs.m_internal, dst_color, prf.m_internal, *(fz_color_params*) &color_params.ri);
}

/* Wrapper for fz_separation_name(). */
const char *Separations::separation_name(int separation)
{
	return mupdf::separation_name(this->m_internal, separation);
}

/* Wrapper for fz_set_separation_behavior(). */
void Separations::set_separation_behavior(int separation, fz_separation_behavior behavior)
{
	return mupdf::set_separation_behavior(this->m_internal, separation, behavior);
}

Separations::Separations(fz_separations* internal)
: m_internal(internal)
{
}

Separations::~Separations()
{
	mupdf::drop_separations(m_internal);
}

/* Implementation of Sha256 (wrapper for fz_sha256). */

/* Wrapper for fz_sha256_final(). */
void Sha256::sha256_final(unsigned char digest[32])
{
	return mupdf::sha256_final(this->m_internal, digest);
}

/* Wrapper for fz_sha256_init(). */
void Sha256::sha256_init()
{
	return mupdf::sha256_init(this->m_internal);
}

/* Wrapper for fz_sha256_update(). */
void Sha256::sha256_update(const unsigned char *input, size_t inlen)
{
	return mupdf::sha256_update(this->m_internal, input, inlen);
}

Sha256::Sha256(fz_sha256* internal)
: m_internal(internal)
{
}

/* Implementation of Sha512 (wrapper for fz_sha512). */

/* Wrapper for fz_sha384_final(). */
void Sha512::sha384_final(unsigned char digest[64])
{
	return mupdf::sha384_final(this->m_internal, digest);
}

/* Wrapper for fz_sha384_init(). */
void Sha512::sha384_init()
{
	return mupdf::sha384_init(this->m_internal);
}

/* Wrapper for fz_sha384_update(). */
void Sha512::sha384_update(const unsigned char *input, size_t inlen)
{
	return mupdf::sha384_update(this->m_internal, input, inlen);
}

/* Wrapper for fz_sha512_final(). */
void Sha512::sha512_final(unsigned char digest[64])
{
	return mupdf::sha512_final(this->m_internal, digest);
}

/* Wrapper for fz_sha512_init(). */
void Sha512::sha512_init()
{
	return mupdf::sha512_init(this->m_internal);
}

/* Wrapper for fz_sha512_update(). */
void Sha512::sha512_update(const unsigned char *input, size_t inlen)
{
	return mupdf::sha512_update(this->m_internal, input, inlen);
}

Sha512::Sha512(fz_sha512* internal)
: m_internal(internal)
{
}

/* Implementation of Shade (wrapper for fz_shade). */

/* Copy constructor using fz_keep_shade(). */
Shade::Shade(const Shade& rhs)
: m_internal(mupdf::keep_shade(rhs.m_internal))
{
}

/* operator= using fz_keep_shade() and fz_drop_shade(). */
Shade& Shade::operator=(const Shade& rhs)
{
	mupdf::drop_shade(this->m_internal);
	mupdf::keep_shade(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_bound_shade(). */
Rect Shade::bound_shade(Matrix& ctm)
{
	fz_rect temp = mupdf::bound_shade(this->m_internal, *(fz_matrix*) &ctm.a);
	return Rect(&temp);
}

/* Wrapper for fz_paint_shade(). */
void Shade::paint_shade(const Colorspace& override_cs, Matrix& ctm, const Pixmap& dest, ColorParams& color_params, Irect& bbox, const Overprint& eop)
{
	return mupdf::paint_shade(this->m_internal, override_cs.m_internal, *(fz_matrix*) &ctm.a, dest.m_internal, *(fz_color_params*) &color_params.ri, *(fz_irect*) &bbox.x0, eop.m_internal);
}

/* Wrapper for fz_process_shade(). */
void Shade::process_shade(Matrix& ctm, Rect& scissor, fz_shade_prepare_fn *prepare, fz_shade_process_fn *process, void *process_arg)
{
	return mupdf::process_shade(this->m_internal, *(fz_matrix*) &ctm.a, *(fz_rect*) &scissor.x0, prepare, process, process_arg);
}

Shade::Shade(fz_shade* internal)
: m_internal(internal)
{
}

Shade::~Shade()
{
	mupdf::drop_shade(m_internal);
}

/* Implementation of ShaperDataT (wrapper for fz_shaper_data_t). */

ShaperDataT::ShaperDataT(fz_shaper_data_t* internal)
: m_internal(internal)
{
}

/* Implementation of StextBlock (wrapper for fz_stext_block). */

/* Custom method. */
StextBlockIterator StextBlock::begin()
{
	return StextBlockIterator(m_internal->u.t.first_line);
}

/* Custom method. */
StextBlockIterator StextBlock::end()
{
	return StextBlockIterator(NULL);
}

StextBlock::StextBlock(fz_stext_block* internal)
: m_internal(internal)
{
}


StextBlockIterator::StextBlockIterator(fz_stext_line* item)
: m_item( item)
{
}
StextBlockIterator& StextBlockIterator::operator++()
{
	m_item = StextLine(m_item.m_internal->next);
	return *this;
}
bool StextBlockIterator::operator==( const StextBlockIterator& rhs)
{
	return m_item.m_internal == rhs.m_item.m_internal;
}
bool StextBlockIterator::operator!=( const StextBlockIterator& rhs)
{
	return m_item.m_internal != rhs.m_item.m_internal;
}
StextLine StextBlockIterator::operator*()
{
	return m_item;
}
StextLine* StextBlockIterator::operator->()
{
	return &m_item;
}

void test(StextBlock& item)
{
	for( StextBlockIterator it = item.begin(); it != item.end(); ++it) {
		(void) *it;
	}
	for ( auto i: item) {
		(void) i;
	}
}

/* Implementation of StextChar (wrapper for fz_stext_char). */

StextChar::StextChar(fz_stext_char* internal)
: m_internal(internal)
{
}

/* Implementation of StextLine (wrapper for fz_stext_line). */

/* Custom method. */
StextLineIterator StextLine::begin()
{
	return StextLineIterator(m_internal->first_char);
}

/* Custom method. */
StextLineIterator StextLine::end()
{
	return StextLineIterator(NULL);
}

StextLine::StextLine(fz_stext_line* internal)
: m_internal(internal)
{
}


StextLineIterator::StextLineIterator(fz_stext_char* item)
: m_item( item)
{
}
StextLineIterator& StextLineIterator::operator++()
{
	m_item = StextChar(m_item.m_internal->next);
	return *this;
}
bool StextLineIterator::operator==( const StextLineIterator& rhs)
{
	return m_item.m_internal == rhs.m_item.m_internal;
}
bool StextLineIterator::operator!=( const StextLineIterator& rhs)
{
	return m_item.m_internal != rhs.m_item.m_internal;
}
StextChar StextLineIterator::operator*()
{
	return m_item;
}
StextChar* StextLineIterator::operator->()
{
	return &m_item;
}

void test(StextLine& item)
{
	for( StextLineIterator it = item.begin(); it != item.end(); ++it) {
		(void) *it;
	}
	for ( auto i: item) {
		(void) i;
	}
}

/* Implementation of StextOptions (wrapper for fz_stext_options). */

/* Custom constructor. */
StextOptions::StextOptions(int flags)
: flags( flags)
{
}

/* Wrapper for fz_parse_stext_options(). */
StextOptions StextOptions::parse_stext_options(const char *string)
{
	fz_stext_options* temp = mupdf::parse_stext_options((fz_stext_options *) &this->flags, string);
	return StextOptions(temp);
}

StextOptions::StextOptions(const fz_stext_options* internal)
{
	this->flags = internal->flags;
}

StextOptions::StextOptions(const fz_stext_options internal)
{
	this->flags = internal.flags;
}

/* Constructor using raw copy of pre-existing fz_stext_options. */
fz_stext_options* StextOptions::internal()
{
	return (fz_stext_options*) &this->flags;
}

/* Constructor using raw copy of pre-existing fz_stext_options. */
const fz_stext_options* StextOptions::internal() const
{
	return (const fz_stext_options*) &this->flags;
}

/* Implementation of StextPage (wrapper for fz_stext_page). */

/* Constructor using fz_new_stext_page(). */
StextPage::StextPage(Rect& mediabox)
{
	this->m_internal = mupdf::new_stext_page(*(fz_rect*) &mediabox.x0);
}

/* Constructor using fz_new_stext_page_from_display_list(). */
StextPage::StextPage(const DisplayList& list, StextOptions& options)
{
	this->m_internal = mupdf::new_stext_page_from_display_list(list.m_internal, (const fz_stext_options *) &options.flags);
}

/* Constructor using fz_new_stext_page_from_page(). */
StextPage::StextPage(const Page& page, StextOptions& options)
{
	this->m_internal = mupdf::new_stext_page_from_page(page.m_internal, (const fz_stext_options *) &options.flags);
}

/* Constructor using fz_new_stext_page_from_page_number(). */
StextPage::StextPage(const Document& doc, int number, StextOptions& options)
{
	this->m_internal = mupdf::new_stext_page_from_page_number(doc.m_internal, number, (const fz_stext_options *) &options.flags);
}

/* Wrapper for fz_copy_rectangle(). */
char *StextPage::copy_rectangle(Rect& area, int crlf)
{
	return mupdf::copy_rectangle(this->m_internal, *(fz_rect*) &area.x0, crlf);
}

/* Wrapper for fz_highlight_selection(). */
int StextPage::highlight_selection(Point& a, Point& b, Quad& quads, int max_quads)
{
	return mupdf::highlight_selection(this->m_internal, *(fz_point*) &a.x, *(fz_point*) &b.x, (fz_quad *) &quads.ul, max_quads);
}

/* Wrapper for fz_new_buffer_from_stext_page(). */
Buffer StextPage::new_buffer_from_stext_page()
{
	fz_buffer* temp = mupdf::new_buffer_from_stext_page(this->m_internal);
	return Buffer(temp);
}

/* Wrapper for fz_new_stext_device(). */
Device StextPage::new_stext_device(StextOptions& options)
{
	fz_device* temp = mupdf::new_stext_device(this->m_internal, (const fz_stext_options *) &options.flags);
	return Device(temp);
}

/* Wrapper for fz_search_stext_page(). */
int StextPage::search_stext_page(const char *needle, Quad& quads, int max_quads)
{
	return mupdf::search_stext_page(this->m_internal, needle, (fz_quad *) &quads.ul, max_quads);
}

/* Wrapper for fz_snap_selection(). */
Quad StextPage::snap_selection(Point& ap, Point& bp, int mode)
{
	fz_quad temp = mupdf::snap_selection(this->m_internal, (fz_point *) &ap.x, (fz_point *) &bp.x, mode);
	return Quad(&temp);
}

/* Custom method. */
std::string StextPage::copy_selection(Point& a, Point& b, int crlf)
{
	char* text = mupdf::copy_selection(m_internal, *(fz_point *) &a.x, *(fz_point *) &b.x, crlf);
	std::string ret(text);
	mupdf::free(text);
	return ret;
}

/* Custom method. */
StextPageIterator StextPage::begin()
{
	return StextPageIterator(m_internal->first_block);
}

/* Custom method. */
StextPageIterator StextPage::end()
{
	return StextPageIterator(NULL);
}

StextPage::StextPage(fz_stext_page* internal)
: m_internal(internal)
{
}

StextPage::~StextPage()
{
	mupdf::drop_stext_page(m_internal);
}


StextPageIterator::StextPageIterator(fz_stext_block* item)
: m_item( item)
{
}
StextPageIterator& StextPageIterator::operator++()
{
	m_item = StextBlock(m_item.m_internal->next);
	return *this;
}
bool StextPageIterator::operator==( const StextPageIterator& rhs)
{
	return m_item.m_internal == rhs.m_item.m_internal;
}
bool StextPageIterator::operator!=( const StextPageIterator& rhs)
{
	return m_item.m_internal != rhs.m_item.m_internal;
}
StextBlock StextPageIterator::operator*()
{
	return m_item;
}
StextBlock* StextPageIterator::operator->()
{
	return &m_item;
}

void test(StextPage& item)
{
	for( StextPageIterator it = item.begin(); it != item.end(); ++it) {
		(void) *it;
	}
	for ( auto i: item) {
		(void) i;
	}
}

/* Implementation of Storable (wrapper for fz_storable). */

/* Copy constructor using fz_keep_storable(). */
Storable::Storable(const Storable& rhs)
: m_internal((fz_storable*) mupdf::keep_storable(rhs.m_internal))
{
}

/* operator= using fz_keep_storable() and fz_drop_storable(). */
Storable& Storable::operator=(const Storable& rhs)
{
	mupdf::drop_storable(this->m_internal);
	mupdf::keep_storable(rhs.m_internal);
	this->m_internal = (fz_storable*) rhs.m_internal;
	return *this;
}

Storable::Storable(fz_storable* internal)
: m_internal(internal)
{
}

Storable::~Storable()
{
	mupdf::drop_storable(m_internal);
}

/* Implementation of Store (wrapper for fz_store). */

Store::Store(fz_store* internal)
: m_internal(internal)
{
}

/* Implementation of StoreHash (wrapper for fz_store_hash). */

StoreHash::StoreHash(fz_store_hash* internal)
: m_internal(internal)
{
}

/* Implementation of StoreType (wrapper for fz_store_type). */

StoreType::StoreType(fz_store_type* internal)
: m_internal(internal)
{
}

/* Implementation of Stream (wrapper for fz_stream). */

/* Constructor using fz_new_stream(). */
Stream::Stream(void *state, fz_stream_next_fn *next, fz_stream_drop_fn *drop)
{
	this->m_internal = mupdf::new_stream(state, next, drop);
}

/* Constructor using fz_open_file(). */
Stream::Stream(const char *filename)
{
	this->m_internal = mupdf::open_file(filename);
}

/* Constructor using fz_open_file_ptr_no_close(). */
Stream::Stream(FILE *file)
{
	this->m_internal = mupdf::open_file_ptr_no_close(file);
}

/* Constructor using fz_open_memory(). */
Stream::Stream(const unsigned char *data, size_t len)
{
	this->m_internal = mupdf::open_memory(data, len);
}

/* Custom constructor. */
Stream::Stream(const std::string& filename)
: m_internal(mupdf::open_file(filename.c_str()))
{
}

/* Copy constructor using fz_keep_stream(). */
Stream::Stream(const Stream& rhs)
: m_internal(mupdf::keep_stream(rhs.m_internal))
{
}

/* operator= using fz_keep_stream() and fz_drop_stream(). */
Stream& Stream::operator=(const Stream& rhs)
{
	mupdf::drop_stream(this->m_internal);
	mupdf::keep_stream(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_available(). */
size_t Stream::available(size_t max)
{
	return mupdf::available(this->m_internal, max);
}

/* Wrapper for fz_concat_push_drop(). */
void Stream::concat_push_drop(const Stream& chain)
{
	return mupdf::concat_push_drop(this->m_internal, chain.m_internal);
}

/* Wrapper for fz_decomp_image_from_stream(). */
Pixmap Stream::decomp_image_from_stream(const CompressedImage& image, Irect& subarea, int indexed, int l2factor)
{
	fz_pixmap* temp = mupdf::decomp_image_from_stream(this->m_internal, image.m_internal, (fz_irect *) &subarea.x0, indexed, l2factor);
	return Pixmap(temp);
}

/* Wrapper for fz_is_eof(). */
int Stream::is_eof()
{
	return mupdf::is_eof(this->m_internal);
}

/* Wrapper for fz_is_eof_bits(). */
int Stream::is_eof_bits()
{
	return mupdf::is_eof_bits(this->m_internal);
}

/* Wrapper for fz_is_tar_archive(). */
int Stream::is_tar_archive()
{
	return mupdf::is_tar_archive(this->m_internal);
}

/* Wrapper for fz_is_zip_archive(). */
int Stream::is_zip_archive()
{
	return mupdf::is_zip_archive(this->m_internal);
}

/* Wrapper for fz_new_archive_of_size(). */
Archive Stream::new_archive_of_size(int size)
{
	fz_archive* temp = mupdf::new_archive_of_size(this->m_internal, size);
	return Archive(temp);
}

/* Wrapper for fz_open_a85d(). */
Stream Stream::open_a85d()
{
	fz_stream* temp = mupdf::open_a85d(this->m_internal);
	return Stream(temp);
}

/* Wrapper for fz_open_aesd(). */
Stream Stream::open_aesd(unsigned char *key, unsigned int keylen)
{
	fz_stream* temp = mupdf::open_aesd(this->m_internal, key, keylen);
	return Stream(temp);
}

/* Wrapper for fz_open_ahxd(). */
Stream Stream::open_ahxd()
{
	fz_stream* temp = mupdf::open_ahxd(this->m_internal);
	return Stream(temp);
}

/* Wrapper for fz_open_arc4(). */
Stream Stream::open_arc4(unsigned char *key, unsigned int keylen)
{
	fz_stream* temp = mupdf::open_arc4(this->m_internal, key, keylen);
	return Stream(temp);
}

/* Wrapper for fz_open_archive_with_stream(). */
Archive Stream::open_archive_with_stream()
{
	fz_archive* temp = mupdf::open_archive_with_stream(this->m_internal);
	return Archive(temp);
}

/* Wrapper for fz_open_dctd(). */
Stream Stream::open_dctd(int color_transform, int l2factor, const Stream& jpegtables)
{
	fz_stream* temp = mupdf::open_dctd(this->m_internal, color_transform, l2factor, jpegtables.m_internal);
	return Stream(temp);
}

/* Wrapper for fz_open_endstream_filter(). */
Stream Stream::open_endstream_filter(int len, int64_t offset)
{
	fz_stream* temp = mupdf::open_endstream_filter(this->m_internal, len, offset);
	return Stream(temp);
}

/* Wrapper for fz_open_faxd(). */
Stream Stream::open_faxd(int k, int end_of_line, int encoded_byte_align, int columns, int rows, int end_of_block, int black_is_1)
{
	fz_stream* temp = mupdf::open_faxd(this->m_internal, k, end_of_line, encoded_byte_align, columns, rows, end_of_block, black_is_1);
	return Stream(temp);
}

/* Wrapper for fz_open_flated(). */
Stream Stream::open_flated(int window_bits)
{
	fz_stream* temp = mupdf::open_flated(this->m_internal, window_bits);
	return Stream(temp);
}

/* Wrapper for fz_open_image_decomp_stream(). */
Stream Stream::open_image_decomp_stream(const CompressionParams& arg_1, int *l2factor)
{
	fz_stream* temp = mupdf::open_image_decomp_stream(this->m_internal, arg_1.m_internal, l2factor);
	return Stream(temp);
}

/* Wrapper for fz_open_jbig2d(). */
Stream Stream::open_jbig2d(const Jbig2Globals& globals)
{
	fz_stream* temp = mupdf::open_jbig2d(this->m_internal, globals.m_internal);
	return Stream(temp);
}

/* Wrapper for fz_open_leecher(). */
Stream Stream::open_leecher(const Buffer& buf)
{
	fz_stream* temp = mupdf::open_leecher(this->m_internal, buf.m_internal);
	return Stream(temp);
}

/* Wrapper for fz_open_lzwd(). */
Stream Stream::open_lzwd(int early_change, int min_bits, int reverse_bits, int old_tiff)
{
	fz_stream* temp = mupdf::open_lzwd(this->m_internal, early_change, min_bits, reverse_bits, old_tiff);
	return Stream(temp);
}

/* Wrapper for fz_open_null_filter(). */
Stream Stream::open_null_filter(int len, int64_t offset)
{
	fz_stream* temp = mupdf::open_null_filter(this->m_internal, len, offset);
	return Stream(temp);
}

/* Wrapper for fz_open_predict(). */
Stream Stream::open_predict(int predictor, int columns, int colors, int bpc)
{
	fz_stream* temp = mupdf::open_predict(this->m_internal, predictor, columns, colors, bpc);
	return Stream(temp);
}

/* Wrapper for fz_open_range_filter(). */
Stream Stream::open_range_filter(const Range& ranges, int nranges)
{
	fz_stream* temp = mupdf::open_range_filter(this->m_internal, ranges.m_internal, nranges);
	return Stream(temp);
}

/* Wrapper for fz_open_rld(). */
Stream Stream::open_rld()
{
	fz_stream* temp = mupdf::open_rld(this->m_internal);
	return Stream(temp);
}

/* Wrapper for fz_open_sgilog16(). */
Stream Stream::open_sgilog16(int w)
{
	fz_stream* temp = mupdf::open_sgilog16(this->m_internal, w);
	return Stream(temp);
}

/* Wrapper for fz_open_sgilog24(). */
Stream Stream::open_sgilog24(int w)
{
	fz_stream* temp = mupdf::open_sgilog24(this->m_internal, w);
	return Stream(temp);
}

/* Wrapper for fz_open_sgilog32(). */
Stream Stream::open_sgilog32(int w)
{
	fz_stream* temp = mupdf::open_sgilog32(this->m_internal, w);
	return Stream(temp);
}

/* Wrapper for fz_open_tar_archive_with_stream(). */
Archive Stream::open_tar_archive_with_stream()
{
	fz_archive* temp = mupdf::open_tar_archive_with_stream(this->m_internal);
	return Archive(temp);
}

/* Wrapper for fz_open_thunder(). */
Stream Stream::open_thunder(int w)
{
	fz_stream* temp = mupdf::open_thunder(this->m_internal, w);
	return Stream(temp);
}

/* Wrapper for fz_open_zip_archive_with_stream(). */
Archive Stream::open_zip_archive_with_stream()
{
	fz_archive* temp = mupdf::open_zip_archive_with_stream(this->m_internal);
	return Archive(temp);
}

/* Wrapper for fz_peek_byte(). */
int Stream::peek_byte()
{
	return mupdf::peek_byte(this->m_internal);
}

/* Wrapper for fz_read(). */
size_t Stream::read(unsigned char *data, size_t len)
{
	return mupdf::read(this->m_internal, data, len);
}

/* Wrapper for fz_read_all(). */
Buffer Stream::read_all(size_t initial)
{
	fz_buffer* temp = mupdf::read_all(this->m_internal, initial);
	return Buffer(temp);
}

/* Wrapper for fz_read_best(). */
Buffer Stream::read_best(size_t initial, int *truncated)
{
	fz_buffer* temp = mupdf::read_best(this->m_internal, initial, truncated);
	return Buffer(temp);
}

/* Wrapper for fz_read_bits(). */
unsigned int Stream::read_bits(int n)
{
	return mupdf::read_bits(this->m_internal, n);
}

/* Wrapper for fz_read_byte(). */
int Stream::read_byte()
{
	return mupdf::read_byte(this->m_internal);
}

/* Wrapper for fz_read_float(). */
float Stream::read_float()
{
	return mupdf::read_float(this->m_internal);
}

/* Wrapper for fz_read_float_le(). */
float Stream::read_float_le()
{
	return mupdf::read_float_le(this->m_internal);
}

/* Wrapper for fz_read_int16(). */
int16_t Stream::read_int16()
{
	return mupdf::read_int16(this->m_internal);
}

/* Wrapper for fz_read_int16_le(). */
int16_t Stream::read_int16_le()
{
	return mupdf::read_int16_le(this->m_internal);
}

/* Wrapper for fz_read_int32(). */
int32_t Stream::read_int32()
{
	return mupdf::read_int32(this->m_internal);
}

/* Wrapper for fz_read_int32_le(). */
int32_t Stream::read_int32_le()
{
	return mupdf::read_int32_le(this->m_internal);
}

/* Wrapper for fz_read_int64(). */
int64_t Stream::read_int64()
{
	return mupdf::read_int64(this->m_internal);
}

/* Wrapper for fz_read_int64_le(). */
int64_t Stream::read_int64_le()
{
	return mupdf::read_int64_le(this->m_internal);
}

/* Wrapper for fz_read_line(). */
char *Stream::read_line(char *buf, size_t max)
{
	return mupdf::read_line(this->m_internal, buf, max);
}

/* Wrapper for fz_read_rbits(). */
unsigned int Stream::read_rbits(int n)
{
	return mupdf::read_rbits(this->m_internal, n);
}

/* Wrapper for fz_read_string(). */
void Stream::read_string(char *buffer, int len)
{
	return mupdf::read_string(this->m_internal, buffer, len);
}

/* Wrapper for fz_read_uint16(). */
uint16_t Stream::read_uint16()
{
	return mupdf::read_uint16(this->m_internal);
}

/* Wrapper for fz_read_uint16_le(). */
uint16_t Stream::read_uint16_le()
{
	return mupdf::read_uint16_le(this->m_internal);
}

/* Wrapper for fz_read_uint24(). */
uint32_t Stream::read_uint24()
{
	return mupdf::read_uint24(this->m_internal);
}

/* Wrapper for fz_read_uint24_le(). */
uint32_t Stream::read_uint24_le()
{
	return mupdf::read_uint24_le(this->m_internal);
}

/* Wrapper for fz_read_uint32(). */
uint32_t Stream::read_uint32()
{
	return mupdf::read_uint32(this->m_internal);
}

/* Wrapper for fz_read_uint32_le(). */
uint32_t Stream::read_uint32_le()
{
	return mupdf::read_uint32_le(this->m_internal);
}

/* Wrapper for fz_read_uint64(). */
uint64_t Stream::read_uint64()
{
	return mupdf::read_uint64(this->m_internal);
}

/* Wrapper for fz_read_uint64_le(). */
uint64_t Stream::read_uint64_le()
{
	return mupdf::read_uint64_le(this->m_internal);
}

/* Wrapper for fz_seek(). */
void Stream::seek(int64_t offset, int whence)
{
	return mupdf::seek(this->m_internal, offset, whence);
}

/* Wrapper for fz_skip(). */
size_t Stream::skip(size_t len)
{
	return mupdf::skip(this->m_internal, len);
}

/* Wrapper for fz_sync_bits(). */
void Stream::sync_bits()
{
	return mupdf::sync_bits(this->m_internal);
}

/* Wrapper for fz_tell(). */
int64_t Stream::tell()
{
	return mupdf::tell(this->m_internal);
}

/* Wrapper for fz_unread_byte(). */
void Stream::unread_byte()
{
	return mupdf::unread_byte(this->m_internal);
}

/* Wrapper for pdf_lex(). */
pdf_token Stream::pdf_lex(const PdfLexbuf& lexbuf)
{
	return mupdf::ppdf_lex(this->m_internal, lexbuf.m_internal);
}

/* Wrapper for pdf_lex_no_string(). */
pdf_token Stream::pdf_lex_no_string(const PdfLexbuf& lexbuf)
{
	return mupdf::ppdf_lex_no_string(this->m_internal, lexbuf.m_internal);
}

/* Wrapper for pdf_load_cmap(). */
PdfCmap Stream::pdf_load_cmap()
{
	pdf_cmap* temp = mupdf::ppdf_load_cmap(this->m_internal);
	return PdfCmap(temp);
}

/* Wrapper for pdf_open_crypt(). */
Stream Stream::pdf_open_crypt(const PdfCrypt& crypt, int num, int gen)
{
	fz_stream* temp = mupdf::ppdf_open_crypt(this->m_internal, crypt.m_internal, num, gen);
	return Stream(temp);
}

/* Wrapper for pdf_open_crypt_with_filter(). */
Stream Stream::pdf_open_crypt_with_filter(const PdfCrypt& crypt, const PdfObj& name, int num, int gen)
{
	fz_stream* temp = mupdf::ppdf_open_crypt_with_filter(this->m_internal, crypt.m_internal, name.m_internal, num, gen);
	return Stream(temp);
}

/* Wrapper for pdf_open_document_with_stream(). */
PdfDocument Stream::pdf_open_document_with_stream()
{
	pdf_document* temp = mupdf::ppdf_open_document_with_stream(this->m_internal);
	return PdfDocument(temp);
}

Stream::Stream(fz_stream* internal)
: m_internal(internal)
{
}

Stream::~Stream()
{
	mupdf::drop_stream(m_internal);
}

/* Implementation of StrokeState (wrapper for fz_stroke_state). */

/* Constructor using fz_new_stroke_state(). */
StrokeState::StrokeState()
{
	this->m_internal = mupdf::new_stroke_state();
}

/* Constructor using fz_new_stroke_state_with_dash_len(). */
StrokeState::StrokeState(int len)
{
	this->m_internal = mupdf::new_stroke_state_with_dash_len(len);
}

/* Copy constructor using fz_keep_stroke_state(). */
StrokeState::StrokeState(const StrokeState& rhs)
: m_internal(mupdf::keep_stroke_state(rhs.m_internal))
{
}

/* operator= using fz_keep_stroke_state() and fz_drop_stroke_state(). */
StrokeState& StrokeState::operator=(const StrokeState& rhs)
{
	mupdf::drop_stroke_state(this->m_internal);
	mupdf::keep_stroke_state(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_clone_stroke_state(). */
StrokeState StrokeState::clone_stroke_state()
{
	fz_stroke_state* temp = mupdf::clone_stroke_state(this->m_internal);
	return StrokeState(temp);
}

/* Wrapper for fz_unshare_stroke_state(). */
StrokeState StrokeState::unshare_stroke_state()
{
	fz_stroke_state* temp = mupdf::unshare_stroke_state(this->m_internal);
	return StrokeState(temp);
}

/* Wrapper for fz_unshare_stroke_state_with_dash_len(). */
StrokeState StrokeState::unshare_stroke_state_with_dash_len(int len)
{
	fz_stroke_state* temp = mupdf::unshare_stroke_state_with_dash_len(this->m_internal, len);
	return StrokeState(temp);
}

StrokeState::StrokeState(fz_stroke_state* internal)
: m_internal(internal)
{
}

StrokeState::~StrokeState()
{
	mupdf::drop_stroke_state(m_internal);
}

/* Implementation of StyleContext (wrapper for fz_style_context). */

StyleContext::StyleContext(fz_style_context* internal)
: m_internal(internal)
{
}

/* Implementation of Text (wrapper for fz_text). */

/* Constructor using fz_new_text(). */
Text::Text()
{
	this->m_internal = mupdf::new_text();
}

/* Copy constructor using fz_keep_text(). */
Text::Text(const Text& rhs)
: m_internal(mupdf::keep_text(rhs.m_internal))
{
}

/* operator= using fz_keep_text() and fz_drop_text(). */
Text& Text::operator=(const Text& rhs)
{
	mupdf::drop_text(this->m_internal);
	mupdf::keep_text(rhs.m_internal);
	this->m_internal = rhs.m_internal;
	return *this;
}

/* Wrapper for fz_bound_text(). */
Rect Text::bound_text(const StrokeState& stroke, Matrix& ctm)
{
	fz_rect temp = mupdf::bound_text(this->m_internal, stroke.m_internal, *(fz_matrix*) &ctm.a);
	return Rect(&temp);
}

/* Wrapper for fz_show_glyph(). */
void Text::show_glyph(const Font& font, Matrix& trm, int glyph, int unicode, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language)
{
	return mupdf::show_glyph(this->m_internal, font.m_internal, *(fz_matrix*) &trm.a, glyph, unicode, wmode, bidi_level, markup_dir, language);
}

/* Wrapper for fz_show_string(). */
Matrix Text::show_string(const Font& font, Matrix& trm, const char *s, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language)
{
	fz_matrix temp = mupdf::show_string(this->m_internal, font.m_internal, *(fz_matrix*) &trm.a, s, wmode, bidi_level, markup_dir, language);
	return Matrix(&temp);
}

Text::Text(fz_text* internal)
: m_internal(internal)
{
}

Text::~Text()
{
	mupdf::drop_text(m_internal);
}

/* Implementation of TextItem (wrapper for fz_text_item). */

TextItem::TextItem(fz_text_item* internal)
: m_internal(internal)
{
}

/* Implementation of TextSpan (wrapper for fz_text_span). */

TextSpan::TextSpan(fz_text_span* internal)
: m_internal(internal)
{
}

/* Implementation of Transition (wrapper for fz_transition). */

Transition::Transition(const fz_transition* internal)
{
	this->type = internal->type;
	this->duration = internal->duration;
	this->vertical = internal->vertical;
	this->outwards = internal->outwards;
	this->direction = internal->direction;
	this->state0 = internal->state0;
	this->state1 = internal->state1;
}

Transition::Transition(const fz_transition internal)
{
	this->type = internal.type;
	this->duration = internal.duration;
	this->vertical = internal.vertical;
	this->outwards = internal.outwards;
	this->direction = internal.direction;
	this->state0 = internal.state0;
	this->state1 = internal.state1;
}

/* Constructor using raw copy of pre-existing fz_transition. */
fz_transition* Transition::internal()
{
	return (fz_transition*) &this->type;
}

/* Constructor using raw copy of pre-existing fz_transition. */
const fz_transition* Transition::internal() const
{
	return (const fz_transition*) &this->type;
}

/* Implementation of Tree (wrapper for fz_tree). */

/* Wrapper for fz_tree_insert(). */
Tree Tree::tree_insert(const char *key, void *value)
{
	fz_tree* temp = mupdf::tree_insert(this->m_internal, key, value);
	return Tree(temp);
}

/* Wrapper for fz_tree_lookup(). */
void *Tree::tree_lookup(const char *key)
{
	return mupdf::tree_lookup(this->m_internal, key);
}

Tree::Tree(fz_tree* internal)
: m_internal(internal)
{
}

/* Implementation of TuningContext (wrapper for fz_tuning_context). */

TuningContext::TuningContext(fz_tuning_context* internal)
: m_internal(internal)
{
}

/* Implementation of Vertex (wrapper for fz_vertex). */

Vertex::Vertex(fz_vertex* internal)
: m_internal(internal)
{
}

/* Implementation of WarnContext (wrapper for fz_warn_context). */

WarnContext::WarnContext(fz_warn_context* internal)
: m_internal(internal)
{
}

/* Implementation of Xml (wrapper for fz_xml). */

/* Wrapper for fz_debug_xml(). */
void Xml::debug_xml(int level)
{
	return mupdf::debug_xml(this->m_internal, level);
}

/* Wrapper for fz_new_display_list_from_svg_xml(). */
DisplayList Xml::new_display_list_from_svg_xml(const char *base_uri, const Archive& zip, float *w, float *h)
{
	fz_display_list* temp = mupdf::new_display_list_from_svg_xml(this->m_internal, base_uri, zip.m_internal, w, h);
	return DisplayList(temp);
}

/* Wrapper for fz_new_image_from_svg_xml(). */
Image Xml::new_image_from_svg_xml(const char *base_uri, const Archive& zip)
{
	fz_image* temp = mupdf::new_image_from_svg_xml(this->m_internal, base_uri, zip.m_internal);
	return Image(temp);
}

/* Wrapper for fz_xml_att(). */
char *Xml::xml_att(const char *att)
{
	return mupdf::xml_att(this->m_internal, att);
}

/* Wrapper for fz_xml_att_eq(). */
int Xml::xml_att_eq(const char *name, const char *match)
{
	return mupdf::xml_att_eq(this->m_internal, name, match);
}

/* Wrapper for fz_xml_down(). */
Xml Xml::xml_down()
{
	fz_xml* temp = mupdf::xml_down(this->m_internal);
	return Xml(temp);
}

/* Wrapper for fz_xml_find(). */
Xml Xml::xml_find(const char *tag)
{
	fz_xml* temp = mupdf::xml_find(this->m_internal, tag);
	return Xml(temp);
}

/* Wrapper for fz_xml_find_down(). */
Xml Xml::xml_find_down(const char *tag)
{
	fz_xml* temp = mupdf::xml_find_down(this->m_internal, tag);
	return Xml(temp);
}

/* Wrapper for fz_xml_find_down_match(). */
Xml Xml::xml_find_down_match(const char *tag, const char *att, const char *match)
{
	fz_xml* temp = mupdf::xml_find_down_match(this->m_internal, tag, att, match);
	return Xml(temp);
}

/* Wrapper for fz_xml_find_match(). */
Xml Xml::xml_find_match(const char *tag, const char *att, const char *match)
{
	fz_xml* temp = mupdf::xml_find_match(this->m_internal, tag, att, match);
	return Xml(temp);
}

/* Wrapper for fz_xml_find_next(). */
Xml Xml::xml_find_next(const char *tag)
{
	fz_xml* temp = mupdf::xml_find_next(this->m_internal, tag);
	return Xml(temp);
}

/* Wrapper for fz_xml_find_next_match(). */
Xml Xml::xml_find_next_match(const char *tag, const char *att, const char *match)
{
	fz_xml* temp = mupdf::xml_find_next_match(this->m_internal, tag, att, match);
	return Xml(temp);
}

/* Wrapper for fz_xml_is_tag(). */
int Xml::xml_is_tag(const char *name)
{
	return mupdf::xml_is_tag(this->m_internal, name);
}

/* Wrapper for fz_xml_next(). */
Xml Xml::xml_next()
{
	fz_xml* temp = mupdf::xml_next(this->m_internal);
	return Xml(temp);
}

/* Wrapper for fz_xml_prev(). */
Xml Xml::xml_prev()
{
	fz_xml* temp = mupdf::xml_prev(this->m_internal);
	return Xml(temp);
}

/* Wrapper for fz_xml_tag(). */
char *Xml::xml_tag()
{
	return mupdf::xml_tag(this->m_internal);
}

/* Wrapper for fz_xml_text(). */
char *Xml::xml_text()
{
	return mupdf::xml_text(this->m_internal);
}

/* Wrapper for fz_xml_up(). */
Xml Xml::xml_up()
{
	fz_xml* temp = mupdf::xml_up(this->m_internal);
	return Xml(temp);
}

Xml::Xml(fz_xml* internal)
: m_internal(internal)
{
}

/* Implementation of XmlDoc (wrapper for fz_xml_doc). */

/* Wrapper for fz_detach_xml(). */
void XmlDoc::detach_xml(const Xml& node)
{
	return mupdf::detach_xml(this->m_internal, node.m_internal);
}

/* Wrapper for fz_xml_root(). */
Xml XmlDoc::xml_root()
{
	fz_xml* temp = mupdf::xml_root(this->m_internal);
	return Xml(temp);
}

XmlDoc::XmlDoc(fz_xml_doc* internal)
: m_internal(internal)
{
}

/* Implementation of ZipWriter (wrapper for fz_zip_writer). */

/* Constructor using fz_new_zip_writer(). */
ZipWriter::ZipWriter(const char *filename)
{
	this->m_internal = mupdf::new_zip_writer(filename);
}

/* Constructor using fz_new_zip_writer_with_output(). */
ZipWriter::ZipWriter(const Output& out)
{
	this->m_internal = mupdf::new_zip_writer_with_output(out.m_internal);
}

/* Wrapper for fz_close_zip_writer(). */
void ZipWriter::close_zip_writer()
{
	return mupdf::close_zip_writer(this->m_internal);
}

/* Wrapper for fz_write_zip_entry(). */
void ZipWriter::write_zip_entry(const char *name, const Buffer& buf, int compress)
{
	return mupdf::write_zip_entry(this->m_internal, name, buf.m_internal, compress);
}

ZipWriter::ZipWriter(fz_zip_writer* internal)
: m_internal(internal)
{
}

ZipWriter::~ZipWriter()
{
	mupdf::drop_zip_writer(m_internal);
}

} /* End of namespace mupdf. */