PHP code example of heimrichhannot / contao-pdf-creator-bundle

1. Go to this page and download the library: Download heimrichhannot/contao-pdf-creator-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/ */

    

heimrichhannot / contao-pdf-creator-bundle example snippets


    use Heimrichhannot\PdfCreatorBundle\Generator\PdfGenerator;
    use Heimrichhannot\PdfCreatorBundle\Generator\PdfGeneratorContext;
    
    class ExportCustomEntity {
        /**@var PdfGenerator */
        protected $pdfGenerator;
        
        public function __invoke(string $content, array $row): void {
            $context = new PdfGeneratorContext($row['title']);
            $result = $this->pdfGenerator->generate($content, $row['pdfConfiguration'], $context);
            
        }
    }
    

    use Contao\CoreBundle\DataContainer\PaletteManipulator;
    use Heimrichhannot\PdfCreatorBundle\Generator\DcaGenerator;
    
    class LoadDataContainerListener {
        /** @var DcaGenerator */
        protected $dcaGenerator;
        
        public function __invoke(string $table): void
        {
            if ('tl_custom_dca' === $table) {
                PaletteManipulator::create()->addField('pdfConfiguration', 'someField')->applyToPalette('default', 'tl_custom_entity');
                $GLOBALS['TL_DCA']['tl_custom_entity']['fields']['pdfConfiguration'] = $this->dcaGenerator->getPdfCreatorConfigSelectFieldConfig();
            }
        }
    }
    
yaml 
huh_pdf_creator:
    allowed_paths:
        - web
        - public
        - files
        - assets