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
2019-05-06 06:26:37 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
071f420d5cd7f4c37c7b8660c0a08c691f6db707
071f420d
1 parent
174a1fa9
Convert print screen example to Widgets
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
31 deletions
printing/CHANGELOG.md
printing/example/lib/main.dart
printing/CHANGELOG.md
View file @
071f420
# 2.0.3
*
Add file save and view to example application
*
Convert print screen example to Widgets
# 2.0.2
*
Fix example application
...
...
printing/example/lib/main.dart
View file @
071f420
...
...
@@ -73,41 +73,24 @@ class MyAppState extends State<MyApp> {
print
(
'Print Screen
${im.width}
x
${im.height}
...'
);
Printing
.
layoutPdf
(
onLayout:
(
PdfPageFormat
format
)
{
final
PdfDocument
pdf
=
PdfDocument
(
deflate:
zlib
.
encode
);
final
PdfPage
page
=
PdfPage
(
pdf
,
pageFormat:
format
);
final
PdfGraphics
g
=
page
.
getGraphics
();
// Center the image
final
double
w
=
page
.
pageFormat
.
width
-
page
.
pageFormat
.
marginLeft
-
page
.
pageFormat
.
marginRight
;
final
double
h
=
page
.
pageFormat
.
height
-
page
.
pageFormat
.
marginTop
-
page
.
pageFormat
.
marginBottom
;
double
iw
,
ih
;
if
(
im
.
width
.
toDouble
()
/
im
.
height
.
toDouble
()
<
1.0
)
{
ih
=
h
;
iw
=
im
.
width
.
toDouble
()
*
ih
/
im
.
height
.
toDouble
();
}
else
{
iw
=
w
;
ih
=
im
.
height
.
toDouble
()
*
iw
/
im
.
width
.
toDouble
();
}
final
pdf
.
Document
document
=
PdfDoc
();
final
PdfImage
image
=
PdfImage
(
pdf
,
final
image
=
PdfImage
(
document
.
document
,
image:
bytes
.
buffer
.
asUint8List
(),
width:
im
.
width
,
height:
im
.
height
);
g
.
drawImage
(
image
,
page
.
pageFormat
.
marginLeft
+
(
w
-
iw
)
/
2.0
,
page
.
pageFormat
.
height
-
page
.
pageFormat
.
marginTop
-
ih
-
(
h
-
ih
)
/
2.0
,
iw
,
ih
);
return
pdf
.
save
();
document
.
addPage
(
pdf
.
Page
(
pageFormat:
format
,
build:
(
pdf
.
Context
context
)
{
return
pdf
.
Center
(
child:
pdf
.
Expanded
(
child:
pdf
.
Image
(
image
),
),
);
// Center
}));
// Page
return
document
.
save
();
});
}
...
...
Please
register
or
login
to post a comment