PHP code example of cubemage / pdfjs-bundle

1. Go to this page and download the library: Download cubemage/pdfjs-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cubemage / pdfjs-bundle example snippets


   return [
       // ... 其他 bundles
       CubeMage\PdfJsBundle\CubeMagePdfJsBundle::class => ['all' => true],
   ];
   

   // src/Controller/YourController.php
   namespace App\Controller;
   
   use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
   use Symfony\Component\HttpFoundation\Request;
   use Symfony\Component\HttpFoundation\JsonResponse;
   use Symfony\Component\Routing\Annotation\Route;

   class YourController extends AbstractController
   {
       /**
        * @Route("/save-pdf-data", name="app_save_pdf_data", methods={"POST"})
        */
       public function savePdfData(Request $request): JsonResponse
       {
           $data = json_decode($request->getContent(), true);

           if (json_last_error() !== JSON_ERROR_NONE) {
               return new JsonResponse(['status' => 'error', 'message' => 'Invalid JSON'], 400);
           }
           
           // 在这里处理你的业务逻辑,例如:
           // $entityManager = $this->getDoctrine()->getManager();
           // ... 将 $data 数组中的数据保存到你的实体中 ...
           // $entityManager->flush();

           return new JsonResponse(['status' => 'success', 'message' => 'Data saved!']);
       }
   }
   
bash
    php bin/console assets:install