Giter Site home page Giter Site logo

Comments (7)

DavBfr avatar DavBfr commented on June 3, 2024

If you can print an image, yes. Use this https://pub.dev/packages/barcode_image
Otherwise, try with the pdf plugin: https://github.com/DavBfr/dart_pdf/wiki/Document-Output#using-another-plugin

from dart_barcode.

antoniopetricc avatar antoniopetricc commented on June 3, 2024

Thanks for the reply. But if the printer is connected only via usb, what can I do? Is there any way?

from dart_barcode.

DavBfr avatar DavBfr commented on June 3, 2024

I don't know

from dart_barcode.

antoniopetricc avatar antoniopetricc commented on June 3, 2024

Ok! I was able to print via my thermal printer. The problem now is the size of the pdf. If the sticker where I print is 50 x 30 mm, how should I set the pdf? Could you give me an example? (With what you gave me from the link it prints me badly!)

from dart_barcode.

DavBfr avatar DavBfr commented on June 3, 2024

Use a

SizedBox(
    width: 50 * PdfPageFormat.mm, 
    height: 30 * PdfPageFormat.mm, 
    child: BarcodeWidget(
         barcode: Barcode.ean13,
         data: '12345678'
       ),
);

from dart_barcode.

antoniopetricc avatar antoniopetricc commented on June 3, 2024

If I use 50 and 30 it prints the blank page, to test I also put 500 and 300 and it gives me the giant sticker.
What should I put on pageFormat? Now I use "format" but I also saw PdfPageFormat.roll80.

        doc.addPage(
          Page(
            pageFormat: format,
            build: (Context context) {
              return SizedBox(
                width: 500 * PdfPageFormat.mm,
                height: 300 * PdfPageFormat.mm,
                child: BarcodeWidget(
                  barcode: Barcode.ean13(drawEndChar: true),
                  data: '8099807953185',
                ),
              );
            },
          ),
        );

from dart_barcode.

DavBfr avatar DavBfr commented on June 3, 2024

I would do:

  Future<Uint8List> _generatePdf(PdfPageFormat format, String title) async {
    final pdf = pw.Document();

    pdf.addPage(
      pw.Page(
        pageFormat: PdfPageFormat.roll57.copyWith(
          marginTop: 2 * PdfPageFormat.mm,
          marginLeft: 3.5 * PdfPageFormat.mm,
          marginRight: 3.5 * PdfPageFormat.mm,
          marginBottom: 2 * PdfPageFormat.mm,
        ),
        build: (pw.Context context) {
          return pw.Center(
            child: pw.Wrap(
              runSpacing: 2 * PdfPageFormat.mm, // Space between stickers
              children: [
                pw.SizedBox(
                  height: 30 * PdfPageFormat.mm,
                  child: pw.BarcodeWidget(
                    barcode: pw.Barcode.ean13(drawEndChar: true),
                    data: '8099807953185',
                  ),
                ),
                pw.SizedBox(
                  height: 30 * PdfPageFormat.mm,
                  child: pw.BarcodeWidget(
                    barcode: pw.Barcode.ean13(drawEndChar: true),
                    data: '809983425318',
                  ),
                ),
                pw.SizedBox(
                  height: 30 * PdfPageFormat.mm,
                  child: pw.BarcodeWidget(
                    barcode: pw.Barcode.ean13(drawEndChar: true),
                    data: '809980541185',
                  ),
                ),
              ],
            ),
          );
        },
      ),
    );

    return pdf.save();
  }

from dart_barcode.

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.