diff --git a/LICENSE b/LICENSE index 2784600..a3a7ee7 100644 --- a/LICENSE +++ b/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. diff --git a/README.md b/README.md index c0a6054..131f163 100644 --- a/README.md +++ b/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:
Hello world!
@message
} ``` -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.")); @@ -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. @@ -44,37 +42,35 @@ 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 - + ... ``` -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 ``` @@ -82,15 +78,17 @@ 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