Closed Yuvabanna closed 8 months ago
To meet your requirements, we have two options: either utilize a footer template for all pages or manually allocate space at the bottom of the table using PdfLayoutFormat.paginateBounds.
To add a footer template for all pages, kindly use the following UG documentation for reference, Headers and Footers in Flutter PDF library | Syncfusion
To manually allocate space at the bottom of the table, kindly use the below modified code snippet for reference,
//The paginate bounds is preserved in every page during pagination.
PdfLayoutFormat layoutFormat = PdfLayoutFormat(
layoutType: PdfLayoutType.paginate,
paginateBounds: Rect.fromLTWH(
0, 0, page.getClientSize().width, page.getClientSize().height - 100));
grid.draw(
page: page,
bounds: Rect.fromLTWH(0, pageSize.height - 430, 0, 0),
format: layoutFormat);
To know more about working with PdfGrid, kindly use the following UG documentation, Tables in Flutter PDF library | Syncfusion
This issue is coming in this that product ad is visible till the end of the page. I need bottom space, with the help of which I can add footer at the bottom and my footer does not overflow.
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart'; import 'package:open_filex/open_filex.dart'; import 'package:path_provider/path_provider.dart'; import 'package:share_plus/share_plus.dart'; import 'package:spl_invoice_creator/api/api_method.dart'; import 'package:spl_invoice_creator/utility/changable_value.dart'; import 'package:spl_invoice_creator/utility/image_manager.dart'; import 'package:syncfusion_flutter_pdf/pdf.dart';
class PDFGenerate { Future _readImageData() async {
Alignment.center;
final data = await rootBundle.load(ImageAsset.logo);
return data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
}
Future createPDF(
customerName,
address,
city,
country,
postalCode,
invoiceNo,
reference,
invoiceDate,
invoiceDueDate,
item,
notes,
amount,
isOpen,
isUpdate) async {
DateTime year = DateTime.now();
}
PdfGrid getGrid(item) { final PdfGrid grid = PdfGrid();
}
void addProducts(String date, String minibus, String description, String price, String quantity, String amount, PdfGrid grid) { final PdfGridRow row = grid.rows.add(); row.cells[0].value = date; row.cells[1].value = description; row.cells[2].value = minibus; row.cells[3].value = quantity.toString(); row.cells[4].value = price.toString(); row.cells[5].value = amount.toString(); row.cells[0].stringFormat.alignment = PdfTextAlignment.center; row.cells[1].stringFormat.alignment = PdfTextAlignment.center; row.cells[2].stringFormat.alignment = PdfTextAlignment.center; row.cells[3].stringFormat.alignment = PdfTextAlignment.center; row.cells[4].stringFormat.alignment = PdfTextAlignment.center; row.cells[5].stringFormat.alignment = PdfTextAlignment.center; }
Future saveAndLaunchFile(bytes, String fileName, isOpen) async {
final path = (await getExternalStorageDirectory())!.path;
kLog(content: ">>>> $path");
final file = File('$path/$fileName');
await file.writeAsBytes(bytes, flush: true);
kLog(content: "0000$isOpen >>> $path >>> $fileName");
isOpen
? OpenFilex.open('$path/$fileName')
: Share.shareXFiles([XFile("$path/$fileName")]);
}
String convertDate(String date) { DateTime parseDate = DateFormat("yyyy-MM-dd").parse(date); var inputDate = DateTime.parse(parseDate.toString()); var outputFormat = DateFormat('dd/MM/yyyy'); var outputDate = outputFormat.format(inputDate); return outputDate; } }