<commit_before><?php
/*
 * converts pages or document into different formats
 */
namespace Aspose\Cloud\Pdf;

use Aspose\Cloud\Common\AsposeApp;
use Aspose\Cloud\Common\Utils;
use Aspose\Cloud\Common\Product;
use Aspose\Cloud\Exception\AsposeCloudException as Exception;

class Converter {

    public $fileName = '';
    public $saveFormat = '';

    public function __construct($fileName) {
        $this->fileName = $fileName;

        $this->saveFormat = 'Pdf';
    }

    /*
     * convert a particular page to image with specified size
     * @param string $pageNumber
     * @param string $imageFormat
     * @param string $width
     * @param string $height
     */
    public function convertToImagebySize($pageNumber, $imageFormat, $width, $height) {
        try {
            //check whether file is set or not
            if ($this->fileName == '')
                throw new Exception('No file name specified');

            $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . '/pages/' . $pageNumber . '?format=' . $imageFormat . '&width=' . $width . '&height=' . $height;

            $signedURI = Utils::sign($strURI);

            $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

            $v_output = Utils::validateOutput($responseStream);

            if ($v_output === '') {
                $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->fileName) . '_' . $pageNumber . '.' . $imageFormat;
                Utils::saveFile($responseStream, $outputPath);
                return $outputPath;
            }
            else
                return $v_output;
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }

    /*
     * convert a particular page to image with default size
     * @param string $pageNumber
     * @param string $imageFormat
     */
    public function convertToImage($pageNumber, $imageFormat) {
        try {
            //check whether file is set or not
            if ($this->fileName == '')
                throw new Exception('No file name specified');

            $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . '/pages/' . $pageNumber . '?format=' . $imageFormat;

            $signedURI = Utils::sign($strURI);

            $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

            $v_output = Utils::validateOutput($responseStream);

            if ($v_output === '') {
                $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->fileName) . '_' . $pageNumber . '.' . $imageFormat;
                Utils::saveFile($responseStream, $outputPath);
                return $outputPath;
            }
            else
                return $v_output;
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }

    /*
     * convert a document to SaveFormat
     */
    public function convert() {
        try {
            //check whether file is set or not
            if ($this->fileName == '')
                throw new Exception('No file name specified');

            $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . '?format=' . $this->saveFormat;

            $signedURI = Utils::sign($strURI);

            $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

            $v_output = Utils::validateOutput($responseStream);

            if ($v_output === '') {
                if ($this->saveFormat == 'html') {
                    $saveFormat = 'zip';
                } else {
                    $saveFormat = $this->saveFormat;
                }

                $outputPath = Utils::saveFile($responseStream, AsposeApp::$outPutLocation . Utils::getFileName($this->fileName) . '.' . $saveFormat);
                return $outputPath;
            } else {
                return $v_output;
            }
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }<commit_msg>New Resources Implemented for Pdf<commit_after><?php
/*
 * converts pages or document into different formats
 */
namespace Aspose\Cloud\Pdf;

use Aspose\Cloud\Common\AsposeApp;
use Aspose\Cloud\Common\Utils;
use Aspose\Cloud\Common\Product;
use Aspose\Cloud\Exception\AsposeCloudException as Exception;

class Converter {

    public $fileName = '';
    public $saveFormat = '';

    public function __construct($fileName) {
        $this->fileName = $fileName;

        $this->saveFormat = 'Pdf';
    }

    /*
     * convert a particular page to image with specified size
     * @param string $pageNumber
     * @param string $imageFormat
     * @param string $width
     * @param string $height
     */
    public function convertToImagebySize($pageNumber, $imageFormat, $width, $height) {
        try {
            //check whether file is set or not
            if ($this->fileName == '')
                throw new Exception('No file name specified');

            $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . '/pages/' . $pageNumber . '?format=' . $imageFormat . '&width=' . $width . '&height=' . $height;

            $signedURI = Utils::sign($strURI);

            $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

            $v_output = Utils::validateOutput($responseStream);

            if ($v_output === '') {
                $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->fileName) . '_' . $pageNumber . '.' . $imageFormat;
                Utils::saveFile($responseStream, $outputPath);
                return $outputPath;
            }
            else
                return $v_output;
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }

    /*
     * convert a particular page to image with default size
     * @param string $pageNumber
     * @param string $imageFormat
     */
    public function convertToImage($pageNumber, $imageFormat) {
        try {
            //check whether file is set or not
            if ($this->fileName == '')
                throw new Exception('No file name specified');

            $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . '/pages/' . $pageNumber . '?format=' . $imageFormat;

            $signedURI = Utils::sign($strURI);

            $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

            $v_output = Utils::validateOutput($responseStream);

            if ($v_output === '') {
                $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->fileName) . '_' . $pageNumber . '.' . $imageFormat;
                Utils::saveFile($responseStream, $outputPath);
                return $outputPath;
            }
            else
                return $v_output;
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }

    /*
     * convert a document by url to SaveFormat
     */
    public function convertByUrl($url='',$format='',$outputFilename='') {
        try {
            //check whether file is set or not
            if ($url == '')
                throw new Exception('Url not specified');

            $strURI = Product::$baseProductUri . '/pdf/convert?url='.$url.'&format='.$format;

            $signedURI = Utils::sign($strURI);

            $responseStream = Utils::processCommand($signedURI, 'PUT', '', '');

            $v_output = Utils::validateOutput($responseStream);

            if ($v_output === '') {
                if ($this->saveFormat == 'html') {
                    $saveFormat = 'zip';
                } else {
                    $saveFormat = $this->saveFormat;
                }

                $outputPath = Utils::saveFile($responseStream, AsposeApp::$outPutLocation . Utils::getFileName($outputFilename) . '.' . $format);
                return $outputPath;
            } else {
                return $v_output;
            }
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }

    /*
     * convert a document to SaveFormat
     */
    public function convert() {
        try {
            //check whether file is set or not
            if ($this->fileName == '')
                throw new Exception('No file name specified');

            $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . '?format=' . $this->saveFormat;

            $signedURI = Utils::sign($strURI);

            $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

            $v_output = Utils::validateOutput($responseStream);

            if ($v_output === '') {
                if ($this->saveFormat == 'html') {
                    $saveFormat = 'zip';
                } else {
                    $saveFormat = $this->saveFormat;
                }

                $outputPath = Utils::saveFile($responseStream, AsposeApp::$outPutLocation . Utils::getFileName($this->fileName) . '.' . $saveFormat);
                return $outputPath;
            } else {
                return $v_output;
            }
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }
{'fraction_non_alphanumeric': 0.14066579634464751, 'fraction_numerical': 0.0, 'mean_word_length': 1.892699811202014, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2319923', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2404, 'n_words': 561}