Utlisation knpSnappy

Par yaabapogbi, il y a 6 ans


Bonjour,

Mon objectif est de générer un fichier pdf contenant une liste de candidats.
Je bloque depuis quelques jours et je voudrais donc un coup de main.

j'ai installé le package via composer require knplabs/knp-snappy-bundle

Décrivez ici votre code ou ce que vous cherchez à faire

Voici comment se presente mon fichier app/config/package/knp_snappy.yaml
``knp_snappy:
pdf:
enabled: true
binary: "\"C:\wkhtmltopdf\bin\wkhtmltopdf.exe\""
options:

set default settings

        no-outline: true
        page-size: LETTER
        # recommend to set utf-8 as default encoding
        encoding: UTF-8
image:
    enabled:    true
    binary:     "\"C:\\wkhtmltopdf\\bin\\wkhtmltoimage.exe\""
    options:    []

`
le contenu du Controller
``
<?php
namespace App\Controller;
use App\Entity\Candidat;
use App\Form\CandidatType;
use App\Form\TuteurType;
use App\Repository\CandidatRepository;
use Doctrine\Common\Persistence\ObjectManager;
//use Doctrine\Common\Persistence\ManagerInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
use Knp\Bundle\SnappyBundle\Snappy;
use Knp\Snappy\Pdf;
use Knp\Bundle\SnappyBundle\DependencyInjection;
class VanController extends AbstractController
{
/**

}
`

Là l'erreur d'exécution que je reçois.

ServiceNotFoundException
HTTP 500 Internal Server Error
Service "knp_snappy.pdf" not found: even though it exists in the app's container, the container inside "App\Controller\VanController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services. Try using dependency injection instead.

Aucune réponse