@geoffreydelumeau

Account created on 11 February 2018, about 7 years ago
#

Recent comments

Hi !
I found that the patch choose_directory_for_saveprintable_function_8.patch of Boazpoolman not worked for my Drupal 9.5.11 version. So I corrected it be able to use it ! Thanks Boazpoolman.

Here is how to use the savePrintable function for saving in a subdirectory :

        $print_engine = \Drupal::service('plugin.manager.entity_print.print_engine')->createSelectedInstance('pdf');
        $print_builder = \Drupal::service('entity_print.print_builder');
        
        $node = \Drupal::entityTypeManager()->getStorage('node')->load($MY_NODE_ID);
        
        // Create a subfolder in the private directory 
        // to save the bill pdf file
        $scheme_directory_pdf = 'private';
        $subdirectory_pdf = 'factures-pdf';

        $filename = 'my-bill-name.pdf';

        // Create the PDF file and save it in the subdirectory
        $pdfUrl = $print_builder->savePrintable([$node], $print_engine, $scheme_irectory_pdf, $filename, TRUE, $subdirectory_pdf);

Thanks !

Production build 0.71.5 2024