0
votes

I'm trying to generate a pdf in Symfony with WhiteOctoberTCPDFBundle with custom Header and Footer.

I always get the following error, even when generating the cache:

[Semantical Error] The annotation "@class" in class TCPDF was never imported. Did you maybe forget to add a "use" statement for this annotation?

It's like Doctrine annotation reader is trying to interpret @class as something related to ORM annotaions. Any idea how to solve it?

in my config.yml

white_october_tcpdf:
     class: 'Acme\DemoBundle\Pdf\MyClass'

in my custom class:

namespace Acme\DemoBundle\Pdf

use JMS\DiExtraBundle\Annotation as DI;
use TCPDF;

/**
*
* @DI\Service("foo.pdf_test")
*/
class MyClass extends TCPDF
{
    public function Header()
    {
        // some content
    }

    public function Footer()
    {
       // some content
    }
} 

In my controller:

/**
 * @MVC\Route("/pdf", name="pdf")
 * @MVC\Template()
 *
 * @return Response
 */
 public function pdfAction()
 {

    $pdf = $this->container->get("white_october.tcpdf")->create();

    $pdf->AddPage();

    // some content

    $response = new Response($pdf->Output('test.pdf', 'I'));
    $response->headers->set('Content-Type', 'application/pdf');

    return $response;
}

EDIT:

the @class code (in vendor)

/**
  * @class TCPDF
  * PHP class for generating PDF documents without requiring external extensions.
  * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public     Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
  * @package com.tecnick.tcpdf
  * @brief PHP class for generating PDF documents without requiring external extensions.
  * @version 6.2.0
  * @author Nicola Asuni - [email protected]
 */
  class TCPDF { 
      // ....
  }
1
pls post the code with the @class annotationjohn Smith
added the code with the @class annotationFra
I don't think @class or @brief are generally recognized documentation annotations (at least that I've seen). What doc builder are you using?AlpineCoder
I'm sorry, but I don't understand, what do you mean with "doc builder"?Fra

1 Answers

0
votes

You can resolve this by excluding annotations globally for example.

AnnotationReader::addGlobalIgnoredName("class");