dart_pdf icon indicating copy to clipboard operation
dart_pdf copied to clipboard

How to use Signature? How to digitally sign the generated PDF.

Open xSuperMu opened this issue 1 year ago • 5 comments

Screenshot 2024-08-28 at 5 26 36 PM

pw.Container(
            width: double.infinity,
            padding: const pw.EdgeInsets.all(8),
            decoration: pw.BoxDecoration(
              border: pw.Border.all(
                color: PdfColors.blue,
                width: .5,
              ),
            ),
            child: pw.Column(
              crossAxisAlignment: pw.CrossAxisAlignment.start,
              children: [
                pw.Row(
                  children: [
                    pw.Text(
                      'First Name:',
                      style: customerDetailsTextStyle,
                    ),
                    pw.SizedBox(width: 10),
                    pw.Text(
                      _fNameCtrl.text,
                    ),
                  ],
                ),
                pw.SizedBox(height: 8),
                pw.Row(
                  children: [
                    pw.Text(
                      'Surname:',
                      style: customerDetailsTextStyle,
                    ),
                    pw.SizedBox(width: 10),
                    pw.Text(
                      _surNameCtrl.text,
                    ),
                  ],
                ),
                pw.SizedBox(height: 8),
                pw.Row(
                  children: [
                    pw.Text(
                      'Installation Address:',
                      style: customerDetailsTextStyle,
                    ),
                    pw.SizedBox(width: 10),
                    pw.Text(
                      _addressCtrl.text,
                    ),
                  ],
                ),
                pw.SizedBox(height: 8),
                pw.Row(
                  children: [
                    pw.Text(
                      'Email:',
                      style: customerDetailsTextStyle,
                    ),
                    pw.SizedBox(width: 10),
                    pw.Text(
                      _emailCtrl.text,
                    ),
                  ],
                ),
                pw.SizedBox(height: 8),
                pw.Signature(
                  name: 'signature',
                  child: pw.Text('Please sign here'),
                  // value: ,  <<<<<<<---------------------------------------------
                ),
              ],
            ),
          )

How to use the value attribute?

xSuperMu avatar Aug 28 '24 14:08 xSuperMu

Something like:

Signature(
          name: 'Signature',
          value: PdfSign.rsaSha1(
            privateKey: privateKey,
            certificates: chain,
          ),
          child: PdfLogo(),
        ),

It's described here: https://pub.nfet.net/pdf_crypto/

DavBfr avatar Aug 28 '24 14:08 DavBfr

@DavBfr This is a paid feature, Right?

xSuperMu avatar Aug 28 '24 15:08 xSuperMu

Yes it is. It's for digital cryptographic signature, not for hand-signed.

DavBfr avatar Aug 28 '24 15:08 DavBfr

Thank you @DavBfr for the prompt response. I think that I only need the hand-signed feature. How to achieve that?

xSuperMu avatar Aug 28 '24 15:08 xSuperMu

Ask the user to draw with a hand sign flutter plugin and add it as an image in the pdf.

DavBfr avatar Aug 28 '24 15:08 DavBfr