Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Print document silently without preview panel?

I've been using printing plugin to print documents. It is working fine as expected.

Is it possible to print files without showing the preview panel which actually comes from android print?

For example, when user clicks a button it should print the file automatically without any user interaction or intervention.

Is this feasible?

Thanks. Hussain

like image 376
Hussain Badusha Avatar asked Oct 21 '25 05:10

Hussain Badusha


2 Answers

await Printing.directPrintPdf ( 
   printer: Printer(url: 'name of your device(printer name)' 
), 
  onLayout: (format) => _generatePdf(format, title));
like image 182
faycal Avatar answered Oct 26 '25 15:10

faycal


Just call what the preview calls; for example:

await Printing.layoutPdf(
  onLayout: (format) => _generatePrint()
  name: 'tst.pdf',
  format: PdfPageFormat.roll80,
);
like image 37
Marcel Cunha Avatar answered Oct 26 '25 15:10

Marcel Cunha