使用Dart/flutter在现有PDF表单中填写数据



问题:我有一个现有的PDF表单(*.PDF(需要填写。如何使用飞镖动态填充?

我已经使用了syncfusion扩展来完成它。您可以在pub.dev上找到信息:https://pub.dev/packages/syncfusion_flutter_pdf跟随样本

//Load the existing PDF document.
final PdfDocument document =
PdfDocument(inputBytes: File('input.pdf').readAsBytesSync());
//Get the form.
PdfForm form = document.form;
//Get text box and fill value.
PdfTextBoxField name = document.form.fields[0] as PdfTextBoxField;
name.text = 'John';
//to change the font or size use
name.font = PdfStandardFont(PdfFontFamily.timesRoman, 12,0);

//Get the radio button and select.
PdfRadioButtonListField gender = form.fields[1] as PdfRadioButtonListField;
gender.selectedIndex = 1;
//Save and dispose the document.
File('output.pdf').writeAsBytesSync(document.save());
document.dispose();

最新更新