printing 2.0.0 copy "printing: ^2.0.0" to clipboard
printing: ^2.0.0 copied to clipboard

outdated

Plugin that allows Flutter apps to generate and print documents to android or ios compatible printers

Printing #

Plugin that allows Flutter apps to generate and print documents to android or ios compatible printers

See the example on how to use the plugin.

Example document

This plugin uses the pdf package https://pub.dartlang.org/packages/pdf for pdf creation. Please refer to https://pub.dartlang.org/documentation/pdf/latest/ for documentation.

To load an image it is possible to use Image.toByteData:

var Image im;
var bytes = await im.toByteData(format: ui.ImageByteFormat.rawRgba);

PdfImage image = PdfImage(
    pdf,
    image: bytes.buffer.asUint8List(), 
    width: im.width, 
    height: im.height);
g.drawImage(image, 100.0, 100.0, 80.0);

To use a TrueType font from a flutter bundle:

var font = await rootBundle.load("assets/open-sans.ttf");
PdfTtfFont ttf = PdfTtfFont(pdf, font);
g.setColor(PdfColor(0.3, 0.3, 0.3));
g.drawString(ttf, 20.0, "Dart is awesome", 50.0, 30.0);

Installing #

  1. Add this to your package's pubspec.yaml file:

    dependencies:
      printing: any       # <-- Add this line
    
  2. Enable Swift on the iOS project, in ios/Podfile:

    target 'Runner' do
       use_frameworks!    # <-- Add this line
    
  3. Set minimum Android version in android/app/build.gradle:

    defaultConfig {
        ...
        minSdkVersion 19  // <-- Change this line to 19 or more
        ...
    }
    
1445
likes
0
pub points
99%
popularity

Publisher

verified publishernfet.net

Plugin that allows Flutter apps to generate and print documents to android or ios compatible printers

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, pdf

More

Packages that depend on printing