2

I am using this Bundle to convert HTML to PDF files.

The actual conversion works, but I have a problem understanding the routing.

Here is my code:

/**
 * @Route("/formulare/selbstauskunft/{keycode}", name="saPrint")
 */
public function saPrintAction(Request $request, $keycode)
{


    $em = $this->getDoctrine()->getManager();
    $sa = $em->getRepository('AppBundle:Selfinfo')->findOneBy(array(
        'keycode' => $keycode,
    ));

    if(count($sa) > 0){

        $response = new Response(
            $this->get('padam87_rasterize.rasterizer')->rasterize(
                $this->renderView('default/formSAPrint.html.twig', array(
                    'selfinfo' => $sa,
                ))
            ),
            200, [
                'Content-Type'          => 'application/pdf',
                'Content-Disposition'   => 'attachment; filename="my.pdf"'
            ]
        );

        return $response;

    }else{
        return new Response("fail");
    }
}

The bundle creates 2 files, rasterize-UNIQUEID.html and rasterize-UNIQUEID.pdf. The html file contains the correct output. After the creation of the html file in /bundles/padam87rasterize/temp/ the second part of the script opens this file via an url call here. Unfortunately the actual rendered page is a symfony error page, saying:

No route found for GET /bundles/padam87rasterize/temp/rasterize-UNIQUEID.html

What do I have to set in order to render the html file?

vishuB
  • 4,173
  • 5
  • 31
  • 49
PrimuS
  • 2,505
  • 6
  • 33
  • 66

1 Answers1

0

I think you actually have to create a separare route to render the html. As far as I can tell the rasterize function generates a pdf from the temporary html file (The key word being temporary).

alexandra
  • 1,182
  • 13
  • 24