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
![Screenshot 2024-05-02 at 10 45 43 a m](https://private-user-images.githubusercontent.com/128649230/327513253-7e3c9106-7d2e-4a57-8695-9ab9bad6c827.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTc4MzQ5NzYsIm5iZiI6MTcxNzgzNDY3NiwicGF0aCI6Ii8xMjg2NDkyMzAvMzI3NTEzMjUzLTdlM2M5MTA2LTdkMmUtNGE1Ny04Njk1LTlhYjliYWQ2YzgyNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjA4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYwOFQwODE3NTZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kZWE5M2E2NjU5YzQ4MTg4ZDM1OWMxNzVhNjk1NmUzZmVlMzI4OWRjZDIzMmY2Y2Q4YWE0YjIzYTkyZTI1MjBhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.DCdUZDu2rBwNMRnlaHHWKy-mTu2i_DhYlbhz9kXF2X8)
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: