Generate pdf file from pdf string and image string content in Magento 2
here we will learn, how to generate pdf file if you have string data of pdf and image.
public function generatePdf()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$labelGenerator = $objectManager->create('Magento\Shipping\Model\Shipping\LabelGenerator');
$labelContent[] = base64_decode((string) $imageString); //you can add more image strings.
$outputPdf = $labelGenerator->combineLabelsPdf($labelContent);
$fileFactory = $objectManager->create('Magento\Framework\App\Response\Http\FileFactory');
return $fileFactory->create(
'Labels.pdf',
$outputPdf->render(),
\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR,
'application/pdf'
);
}
By calling this function you can generate pdf file from string content.
Categories:
Magento2
Tags:
Create pdf file from image string content generate pdf Generate pdf from string Magento 2 create pdf file from string
View Comments
Comment or Ask a Question
Quick Links