Skip to content

Commit

Permalink
Updated README and LICENSE.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjohnde committed Dec 30, 2016
1 parent bc7fd67 commit 1eb2e06
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 34 deletions.
22 changes: 18 additions & 4 deletions LICENSE
@@ -1,8 +1,22 @@
The MIT License (MIT)
MIT License

Copyright (c) 2013 Jöerg Viola
Copyright (c) 2016 Ben John

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 28 additions & 30 deletions README.md
@@ -1,28 +1,27 @@
Play 2.5 PDF module
-------------------
# play-pdf

This module helps generating PDF documents dynamically from your Play! web application.
It simply renders your HTML- and CSS-based templates to PDF.
It is based on the Flying Saucer library, which in turn uses iText for PDF generation.

Usage
-----
## Usage

I have provided a simple example application at
https://github.com/benjohnde/play20-pdf/tree/master/samples/pdf-sample.
https://github.com/benjohnde/play-pdf/tree/master/example.

You can use a standard Play! scala template like this one:
```html
@(message: String)

@main("Welcome to Play 2.0") {
@main("Welcome to Play 2.5") {
Image: <img src="/public/images/favicon.png"/><br/>
Hello world! <br/>
@message <br/>
}
```

Then this template, after having imported ```util.pdf.PDF```, can simply be rendered as:
Then this template, after having imported ```de.benjohn.play.pdf.PDF```, can simply be rendered as:

```java
public static Result document() {
return PDF.ok(document.render("Your new application is ready."));
Expand All @@ -33,8 +32,7 @@ where ```PDF.ok``` is a simple shorthand notation for:
ok(PDF.toBytes(document.render("Your new application is ready."))).as("application/pdf")
```

Template rules
--------------
## Template rules

Templates must generate XHTML.

Expand All @@ -44,53 +42,53 @@ If you specify the URI as a path into the classpath of your Play! app, the resou
See the above sample template for an example.

Of course you can link to CSS files in your class path also, but be aware not to
use the ``` media="screen"```qualifier.
use the ``` media="screen"```qualifier.

Fonts you use must be explicitely packaged with your app.
```html
<html>
<head>
<style type="text/css"><!--
body {
...
font-family: FreeSans;
}
--></style>
<style>
body {
font-family: FreeSans;
}
</style>
</head>
<body>
...
</body>
</html>
```
Since the FreeSans font is not available to the java VM, you are required to
add the corresponding font file, "FreeSans.ttf" to your Play! app.
The module adds ```/conf/resources/fonts``` to the list of directories
searched for font files.
The module imports font resources as specified in your application configuration.
Specify fonts as follows: ```pdf.fonts = ["Arial.ttf", "Helvetica.ttf"]```.
Each font file should be placed in your Play app configuration folder, so that they will be included.
See also the example project.

Installation
------------
## Installation

Currently the module is not hosted anywhere. In order to use it, you need to publish it locally in the current play-maven-repository. Therefore:

```bash
git clone https://github.com/benjohnde/play20-pdf.git
cd play20-pdf/module
git clone https://github.com/benjohnde/play-pdf.git
cd play-pdf/module
activator publish-local
```

Then, add to your libraryDependencies in your ```build.sbt```:

```
libraryDependencies ++= Seq(
"de.joergviola" %% "play-pdf" % "0.7-SNAPSHOT"
"de.benjohn.play" %% "pdf" % "1.0"
)
```

After the next restart of the typesafe-activator, the module should be available.
If you are using an IDE like Eclipse, remember to re-generate your project files.
If you are using an IDE like Eclipse, remember to re-generate your project files.

License
-------
## License

Released under the MIT license; see the file LICENSE.

## Kudos

- [joergviola](https://github.com/joergviola) initial creator of this project

0 comments on commit 1eb2e06

Please sign in to comment.