diff --git a/src/Controller/HandlePdfController.php b/src/Controller/HandlePdfController.php
index 59f7c7529ca813647791ae365a2e009aa50cdbb6..048e0046eefbd5d295884747798020accb5d53c7 100644
--- a/src/Controller/HandlePdfController.php
+++ b/src/Controller/HandlePdfController.php
@@ -199,6 +199,25 @@ class HandlePdfController extends ControllerBase {
     return $this->handlePopulatedPdf($fillpdf_form, $populated_pdf, $context, $filename, $entities);
   }
 
+  /**
+   * Return the token-replaced filename of a populated PDF file.
+   *
+   * Given the same context, this will return the same filename that would be
+   * used in ::populatePdf().
+   *
+   * @param array $context
+   *   The FillPDF context.
+   *
+   * @return string
+   *   The filename.
+   */
+  public function getFilename(array $context): string {
+    $fillpdf_form = FillPdfForm::load($context['fid']);
+    $entities = $this->contextManager->loadEntities($context);
+
+    return $this->buildFilename($fillpdf_form->title->value, $entities);
+  }
+
   /**
    * Builds the filename of a populated PDF file.
    *