Vince
Vince

Reputation: 1535

Snappy / WKHTMLtoPDF - How to change the save folder

I'm using Laravel with the snappy wrapper. It is all working except that it saves the PDF's into the public folder. I want it to go to a different folder. There is nothing obvious on the snappy git site, nor in the config. And the wkhtlptopdf docs are very sparse imho. How do I change the $pdf->save() statement so it goes where I want it to go ?

My PDF is generated by laravel like this:

 if( $email == 'email'){

        $quotation = $this->quotation->get_PdfQuote($ref);
        $pdf = PDF::loadView('quotations/pdf_quotation',compact('quotation') );
        $pdf->save($ref.'.pdf');  //THIS SAVES INTO THE PUBLIC FOLDER. 

       $title = 'Your Quotation';
       $firstname =  $customer['firstname1'];
       $pathtoFile = '/var/www/auburntree/public/'.$ref.'.pdf';


       Mail::send('emails.quotation', ['title' => $title, 'firstname'=>$firstname ], function ($m) use($customer,$pathtoFile)  {
            $m->from('[email protected]', 'Auburntree');

            $m->to($customer['email1'],($customer['firstname1'] . $customer['lastname1']))->subject('Your Quotation');

            $m->attach($pathtoFile);
        });

       Flash::success('The Quote Has Been Saved. An Email has ben sent to the customer ');
       return redirect ('quotes');

    } else

Upvotes: 1

Views: 1384

Answers (1)

Vince
Vince

Reputation: 1535

Ok, I hope this helps someone else.

        $quotation = $this->quotation->get_PdfQuote($ref);  //pulled in from DB
        $pdf = PDF::loadView('quotations/pdf_quotation',compact('quotation') );

        $filename = base_path('public/pdf/'.$ref.'.pdf');
        $pdf->save($filename);

Upvotes: 1

Related Questions