pdfparser icon indicating copy to clipboard operation
pdfparser copied to clipboard

How to use PDFParser inside a Symfony Controller Action?

Open Fanny-gutting opened this issue 4 years ago • 2 comments

I use this to make my routes: image /** * @Route("/", name="accueil_index", methods={"GET"}) */ but I don't understand how to use pdf parser

Fanny-gutting avatar Apr 30 '21 08:04 Fanny-gutting

Do you wanna read a PDF file and output its content on a HTML page?

I assume you use Symfony framework together with PDFParser installed using Composer? Then you can just use:

$pdfparser = new PDFParser();
$document = $pdfparser->parseFile($fileToParse);
$pages = $document->getPages();
foreach ($pages as $page) {
    $content = $page->getText();
    // ...
}

Example taken from: https://github.com/smalot/pdfparser/blob/master/tests/Integration/ParserTest.php#L51-L80

k00ni avatar Apr 30 '21 09:04 k00ni

Yes I use in a page [name] .html.twig I also wanted to know how to put the link to choose the pdf in our file as with the demonstration on the pdfParser site. I use this way to link to my page : image and my pages look like this : image

Fanny-gutting avatar Apr 30 '21 09:04 Fanny-gutting