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-11-24 08:22:15 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c7d9385ac3c09cf35bb0b93a51c7893e3cbe9602
c7d9385a
1 parent
a77200d7
Rework constructors
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
96 additions
and
44 deletions
pdf/lib/src/annotation.dart
pdf/lib/src/array.dart
pdf/lib/src/border.dart
pdf/lib/src/catalog.dart
pdf/lib/src/font.dart
pdf/lib/src/font_descriptor.dart
pdf/lib/src/object.dart
pdf/lib/src/point.dart
pdf/lib/src/rect.dart
pdf/lib/widgets/text_style.dart
printing/lib/src/widgets.dart
pdf/lib/src/annotation.dart
View file @
c7d9385
...
...
@@ -27,48 +27,78 @@ class PdfAnnot extends PdfObject {
this
.
border
,
this
.
url
,
this
.
name
})
:
super
(
pdfPage
.
pdfDocument
,
type
??
'/Annot'
)
{
:
assert
(
subtype
!=
null
),
super
(
pdfPage
.
pdfDocument
,
type
??
'/Annot'
)
{
pdfPage
.
annotations
.
add
(
this
);
}
/// Creates a text annotation
/// @param rect coordinates
/// @param s Text for this annotation
factory
PdfAnnot
.
text
(
PdfPage
pdfPage
,
{
@required
PdfRect
rect
,
factory
PdfAnnot
.
text
(
PdfPage
pdfPage
,
{
@required
PdfRect
rect
,
@required
String
content
,
PdfBorder
border
})
=>
PdfAnnot
.
_create
(
pdfPage
,
subtype:
'/Text'
,
srcRect:
rect
,
content:
content
,
border:
border
);
PdfBorder
border
,
})
=>
PdfAnnot
.
_create
(
pdfPage
,
subtype:
'/Text'
,
srcRect:
rect
,
content:
content
,
border:
border
,
);
/// Creates a link annotation
/// @param srcRect coordinates
/// @param dest Destination for this link. The page will fit the display.
/// @param destRect Rectangle describing what part of the page to be displayed
/// (must be in User Coordinates)
factory
PdfAnnot
.
link
(
PdfPage
pdfPage
,
{
@required
PdfRect
srcRect
,
factory
PdfAnnot
.
link
(
PdfPage
pdfPage
,
{
@required
PdfRect
srcRect
,
@required
PdfPage
dest
,
PdfRect
destRect
,
PdfBorder
border
})
=>
PdfAnnot
.
_create
(
pdfPage
,
PdfBorder
border
,
})
=>
PdfAnnot
.
_create
(
pdfPage
,
subtype:
'/Link'
,
srcRect:
srcRect
,
dest:
dest
,
destRect:
destRect
,
border:
border
);
border:
border
,
);
/// Creates an external link annotation
factory
PdfAnnot
.
urlLink
(
PdfPage
pdfPage
,
{
@required
PdfRect
rect
,
@required
String
dest
,
PdfBorder
border
})
=>
PdfAnnot
.
_create
(
pdfPage
,
subtype:
'/Link'
,
srcRect:
rect
,
url:
dest
,
border:
border
);
factory
PdfAnnot
.
urlLink
(
PdfPage
pdfPage
,
{
@required
PdfRect
rect
,
@required
String
dest
,
PdfBorder
border
,
})
=>
PdfAnnot
.
_create
(
pdfPage
,
subtype:
'/Link'
,
srcRect:
rect
,
url:
dest
,
border:
border
,
);
/// Creates a link annotation to a named destination
factory
PdfAnnot
.
namedLink
(
PdfPage
pdfPage
,
{
@required
PdfRect
rect
,
@required
String
dest
,
PdfBorder
border
})
=>
PdfAnnot
.
_create
(
pdfPage
,
subtype:
'/Link'
,
srcRect:
rect
,
name:
dest
,
border:
border
);
factory
PdfAnnot
.
namedLink
(
PdfPage
pdfPage
,
{
@required
PdfRect
rect
,
@required
String
dest
,
PdfBorder
border
,
})
=>
PdfAnnot
.
_create
(
pdfPage
,
subtype:
'/Link'
,
srcRect:
rect
,
name:
dest
,
border:
border
,
);
/// The subtype of the outline, ie text, note, etc
final
String
subtype
;
...
...
pdf/lib/src/array.dart
View file @
c7d9385
...
...
@@ -17,7 +17,11 @@
part of
pdf
;
class
PdfArrayObject
extends
PdfObject
{
PdfArrayObject
(
PdfDocument
pdfDocument
,
this
.
values
)
:
super
(
pdfDocument
);
PdfArrayObject
(
PdfDocument
pdfDocument
,
this
.
values
,
)
:
assert
(
values
!=
null
),
super
(
pdfDocument
);
final
List
<
String
>
values
;
...
...
pdf/lib/src/border.dart
View file @
c7d9385
...
...
@@ -44,9 +44,14 @@ class PdfBorder extends PdfObject {
/// @param style The style of the border
/// @param dash The line pattern definition
/// @see [PdfAnnot]
PdfBorder
(
PdfDocument
pdfDocument
,
this
.
width
,
{
this
.
style
=
PdfBorderStyle
.
solid
,
this
.
dash
})
:
super
(
pdfDocument
);
PdfBorder
(
PdfDocument
pdfDocument
,
this
.
width
,
{
this
.
style
=
PdfBorderStyle
.
solid
,
this
.
dash
,
})
:
assert
(
width
!=
null
),
assert
(
style
!=
null
),
super
(
pdfDocument
);
/// The style of the border
final
PdfBorderStyle
style
;
...
...
pdf/lib/src/catalog.dart
View file @
c7d9385
...
...
@@ -23,8 +23,14 @@ class PdfCatalog extends PdfObject {
/// @param pagemode How the document should appear when opened.
/// Allowed values are usenone, useoutlines, usethumbs or fullscreen.
PdfCatalog
(
PdfDocument
pdfDocument
,
this
.
pdfPageList
,
this
.
pageMode
,
this
.
names
)
:
super
(
pdfDocument
,
'/Catalog'
);
PdfDocument
pdfDocument
,
this
.
pdfPageList
,
this
.
pageMode
,
this
.
names
,
)
:
assert
(
pdfPageList
!=
null
),
assert
(
pageMode
!=
null
),
assert
(
names
!=
null
),
super
(
pdfDocument
,
'/Catalog'
);
/// The pages of the document
final
PdfPageList
pdfPageList
;
...
...
pdf/lib/src/font.dart
View file @
c7d9385
...
...
@@ -122,14 +122,12 @@ abstract class PdfFont extends PdfObject {
params
[
'/Encoding'
]
=
PdfStream
.
string
(
'/WinAnsiEncoding'
);
}
// Use glyphMetrics instead
@deprecated
@Deprecated
(
'Use `glyphMetrics` instead'
)
double
glyphAdvance
(
int
charCode
)
=>
glyphMetrics
(
charCode
).
advanceWidth
;
PdfFontMetrics
glyphMetrics
(
int
charCode
);
// Use glyphMetrics instead
@deprecated
@Deprecated
(
'Use `glyphMetrics` instead'
)
PdfRect
glyphBounds
(
int
charCode
)
=>
glyphMetrics
(
charCode
).
toPdfRect
();
PdfFontMetrics
stringMetrics
(
String
s
)
{
...
...
@@ -152,8 +150,7 @@ See https://github.com/DavBfr/dart_pdf/issues/76
}
}
// Use stringMetrics instead
@deprecated
@Deprecated
(
'Use `stringMetrics` instead'
)
PdfRect
stringBounds
(
String
s
)
=>
stringMetrics
(
s
).
toPdfRect
();
PdfPoint
stringSize
(
String
s
)
{
...
...
pdf/lib/src/font_descriptor.dart
View file @
c7d9385
...
...
@@ -17,8 +17,12 @@
part of
pdf
;
class
PdfFontDescriptor
extends
PdfObject
{
PdfFontDescriptor
(
this
.
ttfFont
,
this
.
file
)
:
super
(
ttfFont
.
pdfDocument
,
'/FontDescriptor'
);
PdfFontDescriptor
(
this
.
ttfFont
,
this
.
file
,
)
:
assert
(
ttfFont
!=
null
),
assert
(
file
!=
null
),
super
(
ttfFont
.
pdfDocument
,
'/FontDescriptor'
);
final
PdfObjectStream
file
;
...
...
pdf/lib/src/object.dart
View file @
c7d9385
...
...
@@ -21,7 +21,8 @@ class PdfObject {
/// Pdf Object Type
/// @param type the Pdf Object Type
PdfObject
(
this
.
pdfDocument
,
[
String
type
])
:
objser
=
pdfDocument
.
_genSerial
()
{
:
assert
(
pdfDocument
!=
null
),
objser
=
pdfDocument
.
_genSerial
()
{
if
(
type
!=
null
)
{
params
[
'/Type'
]
=
PdfStream
.
string
(
type
);
}
...
...
pdf/lib/src/point.dart
View file @
c7d9385
...
...
@@ -22,10 +22,10 @@ class PdfPoint {
final
double
x
,
y
;
@
deprecated
@
Deprecated
(
'Use `x` instead'
)
double
get
w
=>
x
;
@
deprecated
@
Deprecated
(
'Use `y` instead'
)
double
get
h
=>
y
;
static
const
PdfPoint
zero
=
PdfPoint
(
0.0
,
0.0
);
...
...
pdf/lib/src/rect.dart
View file @
c7d9385
...
...
@@ -41,17 +41,22 @@ class PdfRect {
double
get
horizondalCenter
=>
x
+
width
/
2
;
double
get
verticalCenter
=>
y
+
height
/
2
;
@
deprecated
@
Deprecated
(
'Use `left` instead'
)
double
get
l
=>
left
;
@deprecated
@Deprecated
(
'Use `bottom` instead'
)
double
get
b
=>
bottom
;
@deprecated
@Deprecated
(
'Use `right` instead'
)
double
get
r
=>
right
;
@deprecated
@Deprecated
(
'Use `top` instead'
)
double
get
t
=>
top
;
@deprecated
@Deprecated
(
'Use `width` instead'
)
double
get
w
=>
width
;
@deprecated
@Deprecated
(
'Use `height` instead'
)
double
get
h
=>
height
;
@override
...
...
pdf/lib/widgets/text_style.dart
View file @
c7d9385
...
...
@@ -343,7 +343,7 @@ class TextStyle {
);
}
@Deprecated
(
'use
font
instead'
)
@Deprecated
(
'use
`font`
instead'
)
Font
get
paintFont
=>
font
;
Font
get
font
{
...
...
printing/lib/src/widgets.dart
View file @
c7d9385
...
...
@@ -16,7 +16,7 @@
part of
printing
;
@
deprecated
@
Deprecated
(
'Use `Document` instead'
)
class
PdfDoc
extends
Document
{
/// Wrapper for a [Document] with zlib compression enabled by default
PdfDoc
(
...
...
Please
register
or
login
to post a comment