mikehaertl\pdftk\Pdf::saveAs PHP Method

saveAs() public method

Execute the operation and save the output file
public saveAs ( string $name ) : boolean
$name string of output file
return boolean whether the PDF could be processed and saved
    public function saveAs($name)
    {
        if (!$this->getCommand()->getExecuted() && !$this->execute()) {
            return false;
        }
        $tmpFile = (string) $this->getTmpFile();
        if (!copy($tmpFile, $name)) {
            $this->_error = "Could not copy PDF from tmp location '{$tmpFile}' to '{$name}'";
            return false;
        }
        return true;
    }

Usage Example

Exemplo n.º 1
1
 public function dosplit(Request $request)
 {
     $print_element = Element::where('subject_lesson_id', $request->subject_lesson_id)->where('title', 'نسخة للطباعة')->first();
     if (!$print_element) {
         $print_element = new Element();
         $print_element->title = 'نسخة للطباعة';
         $print_element->element_order = 10;
         $print_element->state = 'نشط';
         $print_element->type = 'pdf';
         $print_element->subject_lesson_id = $request->subject_lesson_id;
         $print_element->file = $request->file('file');
         $print_element->save();
     }
     foreach ($request->subject_element_title as $key => $value) {
         if ($request->element_start_page[$key]) {
             $elelment = new Element();
             $fonly = uniqid() . time() . '.pdf';
             $filename = public_path() . '/temp/' . $fonly;
             $elelment->title = $value;
             $elelment->element_order = $request->element_order[$key];
             $elelment->state = 'نشط';
             $elelment->type = 'pdf';
             $elelment->subject_lesson_id = $request->subject_lesson_id;
             $pdf = new Pdf($print_element->file->path());
             $pdf->cat($request->element_start_page[$key], $request->element_end_page[$key]);
             $pdf->saveAs($filename);
             // sleep(8);
             $elelment->file = $filename;
             // $elelment->file = 'https://el-css.edu.om/admin/public/temp/'.$fonly;
             $elelment->save();
         }
     }
     $message = 'تم اضافة العناصر بنجاح';
     return redirect()->route('s.elements.index', array('id' => $request->subject_lesson_id))->with('success', $message);
 }
All Usage Examples Of mikehaertl\pdftk\Pdf::saveAs