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
2023-07-24 08:57:18 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
90ad7680b75d53fce3ef9793d2b46c2eb1f30c9f
90ad7680
1 parent
9d3ca6a4
Fix readme tests
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
pdf/README.md
test/extract_readme.dart
pdf/README.md
View file @
90ad768
...
...
@@ -79,18 +79,21 @@ Create a Uint8List from the image
final
img
=
await
rootBundle
.
load
(
'assets/images/logo.jpg'
);
final
imageBytes
=
img
.
buffer
.
asUint8List
();
```
Create an image from the ImageBytes
```
dart
pw
.
Image
image
=
pw
.
Image
(
pw
.
MemoryImage
(
imageBytes
));
pw
.
Image
image
1
=
pw
.
Image
(
pw
.
MemoryImage
(
imageBytes
));
```
implement the image in a container
```
dart
pw
.
Container
(
alignment:
pw
.
Alignment
.
center
,
height:
200
,
child:
image
,
),
child:
image1
,
);
```
To load an image from the network using the
`printing`
package:
...
...
@@ -191,7 +194,7 @@ To save the pdf file (Web):
var
savedFile
=
await
pdf
.
save
();
List
<
int
>
fileInts
=
List
.
from
(
savedFile
);
html
.
AnchorElement
(
href:
"data:application/octet-stream;charset=utf-16le;base64,
${
con.
base64.encode(fileInts)}
"
)
href:
"data:application/octet-stream;charset=utf-16le;base64,
${base64.encode(fileInts)}
"
)
..
setAttribute
(
"download"
,
"
${DateTime.now().millisecondsSinceEpoch}
.pdf"
)
..
click
();
```
...
...
test/extract_readme.dart
View file @
90ad768
...
...
@@ -48,11 +48,15 @@ void buildFile(String src, String dest, bool flutter) {
final
output
=
File
(
dest
);
final
st
=
output
.
openWrite
();
st
.
writeln
(
'// ignore_for_file: avoid_web_libraries_in_flutter'
);
st
.
writeln
(
'import
\'
dart:io
\'
;'
);
st
.
writeln
(
'import
\'
dart:typed_data
\'
;'
);
if
(
flutter
)
{
st
.
writeln
(
'import
\'
package:flutter/services.dart
\'
show rootBundle;'
);
if
(
flutter
)
{
st
.
writeln
(
'import
\'
package:path_provider/path_provider.dart
\'
;'
);
}
else
{
st
.
writeln
(
'import
\'
dart:convert
\'
;'
);
st
.
writeln
(
'import
\'
dart:html
\'
as html;'
);
}
st
.
writeln
(
'import
\'
package:printing/printing.dart
\'
;'
);
st
.
writeln
(
'import
\'
package:pdf/pdf.dart
\'
;'
);
...
...
Please
register
or
login
to post a comment