Вы находитесь на странице: 1из 17

QUIS 2 TUTORIAL KONVERTER MENGENAI KONVERTER PDF, EXCEL, WORD DARI WEB (PHP) KE FPDF DAN EZPDF

Halo teman teman, ini aku ada sedikit tutorial yang mungkin masih sederhana ya. Aku ada cara bagaimana menyisipkan foto dan video kedalam web dengan penggabungan antara TUTORIAL KONVERTER MENGENAI KONVERTER PDF, EXCEL, WORD DARI WEB (PHP) KE FPDF DAN EZPDF. Simak baik baik ya langkahnya: 1. Siapkan dulu software adobe dreamweaver , xampp,. 2. Aktifkan xampp nya ya

3. Buka adobe dreamweaver, dan lakukan peng-codingan sbb:

4. Lanjutkan listing sebagai berikut simpan dengan nama index.php:

<?php /* *--------------------------------------------------------------* APPLICATION ENVIRONMENT *--------------------------------------------------------------* * You can load different configurations depending on your * current environment. Setting the environment also influences * things like logging and error reporting. * * This can be set to anything, but default usage is: * * * * * * NOTE: If you change these, also change the error_reporting() code below * */ development testing production

define('ENVIRONMENT', 'development'); /* *--------------------------------------------------------------* ERROR REPORTING *--------------------------------------------------------------* * Different environments will require different levels of error reporting. * By default development will show errors but testing and live will hide them. */

if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'development': error_reporting(E_ALL); break;

case 'testing': case 'production': error_reporting(0); break;

default: exit('The application environment is not set correctly.'); } }

/* *--------------------------------------------------------------* SYSTEM FOLDER NAME *--------------------------------------------------------------* * This variable must contain the name of your "system" folder.

* Include the path if the folder is not in the same directory * as this file. * */ $system_path = 'system';

/* *--------------------------------------------------------------* APPLICATION FOLDER NAME *--------------------------------------------------------------* * If you want this front controller to use a different "application" * folder then the default one you can set its name here. The folder * can also be renamed or relocated anywhere on your server. If * you do, use a full server path. For more info please see the user guide: * http://codeigniter.com/user_guide/general/managing_apps.html * * NO TRAILING SLASH! * */ $application_folder = 'application';

/* * -------------------------------------------------------------------* DEFAULT CONTROLLER * -------------------------------------------------------------------* * Normally you will set your default controller in the routes.php file. * You can, however, force a custom routing by hard-coding a * specific controller class/function here. For most applications, you * WILL NOT set your routing here, but it's an option for those * special instances where you might want to override the standard * routing in a specific front controller that shares a common CI installation. *

* IMPORTANT: If you set the routing here, NO OTHER controller will be * callable. In essence, this preference limits your application to ONE * specific controller. Leave the function name blank if you need * to call functions dynamically via the URI. * * Un-comment the $routing array below to use this feature * */ // The directory name, relative to the "controllers" folder. Leave blank // if your controller is not in a sub-folder within the "controllers" folder // $routing['directory'] = '';

// The controller class file name. Example: Mycontroller // $routing['controller'] = '';

// The controller function you wish to be called. // $routing['function'] = '';

/* * ------------------------------------------------------------------* CUSTOM CONFIG VALUES * ------------------------------------------------------------------* * The $assign_to_config array below will be passed dynamically to the * config class when initialized. This allows you to set custom config * items or override any default config values found in the config.php file. * This can be handy as it permits you to share one application between * multiple front controller files, with each file containing different * config values. * * Un-comment the $assign_to_config array below to use this feature * */

// $assign_to_config['name_of_config_item'] = 'value of config item';

// -------------------------------------------------------------------// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE // --------------------------------------------------------------------

/* * --------------------------------------------------------------* Resolve the system path for increased reliability * --------------------------------------------------------------*/

// Set the current directory correctly for CLI requests if (defined('STDIN')) { chdir(dirname(__FILE__)); }

if (realpath($system_path) !== FALSE) { $system_path = realpath($system_path).'/'; }

// ensure there's a trailing slash $system_path = rtrim($system_path, '/').'/';

// Is the system path correct? if ( ! is_dir($system_path)) {

exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__,

PATHINFO_BASENAME)); }

/* * ------------------------------------------------------------------* Now that we know the path, set the main path constants * ------------------------------------------------------------------*/ // The name of THIS file define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));

// The PHP file extension // this global constant is deprecated. define('EXT', '.php');

// Path to the system folder define('BASEPATH', str_replace("\\", "/", $system_path));

// Path to the front controller (this file) define('FCPATH', str_replace(SELF, '', __FILE__));

// Name of the "system folder" define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));

// The path to the "application" folder if (is_dir($application_folder)) { define('APPPATH', $application_folder.'/'); } else {

