Example #1
0
 /**
  * Constructeur à partir d'une factory
  *
  * @param string $factory Factory name
  */
 function __construct($factory = null)
 {
     if ($factory === null || $factory === "none") {
         $factory = "CWkHtmlToPDFConverter";
     }
     CHtmlToPDFConverter::init($factory);
 }
Example #2
0
 /**
  * Make a PDF document archive of the sejour (based on soins/print_dossier_soins)
  *
  * @param string $title   File title
  * @param bool   $replace Replace existing file
  *
  * @return bool
  * @throws CMbException
  */
 function makePDFarchive($title = "Dossier complet", $replace = false)
 {
     if (!CModule::getActive("soins")) {
         return false;
     }
     $query = array("m" => "soins", "a" => "print_dossier_soins", "sejour_id" => $this->_id, "dialog" => 1, "offline" => 1, "limit" => 10000, "_aio" => 1, "_aio_ignore_scripts" => 1);
     $base = $_SERVER["SCRIPT_NAME"] . "?" . http_build_query($query, "", "&");
     $result = CApp::serverCall("http://127.0.0.1{$base}");
     $content = $result["body"];
     $file = new CFile();
     $file->setObject($this);
     $file->file_name = "{$title}.pdf";
     $file->file_type = "application/pdf";
     /*if ($file->loadMatchingObject()) {
           if ($replace) {
             $file->delete();
     
             // New file
             $file = new CFile();
             $file->setObject($this);
             $file->file_name = "$title.pdf";
             $file->file_type = "application/pdf";
           }
         }*/
     $file->fillFields();
     $file->updateFormFields();
     $file->forceDir();
     $file->author_id = CAppUI::$user->_id;
     $compte_rendu = new CCompteRendu();
     $compte_rendu->_orientation = "portrait";
     $format = CCompteRendu::$_page_formats["a4"];
     $page_width = round(72 / 2.54 * $format[0], 2);
     $page_height = round(72 / 2.54 * $format[1], 2);
     $compte_rendu->_page_format = array(0, 0, $page_width, $page_height);
     $content = str_replace("<!DOCTYPE html>", "", $content);
     CHtmlToPDFConverter::init("CWkHtmlToPDFConverter");
     //CHtmlToPDFConverter::init("CPrinceXMLConverter");
     $pdf = CHtmlToPDFConverter::convert($content, $compte_rendu->_page_format, $compte_rendu->_orientation);
     $file->putContent($pdf);
     if ($msg = $file->store()) {
         throw new CMbException($msg);
     }
     return true;
 }