// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace Poppler {

	using System;
	using System.Collections;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class Document : GLib.Object {

		[Obsolete]
		protected Document(GLib.GType gtype) : base(gtype) {}
		public Document(IntPtr raw) : base(raw) {}

		[DllImport("poppler-glib")]
		static extern unsafe IntPtr poppler_document_new_from_data(IntPtr data, int length, IntPtr password, out IntPtr error);

		public unsafe Document (string data, string password) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Document)) {
				throw new InvalidOperationException ("Can't override this constructor.");
			}
			IntPtr native_password = GLib.Marshaller.StringToPtrGStrdup (password);
			IntPtr error = IntPtr.Zero;
			Raw = poppler_document_new_from_data(GLib.Marshaller.StringToPtrGStrdup(data), System.Text.Encoding.UTF8.GetByteCount (data), native_password, out error);
			GLib.Marshaller.Free (native_password);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
		}

		[DllImport("poppler-glib")]
		static extern unsafe IntPtr poppler_document_new_from_file(IntPtr uri, IntPtr password, out IntPtr error);

		public static unsafe Document NewFromFile(string uri, string password)
		{
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			IntPtr native_password = GLib.Marshaller.StringToPtrGStrdup (password);
			IntPtr error = IntPtr.Zero;
			Document result = new Document (poppler_document_new_from_file(native_uri, native_password, out error));
			GLib.Marshaller.Free (native_uri);
			GLib.Marshaller.Free (native_password);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return result;
		}

		[DllImport("poppler-glib")]
		static extern unsafe bool poppler_document_save(IntPtr raw, IntPtr uri, out IntPtr error);

		public unsafe bool Save(string uri) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			IntPtr error = IntPtr.Zero;
			bool raw_ret = poppler_document_save(Handle, native_uri, out error);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_uri);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[DllImport("poppler-glib")]
		static extern unsafe bool poppler_document_save_a_copy(IntPtr raw, IntPtr uri, out IntPtr error);

		public unsafe bool SaveACopy(string uri) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			IntPtr error = IntPtr.Zero;
			bool raw_ret = poppler_document_save_a_copy(Handle, native_uri, out error);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_uri);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[DllImport("poppler-glib")]
		static extern IntPtr poppler_document_get_page_by_label(IntPtr raw, IntPtr label);

		public Poppler.Page GetPageByLabel(string label) {
			IntPtr native_label = GLib.Marshaller.StringToPtrGStrdup (label);
			IntPtr raw_ret = poppler_document_get_page_by_label(Handle, native_label);
			Poppler.Page ret = GLib.Object.GetObject(raw_ret) as Poppler.Page;
			GLib.Marshaller.Free (native_label);
			return ret;
		}

		[DllImport("poppler-glib")]
		static extern IntPtr poppler_document_get_form_field(IntPtr raw, int id);

		public Poppler.FormField GetFormField(int id) {
			IntPtr raw_ret = poppler_document_get_form_field(Handle, id);
			Poppler.FormField ret = GLib.Object.GetObject(raw_ret) as Poppler.FormField;
			return ret;
		}

		[DllImport("poppler-glib")]
		static extern IntPtr poppler_document_get_page(IntPtr raw, int index);

		public Poppler.Page GetPage(int index) {
			IntPtr raw_ret = poppler_document_get_page(Handle, index);
			Poppler.Page ret = GLib.Object.GetObject(raw_ret) as Poppler.Page;
			return ret;
		}

		[DllImport("poppler-glib")]
		static extern int poppler_document_get_n_pages(IntPtr raw);

		public int NPages { 
			get {
				int raw_ret = poppler_document_get_n_pages(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

		[DllImport("poppler-glib")]
		static extern bool poppler_document_has_attachments(IntPtr raw);

		public bool HasAttachments { 
			get {
				bool raw_ret = poppler_document_has_attachments(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

		[DllImport("poppler-glib")]
		static extern IntPtr poppler_document_find_dest(IntPtr raw, IntPtr link_name);

		public Poppler.Dest FindDest(string link_name) {
			IntPtr native_link_name = GLib.Marshaller.StringToPtrGStrdup (link_name);
			IntPtr raw_ret = poppler_document_find_dest(Handle, native_link_name);
			Poppler.Dest ret = Poppler.Dest.New (raw_ret);
			GLib.Marshaller.Free (native_link_name);
			return ret;
		}

		[DllImport("poppler-glib")]
		static extern IntPtr poppler_document_get_attachments(IntPtr raw);

		public GLib.List Attachments { 
			get {
				IntPtr raw_ret = poppler_document_get_attachments(Handle);
				GLib.List ret = new GLib.List(raw_ret);
				return ret;
			}
		}

		[DllImport("poppler-glib")]
		static extern IntPtr poppler_document_get_type();

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = poppler_document_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}

#endregion
	}
}
