コード例 #1
0
ファイル: index.php プロジェクト: BellyWong/FreeApiPrint
 } catch (Exception $e) {
     $response->sendCallError('Impossible to get content');
 }
 // New print...
 if ($api_print === null) {
     $api_print = new ApiPrint();
     $api_print->setIdUser($api_user->getId());
     if ($url !== null) {
         $api_print->setUrl($url);
     } elseif ($content !== null) {
         $api_print->setContent($content);
     } else {
         $response->sendDisastrousError('Logical error : no content, no url');
     }
     $api_print->setMd5($md5);
     $api_print->setNb(0);
 }
 // Print to PDF
 try {
     // Check the options
     if (isset($_POST['options']) === true && is_array($_POST['options']) === true) {
         $options = $_POST['options'];
     }
     $pdf = $api_print->printPage($options);
     $api_print->save();
 } catch (Exception $e) {
     $response->sendTransformError($e->getMessage());
 }
 // Send PDF
 $response->setContent($pdf, true);
 $response->setDownloadHeader('transform.pdf');