David PHAM-VAN

Move files to the pdf sub-folder

Showing 39 changed files with 70 additions and 55 deletions
... ... @@ -11,3 +11,4 @@ pubspec.lock
doc/api/
*.pdf
*.ttf
... ...
# Pdf creation library for dart / flutter
# Pdf for Dart and Flutter
This is a low-level Pdf creation library.
It can create a full multi-pages document with graphics,
images and text using TrueType fonts.
This set of plugin allows Flutter apps to generate and print pdf files to device printer.
This plugin works for iOS and Android.
The coordinate system is using the internal Pdf system:
* (0.0, 0.0) is bottom-left
* 1.0 is defined as 1 / 72.0 inch
* you can use the constants for centimeters, milimeters and inch defined in PDFPageFormat
Example:
```dart
final pdf = new PDFDocument();
final page = new PDFPage(pdf, pageFormat: PDFPageFormat.LETTER);
final g = page.getGraphics();
final font = new PDFFont(pdf);
g.setColor(new PDFColor(0.0, 1.0, 1.0));
g.drawRect(50.0, 30.0, 100.0, 50.0);
g.fillPath();
g.setColor(new PDFColor(0.3, 0.3, 0.3));
g.drawString(font, 12.0, "Hello World!", 5.0 * PDFPageFormat.MM, 300.0);
var file = new File('file.pdf');
file.writeAsBytesSync(pdf.save());
```
To load an image it is possible to use the dart library `image`
```dart
Image image = decodeImage(new Io.File('test.webp').readAsBytesSync());
PDFImage image = new PDFImage(
pdf,
image: img.data.buffer.asUint8List(),
width: img.width,
height: img.height);
g.drawImage(image, 100.0, 100.0, 80.0);
```
To use a TrueType font:
```dart
PDFTTFFont ttf = new PDFTTFFont(
pdf,
(new File("open-sans.ttf").readAsBytesSync() as Uint8List).buffer.asByteData());
g.setColor(new PDFColor(0.3, 0.3, 0.3));
g.drawString(ttf, 20.0, "Dart is awesome", 50.0, 30.0);
```
... ...
# Pdf creation library for dart / flutter
This is a low-level Pdf creation library.
It can create a full multi-pages document with graphics,
images and text using TrueType fonts.
The coordinate system is using the internal Pdf system:
* (0.0, 0.0) is bottom-left
* 1.0 is defined as 1 / 72.0 inch
* you can use the constants for centimeters, milimeters and inch defined in PDFPageFormat
Example:
```dart
final pdf = new PDFDocument();
final page = new PDFPage(pdf, pageFormat: PDFPageFormat.LETTER);
final g = page.getGraphics();
final font = new PDFFont(pdf);
g.setColor(new PDFColor(0.0, 1.0, 1.0));
g.drawRect(50.0, 30.0, 100.0, 50.0);
g.fillPath();
g.setColor(new PDFColor(0.3, 0.3, 0.3));
g.drawString(font, 12.0, "Hello World!", 5.0 * PDFPageFormat.MM, 300.0);
var file = new File('file.pdf');
file.writeAsBytesSync(pdf.save());
```
To load an image it is possible to use the dart library `image`
```dart
Image image = decodeImage(new Io.File('test.webp').readAsBytesSync());
PDFImage image = new PDFImage(
pdf,
image: img.data.buffer.asUint8List(),
width: img.width,
height: img.height);
g.drawImage(image, 100.0, 100.0, 80.0);
```
To use a TrueType font:
```dart
PDFTTFFont ttf = new PDFTTFFont(
pdf,
(new File("open-sans.ttf").readAsBytesSync() as Uint8List).buffer.asByteData());
g.setColor(new PDFColor(0.3, 0.3, 0.3));
g.drawString(ttf, 20.0, "Dart is awesome", 50.0, 30.0);
```
... ...
... ... @@ -7,14 +7,17 @@ void main() {
final page = new PDFPage(pdf, pageFormat: PDFPageFormat.LETTER);
final g = page.getGraphics();
final font = new PDFFont(pdf);
final top = page.pageFormat.height;
g.setColor(new PDFColor(0.0, 1.0, 1.0));
g.drawRect(50.0, 30.0, 100.0, 50.0);
g.drawRect(50.0 * PDFPageFormat.MM, top - 80.0 * PDFPageFormat.MM, 100.0 * PDFPageFormat.MM,
50.0 * PDFPageFormat.MM);
g.fillPath();
g.setColor(new PDFColor(0.3, 0.3, 0.3));
g.drawString(font, 12.0, "Hello World!", 50.0, 300.0);
g.drawString(
font, 12.0, "Hello World!", 10.0 * PDFPageFormat.MM, top - 10.0 * PDFPageFormat.MM);
var file = new File('file.pdf');
var file = new File('example.pdf');
file.writeAsBytesSync(pdf.save());
}
... ...
... ... @@ -68,12 +68,16 @@ class PDFPage extends PDFObject {
/// Returns the page's PageFormat.
/// @return PageFormat describing the page size in device units (72dpi)
/// use pageFormat
@deprecated
PDFPageFormat getPageFormat() {
return pageFormat;
}
/// Gets the dimensions of the page.
/// @return a Dimension object containing the width and height of the page.
/// use pageFormat.dimension
@deprecated
PDFPoint getDimension() => new PDFPoint(pageFormat.width, pageFormat.height);
/// This adds an Annotation to the page.
... ...
... ... @@ -34,4 +34,6 @@ class PDFPageFormat {
final double height;
const PDFPageFormat(this.width, this.height);
PDFPoint get dimension => new PDFPoint(width, height);
}
... ...
name: pdf
author: David PHAM-VAN <dev.nfet.net@gmail.com>
description: A pdf producer for Dart. It can create pdf files for both web or flutter.
homepage: https://github.com/davbfr/dart_pdf
homepage: https://github.com/davbfr/dart_pdf/pdf
version: 1.0.3
environment:
... ...
... ... @@ -30,7 +30,7 @@ void main() {
var font2 = new PDFTTFFont(
pdf,
(new File("../assets/Nunito-Regular.ttf").readAsBytesSync() as Uint8List)
(new File("open-sans.ttf").readAsBytesSync() as Uint8List)
.buffer
.asByteData());
var s = "Hello World!";
... ...
... ... @@ -17,7 +17,7 @@ void main() {
var g = page.getGraphics();
var ttf = new PDFTTFFont(
pdf,
(new File("../assets/Nunito-Regular.ttf").readAsBytesSync() as Uint8List)
(new File("open-sans.ttf").readAsBytesSync() as Uint8List)
.buffer
.asByteData());
var s = "Hello World!";
... ... @@ -30,7 +30,7 @@ void main() {
g.setColor(new PDFColor(0.3, 0.3, 0.3));
g.drawString(ttf, FS, s, 50.0, 30.0);
var file = new File('file.pdf');
var file = new File('file2.pdf');
file.writeAsBytesSync(pdf.save());
});
}
... ...