diff --git a/fillpdf.services.yml b/fillpdf.services.yml
index cba379a7f08beca60af63e8bd12f27f824fd1af1..5402f8cecd2934cf0c676c25f2f0088555931060 100644
--- a/fillpdf.services.yml
+++ b/fillpdf.services.yml
@@ -23,7 +23,7 @@ services:
 
   fillpdf.output_handler:
     class: Drupal\fillpdf\OutputHandler
-    arguments: ['@fillpdf.token_resolver', '@logger.channel.fillpdf', '@fillpdf.link_manipulator', '@file_system']
+    arguments: ['@fillpdf.token_resolver', '@logger.channel.fillpdf', '@fillpdf.link_manipulator', '@file_system', '@file.repository']
 
   logger.channel.fillpdf:
     parent: logger.channel_base
diff --git a/src/OutputHandler.php b/src/OutputHandler.php
index a83e97f8a7370202f4d95b8afc346cee4dbec838..826fc86a7413791e551861c613342b18e5268923 100644
--- a/src/OutputHandler.php
+++ b/src/OutputHandler.php
@@ -4,6 +4,7 @@ namespace Drupal\fillpdf;
 
 use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Drupal\file\FileInterface;
+use Drupal\file\FileRepositoryInterface;
 use Drupal\fillpdf\Component\Utility\FillPdf;
 use Drupal\fillpdf\Entity\FillPdfFileContext;
 use Psr\Log\LoggerInterface;
@@ -46,6 +47,13 @@ class OutputHandler implements OutputHandlerInterface {
    */
   protected $fileSystem;
 
+  /**
+   * The file.repository service.
+   *
+   * @var \Drupal\file\FileRepositoryInterface
+   */
+  protected $fileRepository;
+
   /**
    * OutputHandler constructor.
    *
@@ -57,12 +65,15 @@ class OutputHandler implements OutputHandlerInterface {
    *   The FillPdf link manipulator.
    * @param \Drupal\Core\File\FileSystemInterface $file_system
    *   The file system.
+   * @param \Drupal\file\FileRepositoryInterface $file_repository
+   *   The file.repository service.
    */
-  public function __construct(TokenResolverInterface $token_resolver, LoggerInterface $logger, FillPdfLinkManipulatorInterface $link_manipulator, FileSystemInterface $file_system) {
+  public function __construct(TokenResolverInterface $token_resolver, LoggerInterface $logger, FillPdfLinkManipulatorInterface $link_manipulator, FileSystemInterface $file_system, FileRepositoryInterface $file_repository) {
     $this->tokenResolver = $token_resolver;
     $this->logger = $logger;
     $this->linkManipulator = $link_manipulator;
     $this->fileSystem = $file_system;
+    $this->fileRepository = $file_repository;
   }
 
   /**
@@ -98,7 +109,7 @@ class OutputHandler implements OutputHandlerInterface {
     }
     else {
       // Full steam ahead!
-      $saved_file = \Drupal::service('file.repository')->writeData($configuration['data'], "{$resolved_destination_path}/{$configuration['filename']}", FileSystemInterface::EXISTS_RENAME);
+      $saved_file = $this->fileRepository->writeData($configuration['data'], "{$resolved_destination_path}/{$configuration['filename']}", FileSystemInterface::EXISTS_RENAME);
       $this->rememberFileContext($saved_file, $configuration['context']);
     }