Git Product home page Git Product logo

Comments (4)

DavBfr avatar DavBfr commented on June 12, 2024

Can you attach the 2 documents?

from dart_pdf.

LuisHer27 avatar LuisHer27 commented on June 12, 2024

The first one is this:
sample.pdf

The second one is generate in the generatePDF() method that I put in the code example

static Future<File> generatePDF(Uint8List signature) async {
    try {
      final font = await PdfGoogleFonts.nunitoExtraLight();
      final pdf = Document();
      final image = MemoryImage(signature);
      pdf.addPage(
        Page(
          pageFormat: PdfPageFormat.a4,
          build: (Context context) {
            return Center(
              child: Column(
                children: [
                  Text(
                    'Participant Agreement Form',
                    style: TextStyle(
                      font: font,
                    ),
                  ),
                  SizedBox(height: 12),
                  Text(
                    'Name: Anakin Skywalker',
                    style: TextStyle(
                      font: font,
                    ),
                  ),
                  Text(
                    'Signature',
                    style: TextStyle(
                      font: font,
                    ),
                  ),
                  SizedBox(height: 20),
                  Image(image),
                  SizedBox(height: 4),
                  Container(
                    height: 1,
                    width: 200,
                    decoration: BoxDecoration(
                      border: Border.all(),
                    ),
                  ),
                  SizedBox(height: 10),
                  Text(
                    'Date: 2021-09-01',
                    style: TextStyle(
                      font: font,
                    ),
                  ),
                ],
              ),
            ); // Center
          },
        ),
      );

      final dir = await getApplicationDocumentsDirectory();
      final formPdf = File('${dir.path}/sign_form.pdf');
      return await formPdf.writeAsBytes(await pdf.save());
    } catch (e) {
      log(e.toString());
      throw Exception('Error generating PDF');
    }
  }

from dart_pdf.

DavBfr avatar DavBfr commented on June 12, 2024

Looks like your sample.pdf file is corrupted.
If you validate it at https://www.pdfforge.org/online/en/validate-pdfa it says so.

from dart_pdf.

LuisHer27 avatar LuisHer27 commented on June 12, 2024

Yes, you are right! It's working with another PDF as expected, thanks @DavBfr.

from dart_pdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.