TF-2520 Convert email object to html to perform print on browser
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -91,4 +91,13 @@ class HtmlInteraction {
|
||||
});
|
||||
</script>
|
||||
''';
|
||||
|
||||
static const String scriptHandleInvokePrinterOnBrowser = '''
|
||||
<script type="text/javascript">
|
||||
document.body.onload= function() {
|
||||
document.body.offsetHeight;
|
||||
window.print();
|
||||
};
|
||||
</script>
|
||||
''';
|
||||
}
|
||||
@@ -21,14 +21,47 @@ class HtmlTemplate {
|
||||
}
|
||||
''';
|
||||
|
||||
static const String sampleHtmlDocument = '''
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head>
|
||||
<body</body>
|
||||
</html>
|
||||
static const String printDocumentCssStyle = '''
|
||||
<style>
|
||||
body,td,div,p,a,input {
|
||||
font-family: arial, sans-serif;
|
||||
}
|
||||
|
||||
body, td {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
a:link, a:active {
|
||||
color: #1155CC;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
a:visited{
|
||||
color: #6611CC;
|
||||
}
|
||||
|
||||
img {
|
||||
border: 0px
|
||||
}
|
||||
|
||||
pre {
|
||||
white-space: pre;
|
||||
white-space: -moz-pre-wrap;
|
||||
white-space: -o-pre-wrap;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
max-width: 800px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.logo {
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
''';
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
import 'package:core/data/constants/constant.dart';
|
||||
import 'package:core/presentation/extensions/html_extension.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
class HtmlUtils {
|
||||
static String customCssStyleHtmlEditor({TextDirection direction = TextDirection.ltr}) {
|
||||
@@ -94,4 +96,31 @@ class HtmlUtils {
|
||||
</html>
|
||||
''';
|
||||
}
|
||||
|
||||
static String createTemplateHtmlDocument({String? title}) {
|
||||
return '''
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
${title != null ? '<title>$title</title>' : ''}
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
''';
|
||||
}
|
||||
|
||||
static String generateSVGImageData(String base64Data) => 'data:image/svg+xml;base64,$base64Data';
|
||||
|
||||
static void openNewTabHtmlDocument(String htmlDocument) {
|
||||
final blob = html.Blob([htmlDocument], Constant.textHtmlMimeType);
|
||||
|
||||
final url = html.Url.createObjectUrlFromBlob(blob);
|
||||
|
||||
html.window.open(url, '_blank');
|
||||
|
||||
html.Url.revokeObjectUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user