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
2024-03-11 09:24:19 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
858a414e708b3ccc490216e363f9a82c240a38aa
858a414e
1 parent
b5eed134
Fix flutter test target
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
6 deletions
demo/lib/data.dart
demo/lib/examples/document.dart
demo/test/printing_test.dart
pdf/lib/src/pdf/io/vm.dart
demo/lib/data.dart
View file @
858a414
class
CustomData
{
const
CustomData
({
this
.
name
=
'[your name]'
});
const
CustomData
({
this
.
name
=
'[your name]'
,
this
.
testing
=
false
,
});
final
String
name
;
final
bool
testing
;
}
...
...
demo/lib/examples/document.dart
View file @
858a414
...
...
@@ -27,8 +27,12 @@ Future<Uint8List> generateDocument(
PdfPageFormat
format
,
CustomData
data
)
async
{
final
doc
=
pw
.
Document
(
pageMode:
PdfPageMode
.
outlines
);
final
font1
=
await
PdfGoogleFonts
.
openSansRegular
();
final
font2
=
await
PdfGoogleFonts
.
openSansBold
();
final
font1
=
data
.
testing
?
pw
.
Font
.
helvetica
()
:
await
PdfGoogleFonts
.
openSansRegular
();
final
font2
=
data
.
testing
?
pw
.
Font
.
helveticaBold
()
:
await
PdfGoogleFonts
.
openSansBold
();
final
shape
=
await
rootBundle
.
loadString
(
'assets/document.svg'
);
final
swirls
=
await
rootBundle
.
loadString
(
'assets/swirls2.svg'
);
...
...
demo/test/printing_test.dart
View file @
858a414
...
...
@@ -7,7 +7,7 @@ import 'package:printing_demo/examples/document.dart';
void
main
(
)
{
testWidgets
(
'Pdf Generate the document'
,
(
WidgetTester
tester
)
async
{
const
data
=
CustomData
();
const
data
=
CustomData
(
testing:
true
);
final
doc
=
await
generateDocument
(
PdfPageFormat
.
a4
,
data
);
final
file
=
File
(
'document.pdf'
);
...
...
pdf/lib/src/pdf/io/vm.dart
View file @
858a414
...
...
@@ -24,5 +24,9 @@ DeflateCallback defaultDeflate = zlib.encode;
/// The dart:io implementation of [pdfCompute].
@pragma
(
'vm:prefer-inline'
)
Future
<
R
>
pdfCompute
<
R
>(
Future
<
R
>
Function
()
computation
)
async
=>
Isolate
.
run
<
R
>(
computation
,
debugName:
'dart_pdf'
);
Future
<
R
>
pdfCompute
<
R
>(
Future
<
R
>
Function
()
computation
)
async
{
if
(
Platform
.
environment
.
containsKey
(
'FLUTTER_TEST'
))
{
return
computation
();
}
return
Isolate
.
run
<
R
>(
computation
,
debugName:
'dart_pdf'
);
}
...
...
Please
register
or
login
to post a comment