The module is working as expected with no issues as far as I know, but currently when i click on the https://example.com/entityprint/pdf/node/15, a pdf file of the /node/15 is directly downloaded and saved locally/offline on my computer/mobile phone !

I would like to know if there is a method to programmatically or via UI, save the pdf file online on my server for example under: /web/sites/default/files/pdf directory.

any help please ?

Thank you,

Comments

C.E.A created an issue. See original summary.

c.e.a’s picture

Issue summary: View changes
c.e.a’s picture

Issue summary: View changes
trentwyman’s picture

I'm trying to figure this out as well. I've got a use case where members of groups can download PDF documents, but after leaving the group the PDF file is no longer available to the user for future reference. I need to find a way to also allow users to SAVE the PDF to their user files folder in Drupal (on the server), in addition to the standard print-on-demand download functionality (which is working as expected).

canardesign’s picture

Subscribing. Same need here, would be interested in saving multiple PDF files programmatically.

z3cka’s picture

You can use the entity_print.print_builder service to save the rendered pdf. My use case was a little different, as I just needed to save the file to the temp directory and attach it to an outgoing email, but it is similar:

  // generate invoice PDF from Order
  $print_engine = \Drupal::service('plugin.manager.entity_print.print_engine')->createSelectedInstance('pdf');
  $print_builder = \Drupal::service('entity_print.print_builder');

  $order = $message['params']['order'];
  $filename = 'inv' . $order->get('order_number')->value .'.pdf';

  $uri = $print_builder->savePrintable(
    [$order],
    $print_engine,
    'temporary',
    $filename,
  );

You would need to swap out $order for your desired entity that you would like saved as a printable pdf and change the file scheme/filename to match your needs. See the PrintBuilderInterface->savePrintable() source for more details on the above code. For more context see comment #45 and discussion on #2831952: Create an entity_print renderer for orders (to allow order PDF output).

Good luck!