【问题标题】:Fill Data In Existing PDF Form Using Dart / flutter使用 Dart / Flutter 在现有 PDF 表单中填充数据
【发布时间】:2021-06-01 17:45:30
【问题描述】:

问题:我有一个现有的 PDF 表格 ( *.pdf ) 需要填写。如何使用 dart 动态填充它?

【问题讨论】:

    标签: flutter dart pdf


    【解决方案1】:

    我已经使用了 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();
    

    【讨论】:

      猜你喜欢
      • 2017-05-10
      • 2017-09-23
      • 1970-01-01
      • 1970-01-01
      • 2014-10-24
      • 1970-01-01
      • 1970-01-01
      • 2014-01-03
      相关资源
      最近更新 更多