lgyjg / AndroidRTC

The webRTC Android Application demo use android studio compile
MIT License
16 stars 7 forks source link

Unable to add Table in existing pdf page (Not as new page in pdf document ) in flutter #3

Closed dalu547 closed 1 year ago

dalu547 commented 1 year ago

Iam trying add table in existing pdf page, but iam unable to add. (It is adding as new page in pdf document)

below is my code, please help me out in this scenario

final PdfDocument document = PdfDocument(inputBytes: File(_file!.path).readAsBytesSync());

**final PdfPage pdfPage = document.pages[0];** // adding in first page

//Create a PdfGrid class PdfGrid grid = PdfGrid();

//Add the columns to the grid grid.columns.add(count: 3);

//Add header to the grid // grid.headers.add(1);

//Add the rows to the grid // PdfGridRow header = grid.headers[0]; // header.cells[0].value = 'Sign'; // header.cells[1].value = 'Sign'; // header.cells[2].value = 'Sign';

PdfGridRow row = grid.rows.add();
row.cells[0].value = 'Sign';
row.cells[1].value = 'Sign';
row.cells[2].value = 'Sign';

//Add rows to grid PdfGridRow row1 = grid.rows.add(); row1.cells[0].value = 'xxxxxxx'; row1.cells[1].value = 'xxxxxxx'; row1.cells[2].value = 'xxxxxxxx';

PdfGridRow row2 = grid.rows.add();
row2.cells[0].value = 'Lead';
row2.cells[1].value = 'Manager';
row2.cells[2].value = 'Manager';

//Set the grid style grid.style = PdfGridStyle( cellPadding: PdfPaddings(left: 2, right: 3, top: 4, bottom: 5), backgroundBrush: PdfBrushes.white, textBrush: PdfBrushes.black, font: PdfStandardFont(PdfFontFamily.helvetica, 25));

//Draw the grid grid.draw( page: pdfPage, bounds: const Rect.fromLTWH(0, 0, 0, 0));

// grid.draw(page: page);

String tableFilePath = '/storage/emulated/0/Download/greensign_watermark_table.pdf';

//Save and dispose the PDF document File(tableFilePath).writeAsBytes(await document.save()); document.dispose();

Iam getting runtime error as "E/flutter (16417): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value"

lgyjg commented 1 year ago

I sorry, I am not working on this project right now, so you need resolve this problem by yourself.

dalu547 commented 1 year ago

Thank you @lgyjg for your update. Posted same issue in https://github.com/syncfusion/flutter-examples/issues lets see if we get any response from syncfusion.