pdfmakr 0.0.1+1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 63

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

Analysis

We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
29 / 100
Health:
Code health derived from static analysis. [more]
97 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
63
Learn more about scoring.

Platforms

Detected platforms: web, other

Primary library: package:pdfmakr/pdfmakr.dart with components: js.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 2 hints.

    Run dartfmt to format lib/pdfmakr.dart.

    Run dartfmt to format lib/src/pdf.dart.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use pdfmakr.dart.

Dependencies

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