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
2023-01-15 08:39:39 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
be71711e442fa014aa59e1534c438c46b13cfdd9
be71711e
1 parent
3a63614b
Fix lints
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
68 additions
and
68 deletions
pdf/CHANGELOG.md
pdf/analysis_options.yaml
pdf/lib/src/pdf/font/bidi_utils.dart
pdf/lib/src/pdf/graphic_state.dart
pdf/lib/src/pdf/obj/border.dart
pdf/lib/src/pdf/obj/font_descriptor.dart
pdf/lib/src/pdf/obj/ttffont.dart
pdf/lib/src/pdf/obj/type1_font.dart
pdf/lib/src/pdf/obj/unicode_cmap.dart
pdf/lib/src/pdf/xref.dart
pdf/lib/src/widgets/flex.dart
pdf/lib/src/widgets/grid_view.dart
pdf/lib/src/widgets/partitions.dart
pdf/lib/src/widgets/placeholders.dart
pdf/lib/src/widgets/table.dart
pdf/lib/src/widgets/text.dart
pdf/lib/src/widgets/wrap.dart
pdf/pubspec.yaml
printing/lib/src/preview/custom.dart
printing/lib/src/preview/page.dart
pdf/CHANGELOG.md
View file @
be71711
...
...
@@ -7,6 +7,7 @@
-
Add Inseparable Widget
-
Fix unit tests
-
Update Image dependency
-
Fix lints
## 3.8.4
...
...
pdf/analysis_options.yaml
View file @
be71711
...
...
@@ -10,6 +10,7 @@ analyzer:
todo
:
ignore
constant_identifier_names
:
ignore
avoid_print
:
ignore
no_leading_underscores_for_local_identifiers
:
ignore
linter
:
rules
:
...
...
pdf/lib/src/pdf/font/bidi_utils.dart
View file @
be71711
...
...
@@ -43,7 +43,7 @@ String logicalToVisual(String input) {
final
buffer
=
StringBuffer
();
final
paragraphs
=
bidi
.
splitStringToParagraphs
(
input
);
for
(
final
paragraph
in
paragraphs
)
{
final
endsWithNewLine
=
paragraph
.
paragraphS
eparator
==
10
;
final
endsWithNewLine
=
paragraph
.
s
eparator
==
10
;
final
endIndex
=
paragraph
.
bidiText
.
length
-
(
endsWithNewLine
?
1
:
0
);
final
visual
=
String
.
fromCharCodes
(
paragraph
.
bidiText
,
0
,
endIndex
);
buffer
.
write
(
visual
.
split
(
' '
).
reversed
.
join
(
' '
));
...
...
pdf/lib/src/pdf/graphic_state.dart
View file @
be71711
...
...
@@ -127,7 +127,7 @@ class PdfGraphicState {
if
(
blendMode
!=
null
)
{
final
bm
=
blendMode
.
toString
();
params
[
'/BM'
]
=
PdfName
(
'/
'
+
bm
.
substring
(
13
,
14
).
toUpperCase
()
+
bm
.
substring
(
14
)
);
PdfName
(
'/
${bm.substring(13, 14).toUpperCase()}${bm.substring(14)}
'
);
}
if
(
softMask
!=
null
)
{
...
...
pdf/lib/src/pdf/obj/border.dart
View file @
be71711
...
...
@@ -63,7 +63,7 @@ class PdfBorder extends PdfObjectDict {
super
.
prepare
();
params
[
'/S'
]
=
PdfName
(
'/
'
+
'SDBIU'
.
substring
(
style
.
index
,
style
.
index
+
1
)
);
PdfName
(
'/
${'SDBIU'.substring(style.index, style.index + 1)}
'
);
params
[
'/W'
]
=
PdfNum
(
width
);
if
(
dash
!=
null
)
{
...
...
pdf/lib/src/pdf/obj/font_descriptor.dart
View file @
be71711
...
...
@@ -37,7 +37,7 @@ class PdfFontDescriptor extends PdfObjectDict {
void
prepare
()
{
super
.
prepare
();
params
[
'/FontName'
]
=
PdfName
(
'/
'
+
ttfFont
.
fontName
);
params
[
'/FontName'
]
=
PdfName
(
'/
${ttfFont.fontName}
'
);
params
[
'/FontFile2'
]
=
file
.
ref
();
params
[
'/Flags'
]
=
PdfNum
(
ttfFont
.
font
.
unicode
?
4
:
32
);
params
[
'/FontBBox'
]
=
PdfArray
.
fromNum
(<
int
>[
...
...
pdf/lib/src/pdf/obj/ttffont.dart
View file @
be71711
...
...
@@ -89,7 +89,7 @@ class PdfTtfFont extends PdfFont {
file
.
buf
.
putBytes
(
font
.
bytes
.
buffer
.
asUint8List
());
file
.
params
[
'/Length1'
]
=
PdfNum
(
font
.
bytes
.
lengthInBytes
);
params
[
'/BaseFont'
]
=
PdfName
(
'/
'
+
fontName
);
params
[
'/BaseFont'
]
=
PdfName
(
'/
$fontName
'
);
params
[
'/FontDescriptor'
]
=
descriptor
.
ref
();
charMin
=
32
;
charMax
=
255
;
...
...
@@ -113,7 +113,7 @@ class PdfTtfFont extends PdfFont {
final
descendantFont
=
PdfDict
({
'/Type'
:
const
PdfName
(
'/Font'
),
'/BaseFont'
:
PdfName
(
'/
'
+
fontName
),
'/BaseFont'
:
PdfName
(
'/
$fontName
'
),
'/FontFile2'
:
file
.
ref
(),
'/FontDescriptor'
:
descriptor
.
ref
(),
'/W'
:
PdfArray
([
...
...
@@ -130,7 +130,7 @@ class PdfTtfFont extends PdfFont {
})
});
params
[
'/BaseFont'
]
=
PdfName
(
'/
'
+
fontName
);
params
[
'/BaseFont'
]
=
PdfName
(
'/
$fontName
'
);
params
[
'/Encoding'
]
=
const
PdfName
(
'/Identity-H'
);
params
[
'/DescendantFonts'
]
=
PdfArray
([
descendantFont
]);
params
[
'/ToUnicode'
]
=
unicodeCMap
.
ref
();
...
...
pdf/lib/src/pdf/obj/type1_font.dart
View file @
be71711
...
...
@@ -59,7 +59,7 @@ class PdfType1Font extends PdfFont {
void
prepare
()
{
super
.
prepare
();
params
[
'/BaseFont'
]
=
PdfName
(
'/
'
+
fontName
);
params
[
'/BaseFont'
]
=
PdfName
(
'/
$fontName
'
);
}
@override
...
...
pdf/lib/src/pdf/obj/unicode_cmap.dart
View file @
be71711
...
...
@@ -51,11 +51,8 @@ class PdfUnicodeCmap extends PdfObjectStream {
for
(
var
key
=
0
;
key
<
cmap
.
length
;
key
++)
{
final
value
=
cmap
[
key
];
buf
.
putString
(
'<'
+
key
.
toRadixString
(
16
).
toUpperCase
().
padLeft
(
4
,
'0'
)
+
'> <'
+
value
.
toRadixString
(
16
).
toUpperCase
().
padLeft
(
4
,
'0'
)
+
'>
\n
'
);
buf
.
putString
(
'<
${key.toRadixString(16).toUpperCase().padLeft(4, '0')}
> <
${value.toRadixString(16).toUpperCase().padLeft(4, '0')}
>
\n
'
);
}
buf
.
putString
(
'endbfchar
\n
'
...
...
pdf/lib/src/pdf/xref.dart
View file @
be71711
...
...
@@ -50,10 +50,7 @@ class PdfXref {
/// The xref in the format of the xref section in the Pdf file
String
ref
()
{
return
offset
.
toString
().
padLeft
(
10
,
'0'
)
+
' '
+
generation
.
toString
().
padLeft
(
5
,
'0'
)
+
(
type
==
PdfCrossRefEntryType
.
inUse
?
' n '
:
' f '
);
return
'
${offset.toString().padLeft(10, '0')}
${generation.toString().padLeft(5, '0')}${type == PdfCrossRefEntryType.inUse ? ' n ' : ' f '}
'
;
}
PdfIndirect
?
get
container
=>
object
==
null
?
null
:
PdfIndirect
(
object
!,
0
);
...
...
pdf/lib/src/widgets/flex.dart
View file @
be71711
...
...
@@ -62,19 +62,19 @@ enum VerticalDirection {
typedef
_ChildSizingFunction
=
double
?
Function
(
Widget
child
,
double
?
extent
);
class
_
FlexContext
extends
WidgetContext
{
class
FlexContext
extends
WidgetContext
{
int
firstChild
=
0
;
int
lastChild
=
0
;
@override
void
apply
(
_
FlexContext
other
)
{
void
apply
(
FlexContext
other
)
{
firstChild
=
other
.
firstChild
;
lastChild
=
other
.
lastChild
;
}
@override
WidgetContext
clone
()
{
return
_
FlexContext
()..
apply
(
this
);
return
FlexContext
()..
apply
(
this
);
}
@override
...
...
@@ -101,7 +101,7 @@ class Flex extends MultiChildWidget with SpanningWidget {
final
VerticalDirection
verticalDirection
;
final
_FlexContext
_context
=
_
FlexContext
();
final
FlexContext
_context
=
FlexContext
();
double
_getIntrinsicSize
(
{
Axis
?
sizingDirection
,
...
...
@@ -502,7 +502,7 @@ class Flex extends MultiChildWidget with SpanningWidget {
bool
get
hasMoreWidgets
=>
true
;
@override
void
restoreContext
(
_
FlexContext
context
)
{
void
restoreContext
(
FlexContext
context
)
{
_context
.
firstChild
=
context
.
lastChild
;
}
...
...
pdf/lib/src/widgets/grid_view.dart
View file @
be71711
...
...
@@ -24,7 +24,7 @@ import 'geometry.dart';
import
'multi_page.dart'
;
import
'widget.dart'
;
class
_
GridViewContext
extends
WidgetContext
{
class
GridViewContext
extends
WidgetContext
{
int
firstChild
=
0
;
int
lastChild
=
0
;
...
...
@@ -32,7 +32,7 @@ class _GridViewContext extends WidgetContext {
double
?
childMainAxis
;
@override
void
apply
(
_
GridViewContext
other
)
{
void
apply
(
GridViewContext
other
)
{
firstChild
=
other
.
firstChild
;
lastChild
=
other
.
lastChild
;
childCrossAxis
=
other
.
childCrossAxis
??
childCrossAxis
;
...
...
@@ -41,7 +41,7 @@ class _GridViewContext extends WidgetContext {
@override
WidgetContext
clone
()
{
return
_
GridViewContext
()..
apply
(
this
);
return
GridViewContext
()..
apply
(
this
);
}
@override
...
...
@@ -67,7 +67,7 @@ class GridView extends MultiChildWidget with SpanningWidget {
final
double
crossAxisSpacing
;
final
double
childAspectRatio
;
final
_GridViewContext
_context
=
_
GridViewContext
();
final
GridViewContext
_context
=
GridViewContext
();
int
?
_mainAxisCount
;
...
...
@@ -331,7 +331,7 @@ class GridView extends MultiChildWidget with SpanningWidget {
bool
get
hasMoreWidgets
=>
true
;
@override
void
restoreContext
(
_
GridViewContext
context
)
{
void
restoreContext
(
GridViewContext
context
)
{
_context
.
apply
(
context
);
_context
.
firstChild
=
context
.
lastChild
;
}
...
...
pdf/lib/src/widgets/partitions.dart
View file @
be71711
...
...
@@ -77,14 +77,14 @@ class Partition extends Widget with SpanningWidget {
bool
get
hasMoreWidgets
=>
child
.
hasMoreWidgets
;
}
class
_PartitionsContext
extends
WidgetContext
{
_PartitionsContext
(
int
count
)
class
PartitionsContext
extends
WidgetContext
{
PartitionsContext
(
int
count
)
:
partitionContext
=
List
<
WidgetContext
?>.
filled
(
count
,
null
);
final
List
<
WidgetContext
?>
partitionContext
;
@override
void
apply
(
_
PartitionsContext
other
)
{
void
apply
(
PartitionsContext
other
)
{
for
(
var
index
=
0
;
index
<
partitionContext
.
length
;
index
++)
{
partitionContext
[
index
]?.
apply
(
other
.
partitionContext
[
index
]!);
}
...
...
@@ -92,7 +92,7 @@ class _PartitionsContext extends WidgetContext {
@override
WidgetContext
clone
()
{
final
context
=
_
PartitionsContext
(
partitionContext
.
length
);
final
context
=
PartitionsContext
(
partitionContext
.
length
);
for
(
var
index
=
0
;
index
<
partitionContext
.
length
;
index
++)
{
context
.
partitionContext
[
index
]
=
partitionContext
[
index
]?.
clone
();
}
...
...
@@ -105,12 +105,12 @@ class Partitions extends Widget with SpanningWidget {
Partitions
({
required
this
.
children
,
this
.
mainAxisSize
=
MainAxisSize
.
max
,
})
:
_context
=
_
PartitionsContext
(
children
.
length
),
})
:
_context
=
PartitionsContext
(
children
.
length
),
super
();
final
List
<
Partition
>
children
;
final
_
PartitionsContext
_context
;
final
PartitionsContext
_context
;
final
MainAxisSize
mainAxisSize
;
...
...
@@ -218,7 +218,7 @@ class Partitions extends Widget with SpanningWidget {
}
@override
void
restoreContext
(
_
PartitionsContext
context
)
{
void
restoreContext
(
PartitionsContext
context
)
{
_context
.
apply
(
context
);
var
index
=
0
;
for
(
final
child
in
children
)
{
...
...
pdf/lib/src/widgets/placeholders.dart
View file @
be71711
...
...
@@ -121,7 +121,7 @@ class LoremText {
}
wordList
.
add
(
w
);
}
final
text
=
wordList
.
join
(
' '
)
+
'
.'
;
final
text
=
'
${wordList.join(' ')}
.'
;
return
text
[
0
].
toUpperCase
()
+
text
.
substring
(
1
);
}
...
...
pdf/lib/src/widgets/table.dart
View file @
be71711
...
...
@@ -136,27 +136,27 @@ class TableBorder extends Border {
}
}
class
_
TableContext
extends
WidgetContext
{
class
TableContext
extends
WidgetContext
{
int
firstLine
=
0
;
int
lastLine
=
0
;
@override
void
apply
(
_
TableContext
other
)
{
void
apply
(
TableContext
other
)
{
firstLine
=
other
.
firstLine
;
lastLine
=
other
.
lastLine
;
}
@override
WidgetContext
clone
()
{
return
_
TableContext
()..
apply
(
this
);
return
TableContext
()..
apply
(
this
);
}
@override
String
toString
()
=>
'
$runtimeType
firstLine:
$firstLine
lastLine:
$lastLine
'
;
}
class
_ColumnLayout
{
_ColumnLayout
(
this
.
width
,
this
.
flex
);
class
ColumnLayout
{
ColumnLayout
(
this
.
width
,
this
.
flex
);
final
double
?
width
;
final
double
?
flex
;
...
...
@@ -165,7 +165,7 @@ class _ColumnLayout {
abstract
class
TableColumnWidth
{
const
TableColumnWidth
();
_
ColumnLayout
layout
(
ColumnLayout
layout
(
Widget
child
,
Context
context
,
BoxConstraints
constraints
);
}
...
...
@@ -175,10 +175,10 @@ class IntrinsicColumnWidth extends TableColumnWidth {
final
double
?
flex
;
@override
_
ColumnLayout
layout
(
ColumnLayout
layout
(
Widget
child
,
Context
context
,
BoxConstraints
constraints
)
{
if
(
flex
!=
null
)
{
return
_
ColumnLayout
(
0
,
flex
);
return
ColumnLayout
(
0
,
flex
);
}
child
.
layout
(
context
,
const
BoxConstraints
());
...
...
@@ -189,7 +189,7 @@ class IntrinsicColumnWidth extends TableColumnWidth {
(
child
is
Expanded
?
child
.
flex
.
toDouble
()
:
(
child
.
box
!.
width
==
double
.
infinity
?
1
:
0
));
return
_
ColumnLayout
(
calculatedWidth
,
childFlex
);
return
ColumnLayout
(
calculatedWidth
,
childFlex
);
}
}
...
...
@@ -199,9 +199,9 @@ class FixedColumnWidth extends TableColumnWidth {
final
double
width
;
@override
_
ColumnLayout
layout
(
ColumnLayout
layout
(
Widget
child
,
Context
context
,
BoxConstraints
?
constraints
)
{
return
_
ColumnLayout
(
width
,
0
);
return
ColumnLayout
(
width
,
0
);
}
}
...
...
@@ -211,9 +211,9 @@ class FlexColumnWidth extends TableColumnWidth {
final
double
flex
;
@override
_
ColumnLayout
layout
(
ColumnLayout
layout
(
Widget
child
,
Context
context
,
BoxConstraints
?
constraints
)
{
return
_
ColumnLayout
(
0
,
flex
);
return
ColumnLayout
(
0
,
flex
);
}
}
...
...
@@ -223,9 +223,9 @@ class FractionColumnWidth extends TableColumnWidth {
final
double
value
;
@override
_
ColumnLayout
layout
(
ColumnLayout
layout
(
Widget
child
,
Context
context
,
BoxConstraints
?
constraints
)
{
return
_
ColumnLayout
(
constraints
!.
maxWidth
*
value
,
0
);
return
ColumnLayout
(
constraints
!.
maxWidth
*
value
,
0
);
}
}
...
...
@@ -412,7 +412,7 @@ class Table extends Widget with SpanningWidget {
final
List
<
double
?>
_widths
=
<
double
?>[];
final
List
<
double
>
_heights
=
<
double
>[];
final
_TableContext
_context
=
_
TableContext
();
final
TableContext
_context
=
TableContext
();
final
TableColumnWidth
defaultColumnWidth
;
final
Map
<
int
,
TableColumnWidth
>?
columnWidths
;
...
...
@@ -423,7 +423,7 @@ class Table extends Widget with SpanningWidget {
}
@override
void
restoreContext
(
_
TableContext
context
)
{
void
restoreContext
(
TableContext
context
)
{
_context
.
apply
(
context
);
_context
.
firstLine
=
_context
.
lastLine
;
}
...
...
pdf/lib/src/widgets/text.dart
View file @
be71711
...
...
@@ -393,7 +393,7 @@ class _WidgetSpan extends _Span {
}
}
typedef
_
VisitorCallback
=
bool
Function
(
typedef
VisitorCallback
=
bool
Function
(
InlineSpan
span
,
TextStyle
?
parentStyle
,
AnnotationBuilder
?
annotation
,
...
...
@@ -435,7 +435,7 @@ abstract class InlineSpan {
}
bool
visitChildren
(
_
VisitorCallback
visitor
,
VisitorCallback
visitor
,
TextStyle
?
parentStyle
,
AnnotationBuilder
?
annotation
,
);
...
...
@@ -469,7 +469,7 @@ class WidgetSpan extends InlineSpan {
/// Calls `visitor` on this [WidgetSpan]. There are no children spans to walk.
@override
bool
visitChildren
(
_
VisitorCallback
visitor
,
VisitorCallback
visitor
,
TextStyle
?
parentStyle
,
AnnotationBuilder
?
annotation
,
)
{
...
...
@@ -509,7 +509,7 @@ class TextSpan extends InlineSpan {
@override
bool
visitChildren
(
_
VisitorCallback
visitor
,
VisitorCallback
visitor
,
TextStyle
?
parentStyle
,
AnnotationBuilder
?
annotation
,
)
{
...
...
@@ -624,14 +624,14 @@ class _Line {
}
}
class
_
RichTextContext
extends
WidgetContext
{
class
RichTextContext
extends
WidgetContext
{
var
startOffset
=
0.0
;
var
endOffset
=
0.0
;
var
spanStart
=
0
;
var
spanEnd
=
0
;
@override
void
apply
(
_
RichTextContext
other
)
{
void
apply
(
RichTextContext
other
)
{
startOffset
=
other
.
startOffset
;
endOffset
=
other
.
endOffset
;
spanStart
=
other
.
spanStart
;
...
...
@@ -640,7 +640,7 @@ class _RichTextContext extends WidgetContext {
@override
WidgetContext
clone
()
{
return
_
RichTextContext
()..
apply
(
this
);
return
RichTextContext
()..
apply
(
this
);
}
@override
...
...
@@ -682,7 +682,7 @@ class RichText extends Widget with SpanningWidget {
final
List
<
_TextDecoration
>
_decorations
=
<
_TextDecoration
>[];
final
_context
=
_
RichTextContext
();
final
_context
=
RichTextContext
();
final
TextOverflow
?
overflow
;
...
...
@@ -1297,7 +1297,7 @@ class RichText extends Widget with SpanningWidget {
bool
get
hasMoreWidgets
=>
canSpan
;
@override
void
restoreContext
(
_
RichTextContext
context
)
{
void
restoreContext
(
RichTextContext
context
)
{
_context
.
spanStart
=
context
.
spanEnd
;
_context
.
startOffset
=
-
context
.
endOffset
;
}
...
...
pdf/lib/src/widgets/wrap.dart
View file @
be71711
...
...
@@ -45,19 +45,19 @@ class _RunMetrics {
final
int
childCount
;
}
class
_
WrapContext
extends
WidgetContext
{
class
WrapContext
extends
WidgetContext
{
int
firstChild
=
0
;
int
lastChild
=
0
;
@override
void
apply
(
_
WrapContext
other
)
{
void
apply
(
WrapContext
other
)
{
firstChild
=
other
.
firstChild
;
lastChild
=
other
.
lastChild
;
}
@override
WidgetContext
clone
()
{
return
_
WrapContext
()..
apply
(
this
);
return
WrapContext
()..
apply
(
this
);
}
@override
...
...
@@ -110,7 +110,7 @@ class Wrap extends MultiChildWidget with SpanningWidget {
@override
bool
get
hasMoreWidgets
=>
_context
.
lastChild
<
children
.
length
;
final
_WrapContext
_context
=
_
WrapContext
();
final
WrapContext
_context
=
WrapContext
();
double
?
_getMainAxisExtent
(
Widget
child
)
{
switch
(
direction
)
{
...
...
@@ -390,7 +390,7 @@ class Wrap extends MultiChildWidget with SpanningWidget {
}
@override
void
restoreContext
(
_
WrapContext
context
)
{
void
restoreContext
(
WrapContext
context
)
{
_context
.
apply
(
context
);
_context
.
firstChild
=
context
.
lastChild
;
}
...
...
pdf/pubspec.yaml
View file @
be71711
...
...
@@ -20,5 +20,5 @@ dependencies:
xml
:
"
>=5.1.0
<7.0.0"
dev_dependencies
:
flutter_lints
:
^
1.0.4
flutter_lints
:
^
2.0.0
test
:
"
>=1.16.0
<2.0.0"
...
...
printing/lib/src/preview/custom.dart
View file @
be71711
...
...
@@ -24,6 +24,7 @@ import '../printing.dart';
import
'../printing_info.dart'
;
import
'page.dart'
;
import
'raster.dart'
;
/// Custom widget builder that's used for custom
/// rasterized pdf pages rendering
typedef
CustomPdfPagesBuilder
=
Widget
Function
(
...
...
printing/lib/src/preview/page.dart
View file @
be71711
...
...
@@ -15,6 +15,7 @@
*/
import
'package:flutter/material.dart'
;
/// A class that holds rasterized pdf data
class
PdfPreviewPageData
{
/// Default constructor
...
...
@@ -26,12 +27,14 @@ class PdfPreviewPageData {
/// rasterized pdf image provider
final
ImageProvider
image
;
/// rasterized image width
final
int
width
;
/// rasterized image height
final
int
height
;
/// returns with to height aspect ratio
/// returns with to height aspect ratio
double
get
aspectRatio
{
if
(
height
!=
0.0
)
{
return
width
/
height
;
...
...
Please
register
or
login
to post a comment