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
2019-03-29 14:25:25 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
24e095a71f13775a9d413c7698d56960522cb1ee
24e095a7
1 parent
f1682bdb
Add jpeg image loading function
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
6 deletions
pdf/CHANGELOG.md
pdf/lib/src/image.dart
pdf/pubspec.yaml
pdf/test/jpeg_test.dart
pdf/CHANGELOG.md
View file @
24e095a
# 1.3.8
*
Add jpeg image loading function
# 1.3.7
*
Add Pdf Creation date
*
Support 64k glyphs per TTF font
...
...
pdf/lib/src/image.dart
View file @
24e095a
...
...
@@ -62,6 +62,51 @@ class PdfImage extends PdfXObject {
}
}
factory
PdfImage
.
jpeg
(
PdfDocument
pdfDocument
,
{
@required
Uint8List
image
})
{
assert
(
image
!=
null
);
int
width
;
int
height
;
int
offset
=
0
;
while
(
offset
<
image
.
length
)
{
while
(
image
[
offset
]
==
0xff
)
{
offset
++;
}
final
int
mrkr
=
image
[
offset
];
offset
++;
if
(
mrkr
==
0xd8
)
{
continue
;
// SOI
}
if
(
mrkr
==
0xd9
)
{
break
;
// EOI
}
if
(
0xd0
<=
mrkr
&&
mrkr
<=
0xd7
)
{
continue
;
}
if
(
mrkr
==
0x01
)
{
continue
;
// TEM
}
final
int
len
=
(
image
[
offset
]
<<
8
)
|
image
[
offset
+
1
];
offset
+=
2
;
if
(
mrkr
==
0xc0
)
{
height
=
(
image
[
offset
+
1
]
<<
8
)
|
image
[
offset
+
2
];
width
=
(
image
[
offset
+
3
]
<<
8
)
|
image
[
offset
+
4
];
break
;
}
offset
+=
len
-
2
;
}
return
PdfImage
(
pdfDocument
,
image:
image
,
width:
width
,
height:
height
,
jpeg:
true
,
alpha:
false
);
}
/// RGBA Image Data
final
Uint8List
image
;
...
...
pdf/pubspec.yaml
View file @
24e095a
...
...
@@ -4,7 +4,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl
homepage
:
https://github.com/DavBfr/dart_pdf/tree/master/pdf
repository
:
https://github.com/DavBfr/dart_pdf
issue_tracker
:
https://github.com/DavBfr/dart_pdf/issues
version
:
1.3.
7
version
:
1.3.
8
environment
:
sdk
:
"
>=2.1.0
<3.0.0"
...
...
pdf/test/jpeg_test.dart
View file @
24e095a
...
...
@@ -36,12 +36,10 @@ void main() {
final
PdfDocument
pdf
=
PdfDocument
();
final
PdfPage
page
=
PdfPage
(
pdf
,
pageFormat:
PdfPageFormat
.
a4
);
final
PdfImage
image
=
PdfImage
(
pdf
,
final
PdfImage
image
=
PdfImage
.
jpeg
(
pdf
,
image:
await
download
(
'https://www.nfet.net/nfet.jpg'
),
width:
472
,
height:
477
,
jpeg:
true
,
alpha:
false
);
);
final
PdfGraphics
g
=
page
.
getGraphics
();
g
.
drawImage
(
image
,
30
,
page
.
pageFormat
.
height
-
507.0
);
...
...
Please
register
or
login
to post a comment