public async Task <ActionResult> GeneratePdf(PdfRequest request, string suggestFilename = "generated.pdf", CancellationToken cancellationToken = default) { try { var stream = await _pdfGenerator.GeneratePdfFromHtmlAsync(request, cancellationToken); return(File( stream, MediaTypeNames.Application.Pdf, enableRangeProcessing: true, fileDownloadName: suggestFilename )); } catch (Exception e) { return(Problem(title: "Failed to generate PDF", detail: e.Message, statusCode: StatusCodes.Status503ServiceUnavailable)); } }