<?php

/**
 *
 * @copyright  2021-2022 mcpalo.com
 * @version    2
 * @link       http://www.mcpalo.com
 */

require_once 'sendhttp.php';
require_once 'filemimetype.php';

function makepdfa($login, $password, $file, $profile='2b', $output='pdfa.pdf') {
	$curl = 'https://tesseractor.com/api/v1/makepdfa' . '?' . 'login=' . urlencode($login) . '&' . 'password=' . urlencode($password);

	$args = array(
		'profile'	=> $profile,
	);

	$files=array('file' => array('name' => basename($file), 'tmp_name' => $file, 'type' => file_mime_type($file)));

	$response=sendpost($curl, $args, $files);

	if (!$response or $response[0] != 200) {
		return false;
	}

	return @file_put_contents($output, $response[2]);
}
