0

i want to combined multi image/pdf to one single pdf file in laravel. i use Imagick packages, here is my code:

  $document1 = DocCust::latest('created_at')->where('cus_id',$id)->where('type','1')->first();
  $document2 = DocCust::latest('created_at')->where('cus_id',$id)->where('type','2')->first();


  $file1= public_path().'/documents/user_doc/'.$id.'/'.$document1->doc_pdf;
  $file2= public_path().'/documents/user_doc/'.$id.'/'.$document2->doc_pdf;
  $path = public_path().'/documents/user_doc/'.$id;

  $images = array($file1, $file2);


    $pdf = new Imagick($images);
    $pdf->setImageFormat('pdf');
    $pdf->writeImages('combined.pdf', true);

its works perfectly, but the new file pdf is saved to 'public' folder. i want to save the new pdf into folder based on their id.

public/documents/user_doc/'.$id.'

i tried to change this code with path, but i get error failed to open stream not found file etc..

     $pdf->writeImages($path.'/'.'combined.pdf', true);
nvrzl
  • 103
  • 1
  • 3
  • 14
  • How do `$path`/`public_path()` and the current working directory relate to your intended target directory? – mario Jan 02 '19 at 02:36
  • hey check this one out as this seems to be the same issue https://stackoverflow.com/questions/8623525/how-to-use-imagicks-writeimage-function – virtualone Jan 02 '19 at 04:24

0 Answers0