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-09-09 08:19:40 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9549cf52b766d7cff7ea7537a9efedaa74f14578
9549cf52
1 parent
66748cb7
Update the example to use PdfPreview
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
28 deletions
printing/CHANGELOG.md
printing/README.md
printing/example/lib/main.dart
printing/pubspec.yaml
printing/CHANGELOG.md
View file @
9549cf5
# Changelog
## 3.6.1
-
Update the example to use PdfPreview
## 3.6.0
-
Added pdfFileName prop to PdfPreview Widget
[
Marcos Rodriguez
]
...
...
printing/README.md
View file @
9549cf5
...
...
@@ -134,6 +134,23 @@ final pdf = await rootBundle.load('document.pdf');
await
Printing
.
layoutPdf
(
onLayout:
(
_
)
=>
pdf
.
buffer
.
asUint8List
());
```
## Designing your PDF document
A good starting point is to use PdfPreview which features hot-reload pdf build
and refresh.
Take a look at the
[
example tab
](
example
)
for a sample project.
This widget also features a debug switch at the bottom right to display the
drawing constraints used. This switch is available only on debug builds.
Moving on to your production application, you can keep only the
`_generatePdf`
function and print the document using:
```
dart
await
Printing
.
layoutPdf
(
onLayout:
(
format
)
=>
_generatePdf
(
format
,
title
));
```
## Encryption and Digital Signature
Encryption using RC4-40, RC4-128, AES-128, and AES-256 is fully supported using a separate library.
...
...
printing/example/lib/main.dart
View file @
9549cf5
// ignore_for_file: always_specify_types
// ignore_for_file: public_member_api_docs
import
'dart:typed_data'
;
import
'package:flutter/material.dart'
;
import
'package:pdf/pdf.dart'
;
import
'package:pdf/widgets.dart'
as
pw
;
import
'package:printing/printing.dart'
;
void
main
(
)
=>
runApp
(
MyApp
(
));
void
main
(
)
=>
runApp
(
const
MyApp
(
'Printing Demo'
));
class
MyApp
extends
StatelessWidget
{
const
MyApp
(
this
.
title
);
final
String
title
;
@override
Widget
build
(
BuildContext
context
)
{
const
title
=
'Printing Demo'
;
return
MaterialApp
(
title:
title
,
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
title
),
),
body:
Center
(
child:
IconButton
(
icon:
const
Icon
(
Icons
.
print
),
onPressed:
_printDocument
,
),
appBar:
AppBar
(
title:
Text
(
title
)),
body:
PdfPreview
(
build:
(
format
)
=>
_generatePdf
(
format
,
title
),
),
),
);
}
void
_printDocument
()
{
Printing
.
layoutPdf
(
onLayout:
(
pageFormat
)
{
final
doc
=
pw
.
Document
();
doc
.
addPage
(
pw
.
Page
(
build:
(
pw
.
Context
context
)
=>
pw
.
Center
(
child:
pw
.
Text
(
'Hello World!'
),
),
),
);
return
doc
.
save
();
},
Future
<
Uint8List
>
_generatePdf
(
PdfPageFormat
format
,
String
title
)
async
{
final
pdf
=
pw
.
Document
();
pdf
.
addPage
(
pw
.
Page
(
pageFormat:
format
,
build:
(
context
)
{
return
pw
.
Center
(
child:
pw
.
Text
(
title
),
);
},
),
);
return
pdf
.
save
();
}
}
...
...
printing/pubspec.yaml
View file @
9549cf5
...
...
@@ -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.6.
0
version
:
3.6.
1
environment
:
sdk
:
"
>=2.3.0
<3.0.0"
...
...
Please
register
or
login
to post a comment