TF-2754 Supports PDF viewing on Microsoft EDGE

This commit is contained in:
dab246
2024-04-01 11:34:20 +07:00
committed by Dat H. Pham
parent 133691e082
commit 30c45ef0a1
2 changed files with 36 additions and 12 deletions
+13 -1
View File
@@ -310,6 +310,18 @@ class HtmlUtils {
</html>''';
}
static void openFileViewer({
required Uint8List bytes,
required String fileName,
String? mimeType
}) {
final blob = html.Blob([bytes], mimeType);
final file = html.File([blob], fileName, {'type': mimeType});
final url = html.Url.createObjectUrl(file);
html.window.open(url, '_blank');
html.Url.revokeObjectUrl(url);
}
static const String _pdfContainerStyle = '''
display: flex;
flex-direction: column;
@@ -359,7 +371,7 @@ class HtmlUtils {
<div id="app-bar">
<div id="file-info">
<span id="file-name" style="margin-right: 10px;"></span>
(<span id="file-size", style="white-space: nowrap;"></span>)
(<span id="file-size" style="white-space: nowrap;"></span>)
</div>
<div style="width: 10px;"></div>
<div id="buttons">