コード例 #1
0
ファイル: view_eval_pdf.php プロジェクト: jamestoot/Eval
 $iEvaluationId = $_POST['evaluation-id'];
 $url = urlencode('http://kaftans.boutique/dev/eval/admin/view_eval_pdf.php?skip_auth=1HGstGtw8272891H&eval_id=' . $iEvaluationId . '&remove_formatting=true');
 $curlSession = curl_init();
 curl_setopt($curlSession, CURLOPT_URL, 'http://www.html2pdf.it/?url=' . $url);
 curl_setopt($curlSession, CURLOPT_BINARYTRANSFER, true);
 curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);
 $Result = curl_exec($curlSession);
 if (!empty($_POST['email-pdf'])) {
     $blnSent = false;
     $objEvaluation = new Evaluation(NULL, $iEvaluationId);
     $arrEvaluation = $objEvaluation->getEvaluation();
     if (!empty($arrEvaluation['email'])) {
         $strEmail = $arrEvaluation['email'];
         $strName = $arrEvaluation['student'];
         $strFilename = 'evaluation-' . $iEvaluationId . '.pdf';
         $blnSent = $objEvaluation->emailEvaluation($strEmail, $strName, $Result, $strFilename);
     }
     if ($blnSent) {
         setTopMessage('success', 'Success! the PDF has been sent to ' . $strEmail . '.');
         header('Location: ' . $strLocation . 'admin/view_eval.php?eval_id=' . $iEvaluationId);
     } else {
         setTopMessage('errro', 'Error! The PDF was not sent, please check the email address.');
         header('Location: ' . $strLocation . 'admin/view_eval.php?eval_id=' . $iEvaluationId);
     }
 } else {
     header('Cache-Control: public');
     header('Content-type: application/pdf');
     header('Content-Disposition: attachment; filename="evaluation-' . $iEvaluationId . '.pdf"');
     header('Content-Length: ' . strlen($Result));
     echo $Result;
 }
コード例 #2
0
ファイル: generate_pdf.php プロジェクト: jamestoot/Eval
<?php

include "../includes/logincheck.php";
if (!empty($_POST)) {
    if (!empty($_POST['download-pdf'])) {
        if (!ini_get('display_errors')) {
            ini_set('display_errors', '1');
        }
        require_once '../includes/html2pdf_v4.03/html2pdf.class.php';
        $iEvaluationId = $_POST['evaluation-id'];
        $html2pdf = new HTML2PDF('P', 'A4', 'en');
        $username = '******';
        $password = '******';
        $context = stream_context_create(array('http' => array('header' => "Authorization: Basic " . base64_encode("{$username}:{$password}"))));
        $content = file_get_contents('http://jamestoothill.co.uk/dev/eval/admin/view_eval_pdf.php?skip_auth=1HGstGtw8272891H&eval_id=' . $iEvaluationId . '&remove_formatting=true', false, $context);
        $objEvaluation = new Evaluation(NULL, NULL);
        $objEvaluation->emailEvaluation('*****@*****.**', 'James Toothill', $content);
        //echo $content;
        //$html2pdf->WriteHTML($content);
        //$html2pdf->Output('exemple.pdf');
        exit;
    }
}