pdfmakr 0.0.1+1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 33

pdfmakr

A dart wrapper for PDFMake in browser - example

Usage

HTML

add pdfmake scripts file to your repo and your html page

<script src='js/pdfmake.min.js'></script>
<script src='js/vfs_fonts.js'></script>

Dart

Future downloadPdf() async {
  final pdfFile = await pdf.createPdf(new pdf.PDFContent(
      content: [
        new pdf.Image(image: await loadImg64("img/rx.png")),
        new pdf.TextBloc(text: "text example", bold: true, color: 'blue'),
        new pdf.TextBloc(text: "text example with style", style: 'header'),
        new pdf.TextBloc(text: " "),
        new pdf.Columns(columns: [
          new pdf.Column(text: 'col 1 80%', width: '80%'),
          new pdf.Column(text: 'col 2'),
        ]),
        new pdf.TextBloc(text: " "),
        new pdf.Table(
            table: new pdf.TableBody(body: [
          [
            new pdf.TextBloc(text: "cell example 1", bold: true, color: 'blue'),
            new pdf.TextBloc(
                text: "cell example - col 2",
                bold: true,
                color: 'green',
                fillColor: 'yellow'),
          ],
          [
            new pdf.TextBloc(text: "bold row 2 - col 1", bold: true),
            new pdf.TextBloc(text: "italic row 2 - col 2", italics: true),
          ]
        ]))
      ],
      styles: new pdf.Styles(
          header: new pdf.Style(color: 'red', fontSize: 24),
          basic: new pdf.Style(color: 'green'))));

  pdfFile.download();
  //pdfFile.print();
  //pdfFile.open();
}

Future<String> loadImg64(String url) async {
  HttpRequest response =
      await HttpRequest.request(url, responseType: "arraybuffer");

  String contentType = response.getResponseHeader('Content-Type');

  var list = new Uint8List.view((response.response as ByteBuffer));

  String header = 'data:$contentType;base64,';
  String base64 = BASE64.encode(list);
  String image = "${header}${base64}";

  return image;
}

Example

works with DDC

cd example
pub get
pub serve

# open in chrome

Features / Todos

  • [x] createPdf

  • Content types

    • [x] text
    • [ ] image :
      • [x] url
      • [ ] size
    • [ ] Columns
      • [x] text, width
      • [ ] multitype columns content
    • [ ] Table
      • [x] body
      • [ ] more ?
  • [x] Styles dictionaries ( user needs implements its own class )

  • [x] pdf.download()

  • [x] pdf.open()

  • [x] pdf.print()

  • dart-ier api : cascade ?

  • lists : ul, ol

  • headers, footers

  • background layer

  • margins

  • text decorations

  • paragraphs

  • image sizes

  • pageBreak

  • page dimensions, orientation and margins

  • more internal properties

  • browser preview */

Changelog

0.0.1

  • createPdf(PDFContent)
  • Content types
    • text : size, color, bold, italic
    • Image : url
    • basic text Columns
    • Table : body
  • Styles dictionaries ( implies implementing its own class )
  • pdfDoc.download(),pdfDoc.open(),pdfDoc.print()

Use this package as a library

1. Depend on it

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


dependencies:
  pdfmakr: ^0.0.1+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pdfmakr/pdfmakr.dart';
  
Version Uploaded Documentation Archive
0.0.1+1 Sep 13, 2017 Go to the documentation of pdfmakr 0.0.1+1 Download pdfmakr 0.0.1+1 archive
0.0.1 Sep 13, 2017 Go to the documentation of pdfmakr 0.0.1 Download pdfmakr 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
66
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
33
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0