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-03 11:52:15 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
eb6ff163c4c01121308c330f0913689582c4e1fb
eb6ff163
1 parent
3d957448
Fix Page orientation
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
155 additions
and
8 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/multi_page.dart
pdf/lib/widgets/page.dart
pdf/test/all_tests.dart
pdf/test/orientation_test.dart
pdf/CHANGELOG.md
View file @
eb6ff16
...
...
@@ -10,6 +10,7 @@
-
Format Java code
-
Add optional clipping on Page
-
Add Footer Widget
-
Fix Page orientation
## 1.3.23
...
...
pdf/lib/widgets/multi_page.dart
View file @
eb6ff16
...
...
@@ -90,8 +90,10 @@ class MultiPage extends Page {
..
saveContext
()
..
setTransform
(
Matrix4
.
identity
()
..
rotateZ
(-
math
.
pi
/
2
)
..
translate
(
x
-
pageHeight
+
_margin
.
top
-
_margin
.
left
,
y
+
_margin
.
left
-
_margin
.
bottom
));
..
translate
(
x
-
pageHeight
+
_margin
.
top
-
_margin
.
left
,
y
+
_margin
.
left
-
_margin
.
bottom
,
));
child
.
paint
(
context
);
context
.
canvas
.
restoreContext
();
...
...
pdf/lib/widgets/page.dart
View file @
eb6ff16
...
...
@@ -170,14 +170,14 @@ class Page {
if
(
mustRotate
)
{
final
EdgeInsets
_margin
=
margin
;
final
Matrix4
mat
=
Matrix4
.
identity
();
mat
..
rotateZ
(-
math
.
pi
/
2
)
..
translate
(-
pageFormat
.
height
-
_margin
.
left
+
_margin
.
top
,
child
.
box
.
height
-
child
.
box
.
width
+
_margin
.
left
-
_margin
.
bottom
);
context
.
canvas
..
saveContext
()
..
setTransform
(
mat
);
..
setTransform
(
Matrix4
.
identity
()
..
rotateZ
(-
math
.
pi
/
2
)
..
translate
(
-
pageFormat
.
height
-
_margin
.
left
+
_margin
.
top
,
-
pageFormat
.
height
+
pageFormat
.
width
+
_margin
.
top
-
_margin
.
right
,
));
child
.
paint
(
context
);
context
.
canvas
.
restoreContext
();
}
else
{
...
...
pdf/test/all_tests.dart
View file @
eb6ff16
...
...
@@ -24,6 +24,7 @@ import 'isolate_test.dart' as isolate;
import
'jpeg_test.dart'
as
jpeg
;
import
'metrics_test.dart'
as
metrics
;
import
'minimal_test.dart'
as
minimal
;
import
'orientation_test.dart'
as
orientation
;
import
'ttf_test.dart'
as
ttf
;
import
'type1_test.dart'
as
type1
;
import
'widget_basic_test.dart'
as
widget_basic
;
...
...
@@ -47,6 +48,7 @@ void main() {
jpeg
.
main
();
metrics
.
main
();
minimal
.
main
();
orientation
.
main
();
ttf
.
main
();
type1
.
main
();
widget_basic
.
main
();
...
...
pdf/test/orientation_test.dart
0 → 100644
View file @
eb6ff16
/*
* Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
'dart:io'
;
import
'package:test/test.dart'
;
import
'package:pdf/pdf.dart'
;
import
'package:pdf/widgets.dart'
;
Document
pdf
;
Widget
content
(
Context
context
)
{
return
ListView
(
children:
contentMultiPage
(
context
));
}
Widget
footer
(
Context
context
)
{
return
Footer
(
trailing:
Text
(
'Page
${context.pageNumber}
'
),
);
}
Widget
header
(
Context
context
)
{
return
Footer
(
title:
Text
(
'Test document'
),
);
}
List
<
Widget
>
contentMultiPage
(
Context
context
)
{
return
List
<
Widget
>.
generate
(
150
,
(
int
n
)
=>
Container
(
height:
20
,
child:
Text
(
'Hello World
$n
!'
,
style:
TextStyle
(
fontSize:
15
),
)),
);
}
void
main
(
)
{
setUpAll
(()
{
Document
.
debug
=
true
;
pdf
=
Document
();
});
test
(
'Orientation normal'
,
()
{
pdf
.
addPage
(
Page
(
clip:
true
,
build:
content
,
));
});
test
(
'Orientation landscape'
,
()
{
pdf
.
addPage
(
Page
(
clip:
true
,
pageFormat:
PdfPageFormat
.
standard
.
portrait
,
orientation:
PageOrientation
.
landscape
,
build:
content
,
));
pdf
.
addPage
(
Page
(
clip:
true
,
pageFormat:
PdfPageFormat
.
standard
.
landscape
,
orientation:
PageOrientation
.
landscape
,
build:
content
,
));
});
test
(
'Orientation portrait'
,
()
{
pdf
.
addPage
(
Page
(
clip:
true
,
pageFormat:
PdfPageFormat
.
standard
.
portrait
,
orientation:
PageOrientation
.
portrait
,
build:
content
,
));
pdf
.
addPage
(
Page
(
clip:
true
,
pageFormat:
PdfPageFormat
.
standard
.
landscape
,
orientation:
PageOrientation
.
portrait
,
build:
content
,
));
});
test
(
'Orientation MultiPage normal'
,
()
{
pdf
.
addPage
(
MultiPage
(
build:
contentMultiPage
,
header:
header
,
footer:
footer
,
));
});
test
(
'Orientation MultiPage landscape'
,
()
{
pdf
.
addPage
(
MultiPage
(
pageFormat:
PdfPageFormat
.
standard
.
portrait
,
orientation:
PageOrientation
.
landscape
,
build:
contentMultiPage
,
header:
header
,
footer:
footer
,
));
pdf
.
addPage
(
MultiPage
(
pageFormat:
PdfPageFormat
.
standard
.
landscape
,
orientation:
PageOrientation
.
landscape
,
build:
contentMultiPage
,
header:
header
,
footer:
footer
,
));
});
test
(
'Orientation MultiPage portrait'
,
()
{
pdf
.
addPage
(
MultiPage
(
pageFormat:
PdfPageFormat
.
standard
.
portrait
,
orientation:
PageOrientation
.
portrait
,
build:
contentMultiPage
,
header:
header
,
footer:
footer
,
));
pdf
.
addPage
(
MultiPage
(
pageFormat:
PdfPageFormat
.
standard
.
landscape
,
orientation:
PageOrientation
.
portrait
,
build:
contentMultiPage
,
header:
header
,
footer:
footer
,
));
});
tearDownAll
(()
{
final
File
file
=
File
(
'orientation.pdf'
);
file
.
writeAsBytesSync
(
pdf
.
save
());
});
}
...
...
Please
register
or
login
to post a comment