Comments (4)
The layoutPdf function's documentation is:
/// Prints a Pdf document to a local printer using the platform UI
/// the Pdf document is re-built in a [LayoutCallback] each time the
/// user changes a setting like the page format or orientation.
///
/// returns a future with a bool
set to true if the document is printed
/// and false if it is canceled.
/// throws an exception in case of error
so you would do:
import 'package:pdf/pdf.dart' as pw;
import 'package:printing/printing.dart';
final pdf = pw.Document();
// ... add content to the pdf ...
try {
final result = await Printing.layoutPdf(
onLayout: (PdfPageFormat format) async {
try {
final result = await pdf.save();
return result;
} catch (e) {
return null; // Handle error gracefully
}
});
if (result) {
// Handle successful print
return PrintStatus.success;
} else {
// Handle print canceled
return PrintStatus.canceled;
}
} catch (e) {
// handle print error
return PrintStatus.failure;
}
from dart_pdf.
The layoutPdf function's documentation is:
/// Prints a Pdf document to a local printer using the platform UI /// the Pdf document is re-built in a [LayoutCallback] each time the /// user changes a setting like the page format or orientation. /// /// returns a future with a
bool
set to true if the document is printed /// and false if it is canceled. /// throws an exception in case of errorso you would do:
import 'package:pdf/pdf.dart' as pw; import 'package:printing/printing.dart'; final pdf = pw.Document(); // ... add content to the pdf ... try { final result = await Printing.layoutPdf( onLayout: (PdfPageFormat format) async { try { final result = await pdf.save(); return result; } catch (e) { return null; // Handle error gracefully } }); if (result) { // Handle successful print return PrintStatus.success; } else { // Handle print canceled return PrintStatus.canceled; } } catch (e) { // handle print error return PrintStatus.failure; }
Hello.
This is working great on Android and iOS devices, but in Web platform It always return true, even without show the Preview Screen to print. So, with no users interaction to Print or Cancel I always get 'true' from the future.
from dart_pdf.
The layoutPdf function's documentation is:
/// Prints a Pdf document to a local printer using the platform UI /// the Pdf document is re-built in a [LayoutCallback] each time the /// user changes a setting like the page format or orientation. /// /// returns a future with a
bool
set to true if the document is printed /// and false if it is canceled. /// throws an exception in case of errorso you would do:
import 'package:pdf/pdf.dart' as pw; import 'package:printing/printing.dart'; final pdf = pw.Document(); // ... add content to the pdf ... try { final result = await Printing.layoutPdf( onLayout: (PdfPageFormat format) async { try { final result = await pdf.save(); return result; } catch (e) { return null; // Handle error gracefully } }); if (result) { // Handle successful print return PrintStatus.success; } else { // Handle print canceled return PrintStatus.canceled; } } catch (e) { // handle print error return PrintStatus.failure; }Hello.
This is working great on Android and iOS devices, but in Web platform It always return true, even without show the Preview Screen to print. So, with no users interaction to Print or Cancel I always get 'true' from the future.
I think that always true is happening in windows as well. Even if you don't finish the dialog, it returns true
from dart_pdf.
Related Issues (20)
- Pdf/A
- Restrictions on customizations
- The Urdu tag is for issues relating to displaying user interfaces and managing data in Udru written language
- When I press the shared button it calls onPrinted instead of onShared HOT 2
- Extend NewPage with freeSpace HOT 3
- Not forwarding email extras when sharing
- Emoji's not displaying in PDF generated with dart_pdf HOT 2
- Send PDF to a wifi printer by ip
- Merging two pdf
- Merge two PDF's HOT 4
- Updating PDF page
- Russian text Rendering issue.
- Flutter printing: ^5.12.0 package is not working offline or when on local network
- Texts containing \n and \r sometimes don't work
- error build for flutter 3.22.0 (No named parameter with the name 'size'.) HOT 3
- Unable to build app on Flutter version 3.22.0 HOT 5
- Support `--wasm` flag in Flutter 3.22 for web HOT 2
- IntrinsicHeight widget
- Support SVG `vector-effect` as Β΄non-scaling-stroke`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dart_pdf.