a
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:flutter/foundation.dart'; // Per kIsWeb
|
||||
import 'dart:io' show Platform;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||
@@ -179,19 +181,25 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
||||
_ActionButton(
|
||||
icon: Icons.print,
|
||||
label: "Ricevuta A4",
|
||||
onTap: () {
|
||||
TicketPdfService().generateTicketReceipt(ticket);
|
||||
|
||||
// 1. Costruiamo la struttura (velocissimo)
|
||||
/* final doc = await TicketPdfService()
|
||||
onTap: () async {
|
||||
final doc = await TicketPdfService()
|
||||
.generateTicketReceipt(ticket);
|
||||
final bytes = await doc.save();
|
||||
final fileName = 'Ricevuta_${ticket.referenceId}.pdf';
|
||||
|
||||
// 2. Lanciamo layoutPdf esattamente come facevi tu!
|
||||
await Printing.layoutPdf(
|
||||
name: 'Ricevuta_${ticket.referenceId}.pdf',
|
||||
onLayout: (PdfPageFormat format) async =>
|
||||
doc.save(), // La magia è qui!
|
||||
); */
|
||||
if (kIsWeb || Platform.isMacOS) {
|
||||
// Forza il download/salvataggio senza passare per il print spooler
|
||||
await Printing.sharePdf(
|
||||
bytes: bytes,
|
||||
filename: fileName,
|
||||
);
|
||||
} else {
|
||||
// Su Android/iOS continuiamo a usare la stampa diretta che funziona
|
||||
await Printing.layoutPdf(
|
||||
onLayout: (format) async => bytes,
|
||||
name: fileName,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (company.labelFormat != LabelFormat.none)
|
||||
@@ -201,12 +209,23 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
||||
onTap: () async {
|
||||
final doc = await TicketPdfService().generateLabelPdf(
|
||||
ticket,
|
||||
company,
|
||||
);
|
||||
await Printing.layoutPdf(
|
||||
name: 'Etichetta_${ticket.referenceId}.pdf',
|
||||
onLayout: (PdfPageFormat format) async => doc.save(),
|
||||
);
|
||||
final bytes = await doc.save();
|
||||
final fileName = 'Ricevuta_${ticket.referenceId}.pdf';
|
||||
|
||||
if (kIsWeb || Platform.isMacOS) {
|
||||
// Forza il download/salvataggio senza passare per il print spooler
|
||||
await Printing.sharePdf(
|
||||
bytes: bytes,
|
||||
filename: fileName,
|
||||
);
|
||||
} else {
|
||||
// Su Android/iOS continuiamo a usare la stampa diretta che funziona
|
||||
await Printing.layoutPdf(
|
||||
onLayout: (format) async => bytes,
|
||||
name: fileName,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
_ActionButton(
|
||||
|
||||
Reference in New Issue
Block a user