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
2022-02-02 07:56:01 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7521260bb3478b200f5b617143a37ecf01d050ed
7521260b
1 parent
6390f316
Add dpi attribute to PdfPreview
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
11 deletions
printing/CHANGELOG.md
printing/lib/src/preview/custom.dart
printing/lib/src/preview/pdf_preview.dart
printing/lib/src/preview/raster.dart
printing/CHANGELOG.md
View file @
7521260
...
...
@@ -7,6 +7,7 @@
-
Fix raster quality on Android
-
Use a CDN for emoji and cupertino fonts
-
Improved Android rendering
-
Add dpi attribute to PdfPreview
## 5.7.1
...
...
printing/lib/src/preview/custom.dart
View file @
7521260
...
...
@@ -40,6 +40,7 @@ class PdfPreviewCustom extends StatefulWidget {
this
.
padding
,
this
.
shouldRepaint
=
false
,
this
.
loadingWidget
,
this
.
dpi
,
})
:
super
(
key:
key
);
/// Pdf paper page format
...
...
@@ -78,6 +79,10 @@ class PdfPreviewCustom extends StatefulWidget {
/// If null, a [CircularProgressIndicator] is used instead.
final
Widget
?
loadingWidget
;
/// The rendering dots per inch resolution
/// If not provided, this value is calculated.
final
double
?
dpi
;
@override
PdfPreviewCustomState
createState
()
=>
PdfPreviewCustomState
();
}
...
...
@@ -103,6 +108,9 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom>
static
const
_errorMessage
=
'Unable to display the document'
;
@override
double
?
get
forcedDpi
=>
widget
.
dpi
;
@override
void
dispose
()
{
previewUpdate
?.
cancel
();
super
.
dispose
();
...
...
printing/lib/src/preview/pdf_preview.dart
View file @
7521260
...
...
@@ -60,6 +60,7 @@ class PdfPreview extends StatefulWidget {
this
.
shouldRepaint
=
false
,
this
.
loadingWidget
,
this
.
onPageFormatChanged
,
this
.
dpi
,
})
:
super
(
key:
key
);
static
const
_defaultPageFormats
=
<
String
,
PdfPageFormat
>{
...
...
@@ -158,6 +159,10 @@ class PdfPreview extends StatefulWidget {
/// The page format has changed
final
ValueChanged
<
PdfPageFormat
>?
onPageFormatChanged
;
/// The rendering dots per inch resolution
/// If not provided, this value is calculated.
final
double
?
dpi
;
@override
_PdfPreviewState
createState
()
=>
_PdfPreviewState
();
}
...
...
@@ -323,6 +328,7 @@ class _PdfPreviewState extends State<PdfPreview> {
previewPageMargin:
widget
.
previewPageMargin
,
scrollViewDecoration:
widget
.
scrollViewDecoration
,
shouldRepaint:
widget
.
shouldRepaint
,
dpi:
widget
.
dpi
,
),
),
if
(
actions
.
isNotEmpty
&&
widget
.
useActions
)
...
...
printing/lib/src/preview/raster.dart
View file @
7521260
...
...
@@ -48,6 +48,8 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> {
/// Dots per inch
double
dpi
=
PdfPageFormat
.
inch
;
double
?
get
forcedDpi
;
var
_rastering
=
false
;
Timer
?
_previewUpdate
;
...
...
@@ -62,21 +64,26 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> {
void
raster
()
{
_previewUpdate
?.
cancel
();
_previewUpdate
=
Timer
(
_updateTime
,
()
{
final
mq
=
MediaQuery
.
of
(
context
);
final
double
dpr
;
if
(!
kIsWeb
&&
Platform
.
isAndroid
)
{
if
(
mq
.
size
.
shortestSide
*
mq
.
devicePixelRatio
<
800
)
{
dpr
=
2
*
mq
.
devicePixelRatio
;
if
(
forcedDpi
!=
null
)
{
dpi
=
forcedDpi
!;
}
else
{
final
mq
=
MediaQuery
.
of
(
context
);
final
double
dpr
;
if
(!
kIsWeb
&&
Platform
.
isAndroid
)
{
if
(
mq
.
size
.
shortestSide
*
mq
.
devicePixelRatio
<
800
)
{
dpr
=
2
*
mq
.
devicePixelRatio
;
}
else
{
dpr
=
mq
.
devicePixelRatio
;
}
}
else
{
dpr
=
mq
.
devicePixelRatio
;
}
}
else
{
dpr
=
mq
.
devicePixelRatio
;
dpi
=
(
min
(
mq
.
size
.
width
-
16
,
widget
.
maxPageWidth
??
double
.
infinity
))
*
dpr
/
pageFormat
.
width
*
PdfPageFormat
.
inch
;
}
dpi
=
(
min
(
mq
.
size
.
width
-
16
,
widget
.
maxPageWidth
??
double
.
infinity
))
*
dpr
/
pageFormat
.
width
*
PdfPageFormat
.
inch
;
_raster
();
});
...
...
Please
register
or
login
to post a comment