You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to add a signature in the last page of the pdf and I want put the signature at the bottom of the page. But it seems like I'm not able to achieve it. The text looks flipped and I can't manipulate the blue container location.
To Reproduce
Code snippet to reproduce the behavior:
Future<File> getFile() async {
final data = await rootBundle.load('assets/participant_agreement.pdf');
final bytes = data.buffer.asUint8List();
final dir = await getApplicationDocumentsDirectory();
final file = File('${dir.path}/form.pdf');
final assetFile = await file.writeAsBytes(bytes);
return assetFile;
}
class PdfEditorService {
const PdfEditorService._();
static Future<File> addSignatureToPDF(Uint8List signature) async {
try {
final font = await PdfGoogleFonts.nunitoExtraLight();
final file = await getFile();
final form = file.readAsBytesSync();
final image = MemoryImage(signature);
final document = PdfDocumentParser(
form,
);
final lastPage = document.pages.length - 1;
final themePage = PageTheme(
pageFormat: PdfPageFormat.a4,
buildBackground: (context) {
return Container(color: PdfColors.blue);
},
);
final pdf = Document.load(document)
..editPage(
lastPage,
Page(
pageTheme: themePage,
build: (context) {
return Column(
children: [
Text(
'Participant Agreement Form',
style: TextStyle(
font: font,
fontSize: 32,
),
),
SizedBox(height: 12),
Text(
'Name: Anakin Skywalker',
style: TextStyle(
font: font,
fontSize: 32,
),
),
Positioned(
top: 0,
left: 0,
child: Column(
children: [
Text(
'Signature',
style: TextStyle(
font: font,
fontSize: 32,
),
),
SizedBox(height: 20),
Image(image),
SizedBox(height: 8),
Container(
height: 1,
width: 200,
decoration: BoxDecoration(
border: Border.all(),
),
),
SizedBox(height: 10),
Text(
'Date: 2021-09-01',
style: TextStyle(
font: font,
fontSize: 32,
),
),
],
),
)
],
);
},
),
);
final dir = await getApplicationDocumentsDirectory();
final signedForm = File('${dir.path}/form.pdf');
return await signedForm.writeAsBytes(await pdf.save());
} catch (e) {
log(e.toString());
throw Exception('Error adding signature to PDF');
}
}
}
Describe the bug
To Reproduce
Code snippet to reproduce the behavior:
Expected
expected_behavior.pdf
behavior
Screenshots
Flutter Doctor
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: