<?php
if(!defined('BASEPATH')) exit('No direct script access allowed');

/*
 * Docxtopdf helper for CodeIgniter
 *  
 */

function convert_pdf($fileasal,$filetarget) {
	
	$return = '';
		
		$instance = explode(" ",php_uname());
		if($instance[0] == 'Windows')
		{	
			//echo $fileasal; 
			//echo "<br>".$filetarget;
			$word = new COM("Word.Application") or die ("Could not initialise Object.");
			$word->Visible = 0;
			$word->DisplayAlerts = 0;
			$word->Documents->Open($fileasal); 
			$word->ActiveDocument->SaveAs('baru.doc');
			$word->ActiveDocument->ExportAsFixedFormat($filetarget, 17, false, 0, 0, 0, 0, 7, true, true, 2, true, true, false);
			$word->Quit(false);
			unset($word);
			$return = json_encode("Convert success");
		}			
            else
		{
			exec('python '.FCPATH.'resources/pdf-master/converter.py '.$fileasal.' '.$filetarget);
		}	
	return $return;
	
}
