Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2020-12-13 09:11:44 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dc8da34e18b9d458fa4503252fff5b7033375462
dc8da34e
1 parent
e08669ae
Fix Printing on WEB
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
10 deletions
printing/CHANGELOG.md
printing/lib/src/printing_web.dart
printing/pubspec.yaml
printing/CHANGELOG.md
View file @
dc8da34
# Changelog
## 3.7.2
-
Fix Printing on WEB
## 3.7.1
-
Fix Pdf Raster on WEB
...
...
printing/lib/src/printing_web.dart
View file @
dc8da34
...
...
@@ -70,19 +70,16 @@ class PrintingPlugin extends PrintingPlatform {
return
false
;
}
final
String
userAgent
=
js
.
context
[
'navigator'
][
'userAgent'
];
final
isChrome
=
js
.
context
[
'chrome'
]
!=
null
;
final
isSafari
=
js
.
context
[
'safari'
]
!=
null
;
// Maybe Firefox 75 will support iframe printing
final
isMobile
=
userAgent
.
contains
(
'Mobile'
);
// Maybe Firefox will support iframe printing
// https://bugzilla.mozilla.org/show_bug.cgi?id=911444
// final isFirefox = userAgent.contains('Firefox');
if
(!
isChrome
&&
!
isSafari
)
{
final
pr
=
'data:application/pdf;base64,
${base64.encode(result)}
'
;
final
html
.
Window
win
=
js
.
context
[
'window'
];
win
.
open
(
pr
,
name
);
return
true
;
}
// Chrome and Safari on a desktop computer
if
((
isChrome
||
isSafari
)
&&
!
isMobile
)
{
final
completer
=
Completer
<
bool
>();
final
pdfFile
=
html
.
Blob
(
<
Uint8List
>[
Uint8List
.
fromList
(
result
)],
...
...
@@ -117,6 +114,21 @@ class PrintingPlugin extends PrintingPlatform {
return
completer
.
future
;
}
// All the others
final
pdfFile
=
html
.
Blob
(
<
Uint8List
>[
Uint8List
.
fromList
(
result
)],
'application/pdf'
,
);
final
pdfUrl
=
html
.
Url
.
createObjectUrl
(
pdfFile
);
final
html
.
HtmlDocument
doc
=
js
.
context
[
'document'
];
final
html
.
AnchorElement
link
=
doc
.
createElement
(
'a'
);
link
.
href
=
pdfUrl
;
link
.
target
=
'_blank'
;
link
.
click
();
link
.
remove
();
return
true
;
}
@override
Future
<
bool
>
sharePdf
(
Uint8List
bytes
,
...
...
@@ -133,6 +145,7 @@ class PrintingPlugin extends PrintingPlatform {
link
.
href
=
pdfUrl
;
link
.
download
=
filename
;
link
.
click
();
link
.
remove
();
return
true
;
}
...
...
printing/pubspec.yaml
View file @
dc8da34
...
...
@@ -4,7 +4,7 @@ description: Plugin that allows Flutter apps to generate and print documents to
homepage
:
https://github.com/DavBfr/dart_pdf/tree/master/printing
repository
:
https://github.com/DavBfr/dart_pdf
issue_tracker
:
https://github.com/DavBfr/dart_pdf/issues
version
:
3.7.
1
version
:
3.7.
2
environment
:
sdk
:
"
>=2.3.0
<3.0.0"
...
...
Please
register
or
login
to post a comment