示例#1
0
文件: generate.php 项目: biwax/OVOMA
function processPDF($parser)
{
    $url = $parser->getMenuURL();
    $name = $parser->getSimpleName();
    if (!is_null($url)) {
        if (downloadPDF($url, $name)) {
            convertPDFToText($name);
        }
    }
}
示例#2
0
function phptopdf($pdf_options)
{
    $pdf_options['api_key'] = API_KEY;
    $pdf_options['api_version'] = PHPTOPDF_API;
    $post_data = http_build_query($pdf_options);
    $post_array = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $post_data));
    $context = stream_context_create($post_array);
    if (isset($pdf_options['ssl']) && $pdf_options['ssl'] == 'yes') {
        $result = file_get_contents(PHPTOPDF_URL_SSL, false, $context);
    } else {
        if (isset($pdf_options['beta']) && $pdf_options['beta'] == 'yes') {
            $result = file_get_contents(PHPTOPDF_URL_BETA, false, $context);
        } else {
            if ($pdf_options['ssl'] == 'yes' && $pdf_options['beta'] == 'yes') {
                $result = file_get_contents("https://phptopdf.com/generatePDF_beta.php", false, $context);
            } else {
                $result = file_get_contents(PHPTOPDF_URL, false, $context);
            }
        }
    }
    $action = preg_replace('!\\s+!', '', $pdf_options['action']);
    if (isset($action) && !empty($action)) {
        switch ($action) {
            case 'view':
                //header('Content-type: application/pdf');
                //header('Content-Disposition: inline; filename="' . $pdf_options['file_name'] . '"');
                echo $result;
                break;
            case 'save':
                savePDF($result, $pdf_options['file_name'], $pdf_options['save_directory']);
                break;
            case 'download':
                downloadPDF($result, $pdf_options['file_name']);
                break;
            default:
                header('Content-type: application/pdf');
                echo $result;
                break;
        }
    } else {
        header('Content-type: application/pdf');
        echo $result;
    }
}
function phptopdf($pdf_options)
{
    $pdf_options['api_key'] = '41e024538150232f7b77ce256ee47e5cebe2b9f0';
    $post_data = http_build_query($pdf_options);
    $post_array = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $post_data));
    $context = stream_context_create($post_array);
    $result = file_get_contents(PHPTOPDF_URL, false, $context);
    $action = $pdf_options['action'];
    switch ($action) {
        case 'view':
            header('Content-type: application/pdf');
            echo $result;
            break;
        case 'save':
            savePDF($result, $pdf_options['file_name'], $pdf_options['save_directory']);
            break;
        case 'download':
            downloadPDF($result, $pdf_options['file_name']);
            break;
    }
}