if ( ! is_dir(BASEPATH.$application_folder.'/')) { exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF); }

define('APPPATH', BASEPATH.$application_folder.'/'); }

/* * -------------------------------------------------------------------* LOAD THE BOOTSTRAP FILE * -------------------------------------------------------------------* * And away we go... * */ require_once BASEPATH.'core/CodeIgniter.php';

/* End of file index.php */ /* Location: ./index.php */

5. Buat

desain

seperti

dibawah

ini

lalu

simpan

dengan

nama

views/welcome_message.php dan tulis coding dibawah:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Welcome to Missa's page</title>

<link

rel="stylesheet"

href="<?php

echo

base_url();?>styles/ci_styles.css"

type="text/css"/> <link rel="stylesheet" href="<?php echo base_url();?>styles/forms.css" type="text/css"/> </head> <body> <div id="container"> <h1>Welcome to Missa's page</h1> <div id="body">

<code>Buku Tamu <div id="respond"> <form name="frm1" action="<?php echo base_url().index_page();?>/welcome/test" method="POST"> <label>Nama</label> <input type="text" name="nama" id="nama" value=""/> <label>Alamat</label> <input type="text" name="alamat" id="alamat" value=""/> <br /> <br /> <?echo $captcha;?> <br /> <label>Masukan Kode verifikasi diatas:</label> <input type="text" name="kode" id="kode" value=""/> <br /> <input type="submit" name="submit" id="submit" value="Test Captcha"/> &nbsp; <input type="submit" name="submit" id="submit" value="Test ezPDF"/> &nbsp; <input type="submit" name="submit" id="submit" value="Test fPDF"/> </form> </div> </code>

<p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p> </div>

<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p> </div> </body> </html>

6. Lanjutkan listing sebagai berikut simpan di application/controllers/welcome.php:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Welcome extends CI_Controller { /** * Index Page for this controller. * * Maps to the following URL * * * * - or - or http://example.com/index.php/welcome/index http://example.com/index.php/welcome

* Since this controller is set as the default controller in * config/routes.php, it's displayed at http://example.com/

* * So any other public methods not prefixed with an underscore will * map to /index.php/welcome/<method_name> * @see http://codeigniter.com/user_guide/general/urls.html */ public function index() { $this->load->helper('captcha'); $pathnya = base_url()."captcha/"; $randomword = substr(md5(time()),26); $vals = array( 'word' => strtoupper($randomword), 'img_path' => './captcha/', 'img_url' => base_url().'captcha/' /*'font_path' => './path/to/fonts/texb.ttf', 'img_width' => '150', 'img_height' => 30, 'expiration' => 7200*/ ) $cap = create_captcha($vals); $this->session->set_userdata('captcha', $cap['word']); $data['captcha'] = $cap['image']; //echo ;

$this->load->view('welcome_message',$data); } public function test() { $tombol = $this->input->post('submit'); if($tombol=="Test Captcha") { if($this->session->userdata('captcha')==$this->input->post('kode')) { $this->session->unset_userdata('captcha'); echo("Sukses"); } else { echo "Gagal"; $this->session->unset_userdata('captcha'); } } elseif($tombol=="Test ezPDF") { /* include_once('pdf/class.ezpdf.php'); $pdf = & new Cezpdf();

$pdf->selectFont('pdf/fonts/Helvetica.afm'); $pdf->ezSetCmMargins(1, 1, 1, 1); $pdf->ezText('Nama $pdf->ezText('Alamat $pdf->ezText('Email $pdf->ezStream(); */ } elseif($tombol=="Test fPDF") { include_once('pdf/fpdf/fpdf.php'); $pdf=new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(10,10,'Hello World!'); $pdf->Ln(15); $pdf->SetFont('Arial','',10); $pdf->Write(5,'Visit '); // Then put a blue underlined link $pdf->SetTextColor(0,0,255); $pdf->SetFont('','U'); $pdf->Write(5,'www.fpdf.org','http://www.fpdf.org'); $pdf->Ln(15); : ' . 'var_SiOhm', 10); : ' . 'var_Jogja', 10); : ' . 'var_email', 10);

$pdf->Image('pdf/ros.jpg',10,30,-500); $pdf->Output(); } else { } } } /* End of file welcome.php */ /* Location: ./application/controllers/welcome.php */

7. Save all semua project, lalu jalankan di browser anda dengan alamat http://localhost/ci210/ :

8. Coba isi buku tamu diatas:

9. Klik tombol button test ezPDF, maka akan muncul hasilnya sebagai berikut:

10. Klik tombol button test fPDF, maka akan muncul hasilnya sebagai berikut:

11. Selesai teman teman. Semoga bermanfaat ya. Terimakasih .

Вам также может понравиться