1. Go to this page and download the library: Download xorgxx/neox-pdf-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/ */
namespace App\Controller\Admin;
use NeoxToPdf\NeoxToPdfBundle\NeoxPdf\NeoxToPdfFactory;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
#[Route('/neox-to-pd')]
class NeoxToPdfController extends AbstractController
{
/**
* @throws TransportExceptionInterface
*/
#[Route('/', name: 'app_neox_to_pdf')]
public function index( NeoxToPdfFactory $neoxToPdf): Response
{
return $neoxToPdf->pdfLayerService()
->setParams('document_html',"Neox Wooooonnnn convert to pdf")
->setParams('test',true)
->convert()
->display_pdf();
// Advance** (read Bellow) section ADVANCE
$pdf = $neoxToPdf->customService("pdfLayerA")
->setPostData('document_html',"Neox Wooooonnnn convert to pdf") // in body
->setQuery('test',true) // in url
->convert()
->display_pdf();
}
}
neox_to_pdf:
...
# path to class customs
directory_class: "App/Services"
# Important | [pdfLayerAService] name have to be same "format" as the class name without "Service" ex: pdfLayerA not PdfLayera
customs:
pdfLayerA: "%env(PDFLAYERA_DSN)%"
...
namespace App\Services;
use NeoxToPdf\NeoxToPdfBundle\NeoxPdf\neoxPdfInterface;
use NeoxToPdf\NeoxToPdfBundle\NeoxPdf\NeoxToPdfAbstract;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
class pdfLayerAService extends NeoxToPdfAbstract implements neoxPdfInterface
{
public readonly HttpClientInterface $httpClient;
/**
* method: class construction
* You can do your logic here!!.
*
* @param bool $redirect
*
* @return mixed
* @throws TransportExceptionInterface
*/
public function htmlConverter(bool $redirect = false): mixed
{
...
$request = $this->buildRequest();
...
$t = $this->sendRequest($request, $postData);
return $this;
}
// Process to convert any (support) to pdf
public function anyConverter(): mixed
{
// TODO: Implement anyConverter() method. Woooooooonnnn !
}
public function buildRequest(): string
{
return $this->build_request();
}
/**
* @throws TransportExceptionInterface
*/
public function sendRequest(string $request, array $postData): string
{
return $this->doApi($request, $postData);
}
}
// This class have to extends NeoxToPdfAbstract and implements neoxPdfInterface
// $this->buildRequest() will construct base on Dsn request API
// $this->sendRequest($request, $postData) will send Api request : Note that this have to return string !!
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.