I use TCPDF for generate some PDF files and save it on PC. But it's save on server where is my website folder.
I need to save files to PC. when i work on local server (OpenServer), its works ok. The path is set in $_POST, becouse i use AJAX for generete pdf How to fix it?
Code:
require_once('tcpdf/tcpdf.php');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator('God');
$pdf->SetAuthor('God');
$pdf->SetTitle('Contract');
$pdf->SetSubject('Contract');
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
$pdf->setFontSubsetting(true);
$pdf->SetFont('dejavusans', '', 14, '', true);
$pdf->AddPage();
$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
ob_start();
include "page1.php";
$content = ob_get_clean();
$html = $content;
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->AddPage();
ob_start();
include "page2.php";
$content = ob_get_clean();
$html = $content;
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->AddPage();
ob_start();
include "page3.php";
$content = ob_get_clean();
$html = $content;
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->AddPage();
$dirname = $_POST['dirname'];
$path = $_POST['path'] . $dirname . '\ ';
mkdir($path, 0700);
$filename = $_POST['filename'] . '.pdf';
$pdf->Output($path . $filename, 'F');
Aucun commentaire:
Enregistrer un commentaire