David PHAM-VAN

Fix readme tests

... ... @@ -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 image1 = 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();
```
... ...
... ... @@ -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\';');
... ...