/** * Gets the 'knp_snappy.image' service. * * This service is shared. * This method always returns the same instance of the service. * * @return \Knp\Bundle\SnappyBundle\Snappy\LoggableGenerator A Knp\Bundle\SnappyBundle\Snappy\LoggableGenerator instance. */ protected function getKnpSnappy_ImageService() { $a = new \Knp\Snappy\Image('wkhtmltoimage', array(), array()); $a->setTemporaryFolder(__DIR__ . '/snappy'); return $this->services['knp_snappy.image'] = new \Knp\Bundle\SnappyBundle\Snappy\LoggableGenerator($a, $this->get('monolog.logger.snappy', ContainerInterface::NULL_ON_INVALID_REFERENCE)); }
public function testAvailableOptions() { $testObject = new \Knp\Snappy\Image(); $testObject->setOption('use-xserver', true); $testObject->setOption('enable-smart-width', true); }
public function addDocuments($fileInfo) { $pdf = new \Knp\Snappy\Pdf($this->config->item('pdf_binary')); $image = new \Knp\Snappy\Image($this->config->item('image_binary')); $userP = array($fileInfo['formData']['user_permission']); $deptP = array($fileInfo['formData']['department_permission']); if ($this->session->admin && isset($fileInfo['formData']['file_department'])) { $currentUserDept = $fileInfo['formData']['file_department']; } else { $currentUserDept = $this->session->department; } if ($this->session->admin && isset($fileInfo['formData']['file_owner'])) { $ownerId = $fileInfo['formData']['file_owner']; } else { $ownerId = $this->session->id; } foreach ($fileInfo['fileData'] as $file) { $dbData = array('category' => $fileInfo['formData']['category'], 'owner' => $ownerId, 'realname' => $file['originalName'], 'created' => date('Y-m-d H:i:s'), 'description' => strip_tags($fileInfo['formData']['description']), 'comment' => strip_tags($fileInfo['formData']['comment']), 'status' => 0, 'department' => $currentUserDept, 'default_rights' => 0, 'publishable' => 0, 'location' => $file['newName']); $this->db->insert('documents', $dbData); $fileId = $this->db->insert_id(); foreach ($userP as $userO) { foreach ($userO as $u => $p) { $userPermsData = array('fid' => $fileId, 'uid' => $u, 'rights' => $p); $this->db->insert('user_perms', $userPermsData); } } foreach ($deptP as $deptO) { foreach ($deptO as $dId => $p) { $deptData = array('fid' => $fileId, 'rights' => $p, 'dept_id' => $dId); $this->db->insert('dept_perms', $deptData); } } $userName = $this->session->username; // Add a file history entry $data = array('id' => $fileId, 'modified_on' => date('Y-m-d H:i:s'), 'modified_by' => $userName, 'note' => 'Initial Import', 'revision' => 'current'); $this->db->insert('log', $data); Accesslog_Model::addLogEntry($fileId, 'A'); switch ($file['fileExt']) { case '.html': case '.php': case '.htm': //create PDF from HTML $html = $this->load->file(FCPATH . $this->config->item('dataDir') . $file['newName'], true); $newPdf = $this->config->item('dataDir') . 'pdf/' . $file['rawName'] . '.pdf'; $options = array('viewport-size' => '1250', 'user-style-sheet' => FCPATH . 'assets/css/bootstrap.css', 'load-error-handling' => 'skip'); $pdf->generateFromHtml($html, $newPdf, $options, true); //create thumbnail from HTML $options = array('format' => 'jpg', 'user-style-sheet' => FCPATH . 'assets/css/bootstrap.css', 'load-error-handling' => 'skip'); $newImage = $this->config->item('dataDir') . 'thumbnails/' . $file['rawName'] . '.jpg'; $image->generateFromHtml($html, $newImage, $options, true); break; case '.png': case '.jpg': $config['source_image'] = $this->config->item('dataDir') . $file['newName']; $config['new_image'] = $this->config->item('dataDir') . 'thumbnails/' . $file['newName']; $config['maintain_ratio'] = true; $config['height'] = 200; $this->load->library('image_lib', $config); $this->image_lib->resize(); break; default: break; } $this->emailPeople($fileId); } $msg = array('status' => 'success', 'msg' => 'All files were successfully uploaded.'); return json_encode($msg); }