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-01-31 09:02:35 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
19d9f4bf6e5dc69e53799681c062970f62b3eef9
19d9f4bf
1 parent
fb29442f
Deprecate support for convertHtml
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
27 additions
and
28 deletions
printing/CHANGELOG.md
printing/README.md
printing/android/src/main/java/net/nfet/flutter/printing/PrintingJob.java
printing/ios/Classes/PrintJob.swift
printing/lib/src/printing.dart
printing/macos/Classes/PrintJob.swift
printing/test/document_test.dart
printing/test/printing_test.dart
printing/windows/print_job.cpp
test/extract_readme.dart
test/pubspec.yaml
printing/CHANGELOG.md
View file @
19d9f4b
...
...
@@ -7,6 +7,7 @@
-
Update cursors in zoom mode for web
[
Aleksei
]
-
Output image sized to cropBox instead of mediaBox (iOS)
[
garrettApproachableGeek
]
-
Replace Activity with Context for Service Compatibility (Android)
[
Heinrich
]
-
Deprecate support for
`convertHtml`
## 5.11.1
...
...
printing/README.md
View file @
19d9f4b
...
...
@@ -126,12 +126,27 @@ await Printing.sharePdf(bytes: await doc.save(), filename: 'my-document.pdf');
To print an HTML document:
import
[
HTMLtoPDFWidgets
](
https://pub.dev/packages/htmltopdfwidgets
)
```
dart
await
Printing
.
layoutPdf
(
onLayout:
(
PdfPageFormat
format
)
async
=>
await
Printing
.
convertHtml
(
format:
format
,
html:
'<html><body><p>Hello!</p></body></html>'
,
));
await
Printing
.
layoutPdf
(
onLayout:
(
PdfPageFormat
format
)
async
{
const
body
=
'''
<h1>Heading Example</h1>
<p>This is a paragraph.</p>
<img src="image.jpg" alt="Example Image" />
<blockquote>This is a quote.</blockquote>
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
'''
;
final
pdf
=
pw
.
Document
();
final
widgets
=
await
HTMLToPdf
().
convert
(
body
);
pdf
.
addPage
(
pw
.
MultiPage
(
build:
(
context
)
=>
widgets
));
return
await
pdf
.
save
();
});
```
Convert a Pdf to images, one image per page, get only pages 1 and 2 at 72 dpi:
...
...
printing/android/src/main/java/net/nfet/flutter/printing/PrintingJob.java
View file @
19d9f4b
...
...
@@ -86,7 +86,6 @@ public class PrintingJob extends PrintDocumentAdapter {
result
.
put
(
"directPrint"
,
false
);
result
.
put
(
"dynamicLayout"
,
canPrint
);
result
.
put
(
"canPrint"
,
canPrint
);
result
.
put
(
"canConvertHtml"
,
canRaster
);
result
.
put
(
"canShare"
,
true
);
result
.
put
(
"canRaster"
,
canRaster
);
return
result
;
...
...
printing/ios/Classes/PrintJob.swift
View file @
19d9f4b
...
...
@@ -396,7 +396,6 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate
"directPrint"
:
true
,
"dynamicLayout"
:
true
,
"canPrint"
:
true
,
"canConvertHtml"
:
true
,
"canShare"
:
true
,
"canRaster"
:
true
,
"canListPrinters"
:
false
,
...
...
printing/lib/src/printing.dart
View file @
19d9f4b
...
...
@@ -184,6 +184,7 @@ mixin Printing {
///
/// This is not supported on all platforms. Check the result of [info] to
/// find at runtime if this feature is available or not.
@Deprecated
(
'Please use another method to create your PDF document'
)
static
Future
<
Uint8List
>
convertHtml
({
required
String
html
,
String
?
baseUrl
,
...
...
printing/macos/Classes/PrintJob.swift
View file @
19d9f4b
...
...
@@ -309,7 +309,6 @@ public class PrintJob: NSView, NSSharingServicePickerDelegate {
"directPrint"
:
true
,
"dynamicLayout"
:
true
,
"canPrint"
:
true
,
"canConvertHtml"
:
true
,
"canShare"
:
true
,
"canRaster"
:
true
,
"canListPrinters"
:
true
,
...
...
printing/test/document_test.dart
View file @
19d9f4b
...
...
@@ -44,10 +44,6 @@ void main() {
.
setMockMethodCallHandler
(
channel
,
null
);
});
test
(
'convertHtml'
,
()
async
{
// expect(await Printing.platformVersion, '42');
});
test
(
'flutterImageProvider(FileImage)'
,
()
async
{
final
image
=
await
flutterImageProvider
(
FileImage
(
File
(
'
$path
/example.png'
)));
...
...
printing/test/printing_test.dart
View file @
19d9f4b
...
...
@@ -20,7 +20,6 @@ import 'package:flutter/widgets.dart';
import
'package:flutter_test/flutter_test.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:pdf/pdf.dart'
;
import
'package:plugin_platform_interface/plugin_platform_interface.dart'
;
import
'package:printing/printing.dart'
;
import
'package:printing/src/interface.dart'
;
...
...
@@ -73,13 +72,6 @@ void main() {
);
});
test
(
'convertHtml'
,
()
async
{
expect
(
await
Printing
.
convertHtml
(
html:
'<html></html>'
),
isInstanceOf
<
Uint8List
>(),
);
});
test
(
'raster'
,
()
async
{
expect
(
Printing
.
raster
(
Uint8List
(
0
)),
...
...
@@ -129,11 +121,6 @@ class MockPrinting extends Mock
@override
Stream
<
PdfRaster
>
raster
(
Uint8List
document
,
List
<
int
>?
pages
,
double
dpi
)
async
*
{}
@override
Future
<
Uint8List
>
convertHtml
(
String
html
,
String
?
baseUrl
,
PdfPageFormat
format
)
async
=>
Uint8List
(
0
);
}
class
MockContext
extends
Mock
implements
BuildContext
{}
...
...
printing/windows/print_job.cpp
View file @
19d9f4b
...
...
@@ -398,9 +398,8 @@ void PrintJob::rasterPdf(std::vector<uint8_t> data,
std
::
map
<
std
::
string
,
bool
>
PrintJob
::
printingInfo
()
{
return
std
::
map
<
std
::
string
,
bool
>
{
{
"directPrint"
,
true
},
{
"dynamicLayout"
,
true
},
{
"canPrint"
,
true
},
{
"canListPrinters"
,
true
},
{
"canConvertHtml"
,
false
},
{
"canShare"
,
true
},
{
"canRaster"
,
true
},
{
"directPrint"
,
true
},
{
"dynamicLayout"
,
true
},
{
"canPrint"
,
true
},
{
"canListPrinters"
,
true
},
{
"canShare"
,
true
},
{
"canRaster"
,
true
},
};
}
...
...
test/extract_readme.dart
View file @
19d9f4b
...
...
@@ -54,6 +54,8 @@ void buildFile(String src, String dest, bool flutter) {
st
.
writeln
(
'import
\'
package:flutter/services.dart
\'
show rootBundle;'
);
if
(
flutter
)
{
st
.
writeln
(
'import
\'
package:path_provider/path_provider.dart
\'
;'
);
st
.
writeln
(
'import
\'
package:htmltopdfwidgets/htmltopdfwidgets.dart
\'
show HTMLToPdf;'
);
}
else
{
st
.
writeln
(
'import
\'
dart:convert
\'
;'
);
st
.
writeln
(
'import
\'
dart:html
\'
as html;'
);
...
...
test/pubspec.yaml
View file @
19d9f4b
...
...
@@ -13,6 +13,7 @@ dependencies:
args
:
flutter
:
sdk
:
flutter
htmltopdfwidgets
:
markdown
:
meta
:
string_scanner
:
...
...
Please
register
or
login
to post a comment