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
2018-08-11 07:22:36 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1771608218138d0751902d78be925413ce6baadf
17716082
1 parent
c11fb7e8
Move files to the pdf sub-folder
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
70 additions
and
55 deletions
.gitignore
README.md
CHANGELOG.md → pdf/CHANGELOG.md
LICENSE → pdf/LICENSE
pdf/README.md
example/main.dart → pdf/example/main.dart
lib/pdf.dart → pdf/lib/pdf.dart
lib/src/annotation.dart → pdf/lib/src/annotation.dart
lib/src/array.dart → pdf/lib/src/array.dart
lib/src/ascii85.dart → pdf/lib/src/ascii85.dart
lib/src/border.dart → pdf/lib/src/border.dart
lib/src/catalog.dart → pdf/lib/src/catalog.dart
lib/src/color.dart → pdf/lib/src/color.dart
lib/src/document.dart → pdf/lib/src/document.dart
lib/src/font.dart → pdf/lib/src/font.dart
lib/src/font_descriptor.dart → pdf/lib/src/font_descriptor.dart
lib/src/formxobject.dart → pdf/lib/src/formxobject.dart
lib/src/graphics.dart → pdf/lib/src/graphics.dart
lib/src/image.dart → pdf/lib/src/image.dart
lib/src/info.dart → pdf/lib/src/info.dart
lib/src/object.dart → pdf/lib/src/object.dart
lib/src/object_stream.dart → pdf/lib/src/object_stream.dart
lib/src/outline.dart → pdf/lib/src/outline.dart
lib/src/output.dart → pdf/lib/src/output.dart
lib/src/page.dart → pdf/lib/src/page.dart
lib/src/page_format.dart → pdf/lib/src/page_format.dart
lib/src/page_list.dart → pdf/lib/src/page_list.dart
lib/src/point.dart → pdf/lib/src/point.dart
lib/src/polygon.dart → pdf/lib/src/polygon.dart
lib/src/rect.dart → pdf/lib/src/rect.dart
lib/src/stream.dart → pdf/lib/src/stream.dart
lib/src/ttf_parser.dart → pdf/lib/src/ttf_parser.dart
lib/src/ttffont.dart → pdf/lib/src/ttffont.dart
lib/src/xobject.dart → pdf/lib/src/xobject.dart
lib/src/xref.dart → pdf/lib/src/xref.dart
pubspec.yaml → pdf/pubspec.yaml
test/pdf_test.dart → pdf/test/complex_test.dart
test/pdf1_test.dart → pdf/test/minimal_test.dart
test/ttf_test.dart → pdf/test/ttf_test.dart
.gitignore
View file @
1771608
...
...
@@ -11,3 +11,4 @@ pubspec.lock
doc/api/
*.pdf
*.ttf
...
...
README.md
View file @
1771608
# Pdf
creation library for dart / f
lutter
# Pdf
for Dart and F
lutter
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
);
```
...
...
CHANGELOG.md →
pdf/
CHANGELOG.md
View file @
1771608
LICENSE →
pdf/
LICENSE
View file @
1771608
pdf/README.md
0 → 100644
View file @
1771608
# 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
);
```
...
...
example/main.dart →
pdf/
example/main.dart
View file @
1771608
...
...
@@ -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
(
'
fi
le.pdf'
);
var
file
=
new
File
(
'
examp
le.pdf'
);
file
.
writeAsBytesSync
(
pdf
.
save
());
}
...
...
lib/pdf.dart →
pdf/
lib/pdf.dart
View file @
1771608
lib/src/annotation.dart →
pdf/
lib/src/annotation.dart
View file @
1771608
lib/src/array.dart →
pdf/
lib/src/array.dart
View file @
1771608
lib/src/ascii85.dart →
pdf/
lib/src/ascii85.dart
View file @
1771608
lib/src/border.dart →
pdf/
lib/src/border.dart
View file @
1771608
lib/src/catalog.dart →
pdf/
lib/src/catalog.dart
View file @
1771608
lib/src/color.dart →
pdf/
lib/src/color.dart
View file @
1771608
lib/src/document.dart →
pdf/
lib/src/document.dart
View file @
1771608
lib/src/font.dart →
pdf/
lib/src/font.dart
View file @
1771608
lib/src/font_descriptor.dart →
pdf/
lib/src/font_descriptor.dart
View file @
1771608
lib/src/formxobject.dart →
pdf/
lib/src/formxobject.dart
View file @
1771608
lib/src/graphics.dart →
pdf/
lib/src/graphics.dart
View file @
1771608
lib/src/image.dart →
pdf/
lib/src/image.dart
View file @
1771608
lib/src/info.dart →
pdf/
lib/src/info.dart
View file @
1771608
lib/src/object.dart →
pdf/
lib/src/object.dart
View file @
1771608
lib/src/object_stream.dart →
pdf/
lib/src/object_stream.dart
View file @
1771608
lib/src/outline.dart →
pdf/
lib/src/outline.dart
View file @
1771608
lib/src/output.dart →
pdf/
lib/src/output.dart
View file @
1771608
lib/src/page.dart →
pdf/
lib/src/page.dart
View file @
1771608
...
...
@@ -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.
...
...
lib/src/page_format.dart →
pdf/
lib/src/page_format.dart
View file @
1771608
...
...
@@ -34,4 +34,6 @@ class PDFPageFormat {
final
double
height
;
const
PDFPageFormat
(
this
.
width
,
this
.
height
);
PDFPoint
get
dimension
=>
new
PDFPoint
(
width
,
height
);
}
...
...
lib/src/page_list.dart →
pdf/
lib/src/page_list.dart
View file @
1771608
lib/src/point.dart →
pdf/
lib/src/point.dart
View file @
1771608
lib/src/polygon.dart →
pdf/
lib/src/polygon.dart
View file @
1771608
lib/src/rect.dart →
pdf/
lib/src/rect.dart
View file @
1771608
lib/src/stream.dart →
pdf/
lib/src/stream.dart
View file @
1771608
lib/src/ttf_parser.dart →
pdf/
lib/src/ttf_parser.dart
View file @
1771608
lib/src/ttffont.dart →
pdf/
lib/src/ttffont.dart
View file @
1771608
lib/src/xobject.dart →
pdf/
lib/src/xobject.dart
View file @
1771608
lib/src/xref.dart →
pdf/
lib/src/xref.dart
View file @
1771608
pubspec.yaml → p
df/p
ubspec.yaml
View file @
1771608
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
:
...
...
test/pdf
_test.dart →
pdf/test/complex
_test.dart
View file @
1771608
...
...
@@ -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!"
;
...
...
test/pdf1
_test.dart →
pdf/test/minimal
_test.dart
View file @
1771608
test/ttf_test.dart →
pdf/
test/ttf_test.dart
View file @
1771608
...
...
@@ -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
(
'file
2
.pdf'
);
file
.
writeAsBytesSync
(
pdf
.
save
());
});
}
...
...
Please
register
or
login
to post a comment