Hello, I have a question about being able to display an image positioned in the upper right corner in my PDF document which is already generated. I tried several methods but none of them work for me. Can anyone help me?
This is my custom action:
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:pdf/widgets.dart' as pw;
import 'package:pdf/pdf.dart';
import 'package:printing/printing.dart';
Future makepdf(BuildContext context, List<VehiculosRecord> vehiculos,
String? fechaactual) async {
fechaactual = fechaactual ?? '';
final pdf = pw.Document();
pdf.addPage(pw.MultiPage(
orientation: pw.PageOrientation.landscape,
build: (context) => [
pw.Header(
level: 0,
child: pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: [
pw.Text(
'Reporte de estado de vehiculos ',
style: const pw.TextStyle(
color: PdfColors.black,
fontSize: 30,
),
),
pw.Text(
fechaactual ?? '',
style: pw.TextStyle(fontWeight: pw.FontWeight.bold),
),
],
),
),
pw.Container(
color: PdfColors
.deepOrange200,
child: pw.Table.fromTextArray(
headerStyle: pw.TextStyle(fontWeight: pw.FontWeight.bold),
context: context,
cellAlignment: pw.Alignment.center,
data: <List<String>>[
<String>[
'Unidad',
'Sobrenombre',
'Matricula',
'Encargado',
'Estado',
'Ultimo mantenimiento'
]
],
columnWidths: {
0: pw.FixedColumnWidth(100),
1: pw.FixedColumnWidth(80),
2: pw.FixedColumnWidth(80),
3: pw.FixedColumnWidth(100),
4: pw.FixedColumnWidth(80),
5: pw.FixedColumnWidth(120),
},
),
),
pw.Container(
child: pw.Table.fromTextArray(
context: context,
cellAlignment: pw.Alignment.center,
data: List<List<dynamic>>.from(vehiculos.map((vehiculo) => [
vehiculo.unidad,
vehiculo.sobrenombre,
vehiculo.matricula,
vehiculo.responsable,
vehiculo.estado,
vehiculo.fecha
])),
columnWidths: {
0: pw.FixedColumnWidth(100),
1: pw.FixedColumnWidth(80),
2: pw.FixedColumnWidth(80),
3: pw.FixedColumnWidth(100),
4: pw.FixedColumnWidth(80),
5: pw.FixedColumnWidth(120),
},
),
)
]));
await Printing.layoutPdf(
onLayout: (PdfPageFormat format) async => pdf.save());
}