// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/backend/supabase/supabase.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 'dart:typed_data';
import 'package:flutter/services.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:printing/printing.dart';
Future<void> printWordPdf({
required String word, // Single string argument
}) async {
// Create a new PDF document
final pdf = pw.Document();
// Add a page to the PDF
pdf.addPage(
pw.Page(
pageFormat: PdfPageFormat.a4,
build: (pw.Context context) {
return pw.Center(
child: pw.Text(
word, // Display the passed word in the PDF
style: pw.TextStyle(
fontSize: 30, // Set font size
fontWeight: pw.FontWeight.bold, // Bold font
),
),
);
},
),
);
// Print the generated PDF
await Printing.layoutPdf(
onLayout: (PdfPageFormat format) async => pdf.save(),
);
}