1

I want to create custom pdf with custom text or media

can anyone suggestion me any best link or some help Thanks

0

2 Answers 2

4

You can check below link
1) https://meetanshi.com/blog/generate-pdf-programmatically-magento-2/
2) Magento 2: Convert HTML code into PDF file and Download?
3) https://webkul.com/blog/generate-pdf-programmatically-magento2/

3
2

You Can Check Below Link

https://docs.google.com/document/d/1ORs80r5okZoWdQqLi1gJtlUZ6UH4luBs1SN0YRioiD0/edit

app/code/VendoreName/RmaPdfPrint/Controller/Rma

PrintAction.php

<?php

declare(strict_types=1);

namespace VendoreName\RmaPdfPrint\Controller\Rma;

use Magento\Customer\Model\Session;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Registry;
use VendoreName\Rma\Api\Repository\RmaRepositoryInterface;
use VendoreName\Rma\Api\Service\Rma\RmaManagement\SaveInterface;
use VendoreName\Rma\Helper\Controller\Rma\GuestStrategy;
use VendoreName\Rma\Helper\Controller\Rma\StrategyFactory;
use VendoreName\Rma\Service\Config\FrontendConfig;
use VendoreName\RmaPdfPrint\Block\DownloadRmaPdf;

class PrintAction extends \Magento\Framework\App\Action\Action;
{
    protected $rmaData;

    private $guestStrategy;
    private $rmaRepository;
    private $rmaSaveManagement;
    private $registry;

    public function __construct(
        Context $context,
        GuestStrategy $guestStrategy,
        RmaRepositoryInterface $rmaRepository,
        SaveInterface $rmaSaveManagement,
        Registry $registry,
        StrategyFactory $strategyFactory,
        Session $customerSession,
        FrontendConfig $frontendConfig,
        DownloadRmaPdf $rmaData
    ) {
        $this->guestStrategy     = $guestStrategy;
        $this->rmaRepository     = $rmaRepository;
        $this->rmaSaveManagement = $rmaSaveManagement;
        $this->registry          = $registry;
        $this->rmaData           = $rmaData;
        parent::__construct($context);
    }

    public function execute()
    {
        $rma = $this->getRequest()->getPost();
        $this->registry->register('current_rma', $rma);
        $this->rmaSaveManagement->markAsReadForCustomer($rma);
        $pdf = $this->rmaData->getPdf($rma); // Here We set RMA Data
        $pdf->render();
        $pdfData = $pdf->render();

        header('Content-type: application/pdf');
        header('Content-Disposition: inline; filename=result.pdf');
        header('Content-Transfer-Encoding: binary');
        header('Accept-Ranges: bytes');

        echo $pdfData;
    }
}

Must Open link whole code are in the file

Not the answer you're looking for? Browse other questions tagged or ask your own question.