Skip to content

Commit

Permalink
API updated to what's included in the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bpampuch committed Mar 31, 2014
1 parent 8eddc2c commit 8b61b66
Show file tree
Hide file tree
Showing 13 changed files with 804 additions and 84 deletions.
17 changes: 14 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ module.exports = function(grunt) {
alias: './src/browser-extensions/virtual-fs.js:fs'
},
files: {
'build/pdfmake.js': ['src/printer.js']
'build/pdfmake.js': ['src/browser-extensions/pdfMake.js']
}
}
},

dump_dir: {
fonts: {
options: {
pre: 'var vfs_fonts = ',
pre: 'window.pdfMake = window.pdfMake || {}; window.pdfMake.vfs = ',
rootPath: 'examples/fonts/'
},
files: {
Expand All @@ -94,6 +94,16 @@ module.exports = function(grunt) {
}
},

concat: {
options: {
separator: ';'
},
dist: {
src: ['build/pdfmake.js', 'libs/fileSaver.js'],
dest: 'build/pdfmake.js'
}
},

uglify: {
build: {
options: {
Expand All @@ -116,11 +126,12 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-dump-dir');
grunt.loadNpmTasks('grunt-contrib-concat');

grunt.registerTask('test', [ 'replace:exposeTestMethods', 'jshint', 'mochacov', 'replace:hideTestMethods' ]);

grunt.registerTask('buildFonts', [ 'dump_dir' ]);
grunt.registerTask('build', [ 'replace:fixPdfKit', 'browserify', 'uglify', 'buildFonts' ]);
grunt.registerTask('build', [ 'replace:fixPdfKit', 'browserify', 'concat', 'uglify', 'buildFonts' ]);

grunt.registerTask('default', [ 'test', 'build' ]);
};
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ Check out [the playground](http://bpampuch.github.io/pdfmake/playground.html) or
* support for complex, multi-level (nested) structures,
* helper methods for opening/printing/downloading the generated PDF.

## Getting Started (preliminary version)
The following refers to pdfmake 0.1.2 (not available yet at github).
## Getting Started

*warning! links to the documentation do NOT work yet*

This document will walk you through the basics of pdfmake and will show you how to create PDF files in the browser. If you're interested in server-side printing, read [getting started with pdfMake under NodeJS](NodeGettingStarted).

Expand Down Expand Up @@ -89,18 +90,18 @@ var docDefinition = {
content: [
// if you don't need styles, you can use a simple string to define a paragraph
'This is a standard paragraph, using default style',

// using a { text: '...' } object lets you set styling properties
{ text: 'This paragraph will have a bigger font', fontSize: 15 },

// if you set the value of text to an array instead of a string, you'll be able
// to style any part individually
{
text: [
'This paragraph is defined as an array of elements to make it possible to ',
{
text: [
'This paragraph is defined as an array of elements to make it possible to ',
{ text: 'restyle part of it and make it bigger ', fontSize: 15 },
'than the rest.'
]
]
}
]
};
Expand Down Expand Up @@ -185,7 +186,7 @@ var docDefinition = {
// you can declare how many rows should be treated as headers
headerRows: 1,
widths: [ '*', 'auto', 100, '*' ],

body: [
[ 'First', 'Second', 'Third', 'The last one' ],
[ 'Value 1', 'Value 2', 'Value 3', 'Value 4' ],
Expand All @@ -197,7 +198,7 @@ var docDefinition = {
};
```



All concepts related to tables are covered by [this example](TODO) and [the resulting PDF](TODO). You can also [open it in playground](TODO).

Expand All @@ -210,15 +211,15 @@ var docDefinition = {
content: [
'Bulleted list example:',
{
// to treat a paragraph as a bulleted list, set an array of items under the ul key
// to treat a paragraph as a bulleted list, set an array of items under the ul key
ul: [
'Item 1',
'Item 2',
'Item 3',
{ text: 'Item 4', bold: true },
]
},

'Numbered list example:',
{
// for numbered lists set the ol key
Expand All @@ -234,7 +235,7 @@ var docDefinition = {

#### Headers and footers

Page headers and footers in pdfmake can be: *static* or *dynamic*.
Page headers and footers in pdfmake can be: *static* or *dynamic*.

They use the same syntax:

Expand All @@ -260,7 +261,7 @@ var docDefinition = {
footer: function(currentPage, pageCount) { return currentPage.toString() + ' of ' + pageCount; },
header: function(currentPage, pageCount) {
// you can apply any logic and return any valid pdfmake element

return { text: 'simple text', alignment: (currentPage % 2) ? 'left' : 'right' };
},
(...)
Expand Down Expand Up @@ -294,7 +295,7 @@ var docDefinition = {
content: [
'paragraph 1',
'paragraph 2',
{
{
columns: [
'first column is a simple text',
[
Expand All @@ -317,7 +318,7 @@ var docDefinition = {
content: [
'paragraph 1',
'paragraph 2',
{
{
columns: [
'first column is a simple text',
{
Expand All @@ -342,10 +343,10 @@ var docDefinition = {
var docDefinition = {
// a string or [width, height]
pageSize: 'A5',

// by default we use portrait, you can change it to landscape if you wish
pageOrientation: 'landscape',

// [left, top, right, bottom] or [horizontal, vertical] or just a number for equal margins
pageMargins: [ 40, 60, 40, 60 ],
};
Expand All @@ -361,7 +362,7 @@ If you set ```pageSize``` to a string, you can use one of the following values:

## Does the above description cover everything?

Not at all.
Not at all.

If you really want to learn pdfMake, go ahead and check the:
* [examples folder](https://github.com/bpampuch/pdfmake/tree/master/examples),
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pdfmake",
"version": "0.1.1",
"version": "0.1.2",
"homepage": "https://bpampuch.github.io/pdfmake",
"authors": [
"Bartek Pampuch <[email protected]>"
Expand Down
Loading

0 comments on commit 8b61b66

Please sign in to comment.