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
2021-02-13 09:10:16 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b570a2cb42c62d762c002d291acc0c8f164cbc10
b570a2cb
1 parent
81634e17
Update dependencies
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
4 deletions
demo/lib/app.dart
demo/pubspec.yaml
printing/lib/src/method_channel_ffi.dart
printing/pubspec.yaml
demo/lib/app.dart
View file @
b570a2c
...
...
@@ -127,6 +127,9 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
final
bytes
=
await
build
(
pageFormat
);
final
appDocDir
=
await
getApplicationDocumentsDirectory
();
if
(
appDocDir
==
null
)
{
return
;
}
final
appDocPath
=
appDocDir
.
path
;
final
file
=
File
(
appDocPath
+
'/'
+
'document.pdf'
);
print
(
'Save as file
${file.path}
...'
);
...
...
demo/pubspec.yaml
View file @
b570a2c
...
...
@@ -12,7 +12,7 @@ dependencies:
sdk
:
flutter
intl
:
^0.17.0-nullsafety
open_file
:
path_provider
:
path_provider
:
^2.0.0-nullsafety
printing
:
url_launcher
:
^6.0.0-nullsafety
...
...
printing/lib/src/method_channel_ffi.dart
View file @
b570a2c
...
...
@@ -33,9 +33,10 @@ ffi.DynamicLibrary _open() {
/// Set the Pdf document data
void
setDocumentFfi
(
PrintJob
job
,
Uint8List
data
)
{
final
nativeBytes
=
ffi
.
allocate
<
ffi
.
Uint8
>(
count:
data
.
length
);
final
nativeBytes
=
ffi
.
calloc
<
ffi
.
Uint8
>(
data
.
length
);
nativeBytes
.
asTypedList
(
data
.
length
).
setAll
(
0
,
data
);
_setDocument
(
job
.
index
,
nativeBytes
,
data
.
length
);
ffi
.
calloc
.
free
(
nativeBytes
);
}
final
_SetDocument_Dart
_setDocument
=
...
...
@@ -57,7 +58,7 @@ typedef _SetDocument_Dart = void Function(
/// Set the Pdf Error message
void
setErrorFfi
(
PrintJob
job
,
String
message
)
{
_setError
(
job
.
index
,
ffi
.
Utf8
.
toUtf8
(
message
));
_setError
(
job
.
index
,
ffi
.
StringUtf8Pointer
(
message
).
toNativeUtf8
(
));
}
final
_SetError_Dart
_setError
=
...
...
printing/pubspec.yaml
View file @
b570a2c
...
...
@@ -11,7 +11,7 @@ environment:
flutter
:
"
>=1.16.0"
dependencies
:
ffi
:
"
>=0.
2.0-nullsafety
<2.0.0"
ffi
:
"
>=0.
3.1-nullsafety.0
<2.0.0"
flutter
:
sdk
:
flutter
flutter_web_plugins
:
...
...
Please
register
or
login
to post a comment