#---------------------------------------------------------------------------#
#          Copyright (c) 1997-2010 PDFlib GmbH. All rights reserved.        #
#---------------------------------------------------------------------------#
#    This software may not be copied or distributed except as expressly     #
#    authorized by PDFlib GmbH's general license agreement or a custom      #
#    license agreement signed by PDFlib GmbH.                               #
#    For more information about licensing please refer to www.pdflib.com.   #
#---------------------------------------------------------------------------#

# $Id: TET.pm,v 1.3 2010/06/10 06:28:49 rjs Exp $
#

package PDFlib::TET;

use strict;
use Carp;

use tetlib_pl 4.0;
our $VERSION = 4.0;

sub new {
    my $class = shift;
    my $self = {};
    my $tet = TET_new();

    bless $self, $class;
    $self->{tet} = $tet;
    TET_set_option($tet, "binding={perl} objorient");

    return $self;
}

sub DESTROY {
    my $self = shift;

    TET_delete($self->{tet});
}

# Automatically generated methods



sub close_document {
    my $self = shift;
    eval {
	TET_close_document($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
}

sub close_page {
    my $self = shift;
    eval {
	TET_close_page($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
}

sub create_pvf {
    my $self = shift;
    eval {
	TET_create_pvf($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
}

sub delete_pvf {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_delete_pvf($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub get_apiname {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_get_apiname($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub get_char_info {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_get_char_info($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub get_errmsg {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_get_errmsg($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub get_errnum {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_get_errnum($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub get_image_data {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_get_image_data($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub get_image_info {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_get_image_info($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub get_text {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_get_text($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub open_document {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_open_document($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub open_document_mem {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_open_document_mem($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub open_page {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_open_page($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub pcos_get_number {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_pcos_get_number($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub pcos_get_string {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_pcos_get_string($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub pcos_get_stream {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_pcos_get_stream($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub set_option {
    my $self = shift;
    eval {
	TET_set_option($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
}

sub utf16_to_utf8 {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_utf16_to_utf8($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub utf8_to_utf16 {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_utf8_to_utf16($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub utf8_to_utf32 {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_utf8_to_utf32($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub utf16_to_utf32 {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_utf16_to_utf32($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub utf32_to_utf16 {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_utf32_to_utf16($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub write_image_file {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_write_image_file($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub process_page {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_process_page($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}

sub get_xml_data {
    my $self = shift;
    my $ret;
    eval {
	$ret = TET_get_xml_data($self->{tet}, @_);
    };
    if ($@) {
	croak($@);
    }
    return($ret);
}
