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-10 07:08:27 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6358631c3f2e223fd2f3fbd140d85e56d9c40a20
6358631c
1 parent
99a76d57
Add more information about PdfPreview
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletions
printing/README.md
printing/README.md
View file @
6358631
...
...
@@ -134,6 +134,28 @@ final pdf = await rootBundle.load('document.pdf');
await
Printing
.
layoutPdf
(
onLayout:
(
_
)
=>
pdf
.
buffer
.
asUint8List
());
```
## Display your PDF document
This package also comes with a PdfPreview widget to display a pdf document.
```
dart
PdfPreview
(
build:
(
format
)
=>
doc
.
save
(),
);
```
This widget is compatible with Android, iOS, macOS and web.
For the web, a javascript library and a small script has to be added to
your
`web/index.html`
file:
```
html
<script
src=
"//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.4.456/pdf.min.js"
></script>
<script
type=
"text/javascript"
>
pdfjsLib
.
GlobalWorkerOptions
.
workerSrc
=
"//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.4.456/pdf.worker.min.js"
;
</script>
```
## Designing your PDF document
A good starting point is to use PdfPreview which features hot-reload pdf build
...
...
@@ -161,7 +183,7 @@ Future<Uint8List> _generatePdf(PdfPageFormat format, String title) async {
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`
Moving on to your production application, you can keep the
`_generatePdf`
function and print the document using:
```
dart
...
...
Please
register
or
login
to post a comment