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-02-01 13:50:25 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d27a14b578b8fa4411253a5875c819a2f5c4f9cc
d27a14b5
1 parent
421183ae
Improve PdfRect
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
25 deletions
pdf/CHANGELOG.md
pdf/lib/src/annotation.dart
pdf/lib/src/font.dart
pdf/lib/src/outline.dart
pdf/lib/src/rect.dart
pdf/test/complex_test.dart
pdf/test/ttf_test.dart
pdf/test/type1_test.dart
pdf/CHANGELOG.md
View file @
d27a14b
# 1.2.0
*
Change license to Apache 2.0
*
Improve PdfRect
# 1.1.1
*
Improve PdfPoint and PdfRect
...
...
pdf/lib/src/annotation.dart
View file @
d27a14b
...
...
@@ -84,7 +84,7 @@ class PdfAnnot extends PdfObject {
params
[
"/Subtype"
]
=
PdfStream
.
string
(
subtype
);
params
[
"/Rect"
]
=
PdfStream
.
string
(
"[
${srcRect.l
}
${srcRect.b}
${srcRect.r}
${srcRect.t
}
]"
);
"[
${srcRect.l
eft}
${srcRect.bottom}
${srcRect.right}
${srcRect.top
}
]"
);
// handle the border
if
(
border
==
null
)
{
...
...
@@ -103,7 +103,7 @@ class PdfAnnot extends PdfObject {
dests
.
add
(
PdfStream
.
string
(
"/Fit"
));
else
{
dests
.
add
(
PdfStream
.
string
(
"/FitR
${destRect.l
}
${destRect.b}
${destRect.r}
${destRect.t
}
"
));
"/FitR
${destRect.l
eft}
${destRect.bottom}
${destRect.right}
${destRect.top
}
"
));
}
params
[
"/Dest"
]
=
PdfStream
.
array
(
dests
);
}
...
...
pdf/lib/src/font.dart
View file @
d27a14b
...
...
@@ -63,15 +63,15 @@ class PdfFont extends PdfObject {
var
r
=
glyphBounds
(
c
);
var
x
=
r
.
x
;
var
y
=
r
.
y
;
var
h
=
r
.
h
;
var
w
=
n
==
chars
.
length
-
1
?
r
.
w
:
glyphAdvance
(
c
);
var
h
=
r
.
height
;
var
w
=
n
==
chars
.
length
-
1
?
r
.
width
:
glyphAdvance
(
c
);
while
(++
n
<
chars
.
length
)
{
c
=
chars
[
n
];
r
=
glyphBounds
(
c
);
if
(
r
.
y
<
y
)
y
=
r
.
y
;
if
(
r
.
h
>
h
)
h
=
r
.
h
;
w
+=
n
==
chars
.
length
-
1
?
r
.
w
:
glyphAdvance
(
c
);
if
(
r
.
height
>
h
)
h
=
r
.
height
;
w
+=
n
==
chars
.
length
-
1
?
r
.
width
:
glyphAdvance
(
c
);
}
return
PdfRect
(
x
,
y
,
w
,
h
);
...
...
@@ -85,7 +85,7 @@ class PdfFont extends PdfObject {
for
(
var
c
in
chars
)
{
var
r
=
glyphBounds
(
c
);
if
(
r
.
h
>
h
)
h
=
r
.
h
;
if
(
r
.
h
eight
>
h
)
h
=
r
.
height
;
w
+=
glyphAdvance
(
c
);
}
...
...
pdf/lib/src/outline.dart
View file @
d27a14b
...
...
@@ -92,8 +92,8 @@ class PdfOutline extends PdfObject {
if
(
destMode
==
PdfOutlineMode
.
fitpage
)
{
dests
.
add
(
PdfStream
.
string
(
"/Fit"
));
}
else
{
dests
.
add
(
PdfStream
.
string
(
"/FitR
${rect.l}
${rect.b}
${rect.r}
${rect.t}
"
));
dests
.
add
(
PdfStream
.
string
(
"/FitR
${rect.left}
${rect.bottom}
${rect.right}
${rect.top}
"
));
}
params
[
"/Parent"
]
=
parent
.
ref
();
params
[
"/Dest"
]
=
PdfStream
.
array
(
dests
);
...
...
pdf/lib/src/rect.dart
View file @
d27a14b
...
...
@@ -18,11 +18,11 @@ part of pdf;
@immutable
class
PdfRect
{
final
double
x
,
y
,
w
,
h
;
final
double
x
,
y
,
w
idth
,
height
;
static
const
zero
=
PdfRect
(
0.0
,
0.0
,
0.0
,
0.0
);
const
PdfRect
(
this
.
x
,
this
.
y
,
this
.
w
,
this
.
h
);
const
PdfRect
(
this
.
x
,
this
.
y
,
this
.
w
idth
,
this
.
height
);
factory
PdfRect
.
fromLTRB
(
double
left
,
double
top
,
double
right
,
double
bottom
)
{
...
...
@@ -33,23 +33,36 @@ class PdfRect {
return
PdfRect
(
offset
.
x
,
offset
.
y
,
size
.
x
,
size
.
y
);
}
double
get
l
=>
x
;
double
get
b
=>
y
;
double
get
r
=>
x
+
w
;
double
get
t
=>
y
+
h
;
double
get
left
=>
x
;
double
get
bottom
=>
y
;
double
get
right
=>
x
+
width
;
double
get
top
=>
y
+
height
;
@deprecated
double
get
l
=>
left
;
@deprecated
double
get
b
=>
bottom
;
@deprecated
double
get
r
=>
right
;
@deprecated
double
get
t
=>
top
;
@deprecated
double
get
w
=>
width
;
@deprecated
double
get
h
=>
height
;
@override
String
toString
()
=>
"PdfRect(
$x
,
$y
,
$w
,
$h
)"
;
String
toString
()
=>
"PdfRect(
$x
,
$y
,
$w
idth
,
$height
)"
;
PdfRect
operator
*(
double
factor
)
{
return
PdfRect
(
x
*
factor
,
y
*
factor
,
w
*
factor
,
h
*
factor
);
return
PdfRect
(
x
*
factor
,
y
*
factor
,
w
idth
*
factor
,
height
*
factor
);
}
PdfPoint
get
offset
=>
PdfPoint
(
x
,
y
);
PdfPoint
get
size
=>
PdfPoint
(
w
,
h
);
PdfPoint
get
size
=>
PdfPoint
(
w
idth
,
height
);
PdfPoint
get
topLeft
=>
PdfPoint
(
x
,
y
);
PdfPoint
get
topRight
=>
PdfPoint
(
r
,
y
);
PdfPoint
get
bottomLeft
=>
PdfPoint
(
x
,
t
);
PdfPoint
get
bottomRight
=>
PdfPoint
(
r
,
t
);
PdfPoint
get
topRight
=>
PdfPoint
(
right
,
y
);
PdfPoint
get
bottomLeft
=>
PdfPoint
(
x
,
top
);
PdfPoint
get
bottomRight
=>
PdfPoint
(
right
,
top
);
}
...
...
pdf/test/complex_test.dart
View file @
d27a14b
...
...
@@ -70,7 +70,7 @@ void main() {
var
r
=
font2
.
stringBounds
(
s
);
const
FS
=
20.0
;
g
.
setColor
(
PdfColor
(
0.0
,
1.0
,
1.0
));
g
.
drawRect
(
50.0
+
r
.
x
*
FS
,
30.0
+
r
.
y
*
FS
,
r
.
w
*
FS
,
r
.
h
*
FS
);
g
.
drawRect
(
50.0
+
r
.
x
*
FS
,
30.0
+
r
.
y
*
FS
,
r
.
w
idth
*
FS
,
r
.
height
*
FS
);
g
.
fillPath
();
g
.
setColor
(
PdfColor
(
0.3
,
0.3
,
0.3
));
g
.
drawString
(
font2
,
FS
,
s
,
50.0
,
30.0
);
...
...
pdf/test/ttf_test.dart
View file @
d27a14b
...
...
@@ -35,7 +35,7 @@ void main() {
var
r
=
ttf
.
stringBounds
(
s
);
const
FS
=
20.0
;
g
.
setColor
(
PdfColor
(
0.0
,
1.0
,
1.0
));
g
.
drawRect
(
50.0
+
r
.
x
*
FS
,
30.0
+
r
.
y
*
FS
,
r
.
w
*
FS
,
r
.
h
*
FS
);
g
.
drawRect
(
50.0
+
r
.
x
*
FS
,
30.0
+
r
.
y
*
FS
,
r
.
w
idth
*
FS
,
r
.
height
*
FS
);
g
.
fillPath
();
g
.
setColor
(
PdfColor
(
0.3
,
0.3
,
0.3
));
g
.
drawString
(
ttf
,
FS
,
s
,
50.0
,
30.0
);
...
...
@@ -48,7 +48,7 @@ void main() {
r
=
roboto
.
stringBounds
(
s
);
g
.
setColor
(
PdfColor
(
0.0
,
1.0
,
1.0
));
g
.
drawRect
(
50.0
+
r
.
x
*
FS
,
130.0
+
r
.
y
*
FS
,
r
.
w
*
FS
,
r
.
h
*
FS
);
g
.
drawRect
(
50.0
+
r
.
x
*
FS
,
130.0
+
r
.
y
*
FS
,
r
.
w
idth
*
FS
,
r
.
height
*
FS
);
g
.
fillPath
();
g
.
setColor
(
PdfColor
(
0.3
,
0.3
,
0.3
));
g
.
drawString
(
roboto
,
FS
,
s
,
50.0
,
130.0
);
...
...
pdf/test/type1_test.dart
View file @
d27a14b
...
...
@@ -25,7 +25,7 @@ void printText(PdfGraphics g, String text, PdfFont font, double top) {
const
FS
=
20.0
;
g
.
setColor
(
PdfColor
(
0.9
,
0.9
,
0.9
));
g
.
drawRect
(
50.0
+
r
.
x
*
FS
,
g
.
page
.
pageFormat
.
height
-
top
+
r
.
y
*
FS
,
r
.
w
*
FS
,
r
.
h
*
FS
);
r
.
w
idth
*
FS
,
r
.
height
*
FS
);
g
.
fillPath
();
g
.
setColor
(
PdfColor
(
0.3
,
0.3
,
0.3
));
g
.
drawString
(
font
,
FS
,
text
,
50.0
,
g
.
page
.
pageFormat
.
height
-
top
);
...
...
Please
register
or
login
to post a comment