Giter Site home page Giter Site logo

Comments (10)

DavBfr avatar DavBfr commented on May 28, 2024 1

@amirulasrof try with this: https://gist.github.com/DavBfr/bbe8ba482b1a9101628d8b0d83888517
If it works correctly, it should be easy to make a nice coupon using https://pub.dev/packages/pdf.

from esc_pos_printer.

DavBfr avatar DavBfr commented on May 28, 2024 1

CODE 39 is implemented in pdf version 1.3.28:

BarcodeWidget(
  data: 'HELLO 123',
  width: 200,
  height: 50,
);

If you need to rotate it, wrap it with Transform.rotateBox:

Transform.rotateBox(
  angle: pi / 2,
  child: BarcodeWidget(
    data: 'HELLO 123',
    width: 200,
    height: 50,
  ),
);

from esc_pos_printer.

amirulasrof avatar amirulasrof commented on May 28, 2024

Thank you @DavBfr I will definitely try this. Looks promising.

from esc_pos_printer.

amirulasrof avatar amirulasrof commented on May 28, 2024

Hi @DavBfr I try your code and encountered several error.

This is my pubspec : https://gist.github.com/amirulasrof/655099e425e559b70a8c3c344c956952

Below is the error :

Compiler message:
lib/main.dart:71:1: Error: This requires the 'extension-methods' experiment to be enabled.
Try enabling this experiment by adding it to the command line when compiling and running.
extension PdfRasterExt on PdfRaster {
^^^^^^^^^
lib/main.dart:71:27: Error: A function declaration needs an explicit list of parameters.
Try adding a parameter list to the function declaration.
extension PdfRasterExt on PdfRaster {
^^^^^^^^^
lib/main.dart:71:1: Error: Type 'extension' not found.
extension PdfRasterExt on PdfRaster {
^^^^^^^^^
lib/main.dart:71:24: Error: Type 'on' not found.
extension PdfRasterExt on PdfRaster {
^^
lib/main.dart:71:1: Error: 'extension' isn't a type.
extension PdfRasterExt on PdfRaster {
^^^^^^^^^
lib/main.dart:73:31: Error: Getter not found: 'width'.
return im.Image.fromBytes(width, height, pixels);
^^^^^
lib/main.dart:73:38: Error: Getter not found: 'height'.
return im.Image.fromBytes(width, height, pixels);
^^^^^^
lib/main.dart:73:46: Error: Getter not found: 'pixels'.
return im.Image.fromBytes(width, height, pixels);
^^^^^^
lib/main.dart:171:37: Error: Method not found: 'Printing.raster'.
await for (var page in Printing.raster(_buildDocument(), dpi: 300)) {
^^^^^^
lib/main.dart:172:18: Error: Method not found: 'PdfRasterImage'.
images.add(PdfRasterImage(page));
^^^^^^^^^^^^^^
lib/main.dart:172:18: Error: The method 'PdfRasterImage' isn't defined for the class '_MyAppState'.

  • '_MyAppState' is from 'package:scsgoprint/main.dart' ('lib/main.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'PdfRasterImage'.
    images.add(PdfRasterImage(page));
    ^^^^^^^^^^^^^^
    lib/main.dart:180:37: Error: Method not found: 'Printing.raster'.
    await for (var page in Printing.raster(_buildDocument(), dpi: printerDpi)) {

from esc_pos_printer.

DavBfr avatar DavBfr commented on May 28, 2024

In your pubspec, you missed:

environment:
  sdk: ">=2.7.0 <3.0.0"

This code uses extension methods from Dart 2.7

from esc_pos_printer.

amirulasrof avatar amirulasrof commented on May 28, 2024

Its working now, thank you @DavBfr for the help.

from esc_pos_printer.

amirulasrof avatar amirulasrof commented on May 28, 2024

Hi @DavBfr how to render barcode using plugin like https://pub.dev/packages/barcode_flutter in the pdf. Is it possible ?

from esc_pos_printer.

DavBfr avatar DavBfr commented on May 28, 2024

Not yet, what type of barcode do you need?

from esc_pos_printer.

amirulasrof avatar amirulasrof commented on May 28, 2024

Any type will be good for now.

from esc_pos_printer.

amirulasrof avatar amirulasrof commented on May 28, 2024

Very nice, thank you for the help @DavBfr

from esc_pos_printer.

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.