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
Garrett
2022-05-16 14:20:46 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
David PHAM-VAN
2022-05-19 17:59:59 -0300
Commit
a48077ae2b5f272acd5e6719c0fdff0e8e126f59
a48077ae
1 parent
9ac0db40
Wrapped cleanup of page and destory of document in try/finally blocks
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
printing/lib/printing_web.dart
printing/lib/printing_web.dart
View file @
a48077a
...
...
@@ -290,7 +290,7 @@ class PrintingPlugin extends PrintingPlatform {
await
_initPlugin
();
final
t
=
PdfJs
.
getDocument
(
Settings
()..
data
=
document
);
try
{
final
d
=
await
promiseToFuture
<
PdfJsDoc
>(
t
.
promise
);
final
numPages
=
d
.
numPages
;
...
...
@@ -298,10 +298,12 @@ class PrintingPlugin extends PrintingPlatform {
js
.
context
[
'document'
].
createElement
(
'canvas'
);
final
context
=
canvas
.
getContext
(
'2d'
)
as
html
.
CanvasRenderingContext2D
?;
final
_pages
=
pages
??
Iterable
<
int
>.
generate
(
numPages
,
(
index
)
=>
index
);
final
_pages
=
pages
??
Iterable
<
int
>.
generate
(
numPages
,
(
index
)
=>
index
);
for
(
final
i
in
_pages
)
{
final
page
=
await
promiseToFuture
<
PdfJsPage
>(
d
.
getPage
(
i
+
1
));
try
{
final
viewport
=
page
.
getViewport
(
Settings
()..
scale
=
dpi
/
PdfPageFormat
.
inch
);
...
...
@@ -333,10 +335,14 @@ class PrintingPlugin extends PrintingPlatform {
canvas
.
height
!,
data
.
toBytes
(),
);
}
finally
{
page
.
cleanup
();
}
}
}
finally
{
t
.
destroy
();
}
}
}
class
_WebPdfRaster
extends
PdfRaster
{
...
...
Please
register
or
login
to post a comment