public function orderPdfAction(Request $request, $id)
    {
        $locale = $request->getLocale();

        $this->get('translator')->setLocale($locale);

        $orderApiEntity = $this->getOrderManager()->findByIdAndLocale($id, $locale, false);
        $order = $orderApiEntity->getEntity();

        // Get pdf file from manager. Function parameter fallbacks are sufficient.
        $pdf = $this->getOrderPdfManager()->createOrderPdfDynamically($orderApiEntity);

        // Get the filename with parameter: isSubmitted = false since this is the unsubmitted case.
        $pdfName = $this->getOrderPdfManager()->getPdfName($order, false);

        // Get the response type defined in the parameters.yml.
        $responseType = $this->container->getParameter('sulu_sales_order.pdf_response_type');

        return new Response(
            $pdf,
            200,
            [
                'Content-Type' => 'application/pdf',
                'Content-Disposition' => sprintf('%s; filename="%s"', $responseType, $pdfName),
            ]
        );
    }
public function orderPdfAction(Request $request, $id)
    {
        $locale = $request->getLocale();

        $this->get('translator')->setLocale($locale);

        $orderApiEntity = $this->getOrderManager()->findByIdAndLocale($id, $locale, false);
        $order = $orderApiEntity->getEntity();

        // Get pdf file from manager. Function parameter fallbacks are sufficient.
        $pdf = $this->getOrderPdfManager()->createOrderPdfDynamically($orderApiEntity);

        // Get the filename with parameter: isSubmitted = false since this is the unsubmitted case.
        $pdfName = $this->getOrderPdfManager()->getPdfName($order, false);

        // Get the response type defined in the parameters.yml.
        $responseType = $this->container->getParameter('sulu_sales_order.pdf_response_type');

        return new Response(
            $pdf,
            200,
            [
                'Content-Type' => 'application/pdf',
                'Content-Disposition' => sprintf('%s; filename="%s"', $responseType, $pdfName),
            ]
        );
    }
public function orderPdfAction ( Request $ request , $ id ) { $ locale = $ request -> getLocale ( ) ; $ this -> get ( 'translator' ) -> setLocale ( $ locale ) ; $ orderApiEntity = $ this -> getOrderManager ( ) -> findByIdAndLocale ( $ id , $ locale , false ) ; $ order = $ orderApiEntity -> getEntity ( ) ; // Get pdf file from manager. Function parameter fallbacks are sufficient. $ pdf = $ this -> getOrderPdfManager ( ) -> createOrderPdfDynamically ( $ orderApiEntity ) ; // Get the filename with parameter: isSubmitted = false since this is the unsubmitted case. $ pdfName = $ this -> getOrderPdfManager ( ) -> getPdfName ( $ order , false ) ; // Get the response type defined in the parameters.yml. $ responseType = $ this -> container -> getParameter ( 'sulu_sales_order.pdf_response_type' ) ; return new Response ( $ pdf , 200 , [ 'Content-Type' => 'application/pdf' , 'Content-Disposition' => sprintf ( '%s; filename="%s"' , $ responseType , $ pdfName ) , ] ) ; }
Finds an order object by a given id from the url and renders a configurable template.
Then returns it as pdf in a new tab.

@param Request $request
@param int $id

@throws OrderNotFoundException

@return Response
Finds an order object by a given id from the url and renders a configurable template . Then returns it as pdf in a new tab .