All Projects β†’ benjohnde β†’ Play Pdf

benjohnde / Play Pdf

Licence: mit
A PDF module for the Play framework

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Play Pdf

Asciidoctor Pdf
πŸ“ƒ Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
Stars: ✭ 868 (+703.7%)
Mutual labels:  pdf, pdf-generation
Pdfsave
Convert websites into readable PDFs
Stars: ✭ 46 (-57.41%)
Mutual labels:  pdf, pdf-generation
Html Pdf Service
LGPL V3. Java Spring Boot microservice with RESTful webconsole and service endpoints that convert HTML to PDF, optionally styling with CSS and templating with JSON using Flying Saucer, PDF Box and Jackson libraries. Available on Docker Hub.
Stars: ✭ 12 (-88.89%)
Mutual labels:  pdf, pdf-generation
Itext7
iText 7 for Java represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText 7 can be a boon to nearly every workflow.
Stars: ✭ 913 (+745.37%)
Mutual labels:  pdf, pdf-generation
Unipdf
Golang PDF library for creating and processing PDF files (pure go)
Stars: ✭ 1,171 (+984.26%)
Mutual labels:  pdf, pdf-generation
Hexapdf
Versatile PDF creation and manipulation for Ruby
Stars: ✭ 852 (+688.89%)
Mutual labels:  pdf, pdf-generation
Mkdocs With Pdf
Generate a single PDF file from MkDocs repository.
Stars: ✭ 39 (-63.89%)
Mutual labels:  pdf, pdf-generation
Clj Pdf
PDF generation library for Clojure
Stars: ✭ 571 (+428.7%)
Mutual labels:  pdf, pdf-generation
Notion Pdf Export
A tool to allow batch PDF export for free Notion users. You can export as HTML and then use this tool to convert those into PDFs.
Stars: ✭ 66 (-38.89%)
Mutual labels:  pdf, pdf-generation
Openhtmltopdf
An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
Stars: ✭ 1,096 (+914.81%)
Mutual labels:  pdf, pdf-generation
Satysfi
A statically-typed, functional typesetting system
Stars: ✭ 815 (+654.63%)
Mutual labels:  pdf, pdf-generation
Laravel Pdf
A Simple package for easily generating PDF documents from HTML. This package is specially for laravel but you can use this without laravel.
Stars: ✭ 79 (-26.85%)
Mutual labels:  pdf, pdf-generation
Itext7 Dotnet
iText 7 for .NET is the .NET version of the iText 7 library, formerly known as iTextSharp, which it replaces. iText 7 represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText 7 can be a boon to nearly every workflow.
Stars: ✭ 698 (+546.3%)
Mutual labels:  pdf, pdf-generation
Pdf Generator
Cordova plugin to generate pdf in the client-side
Stars: ✭ 98 (-9.26%)
Mutual labels:  pdf, pdf-generation
Html Pdf Chrome
HTML to PDF converter via Chrome/Chromium
Stars: ✭ 629 (+482.41%)
Mutual labels:  pdf, pdf-generation
Alivepdf
[Official AlivePDF] - AlivePDF is a client side AS3 PDF generation library for Adobe Flash, Flex and AIR
Stars: ✭ 29 (-73.15%)
Mutual labels:  pdf, pdf-generation
Combine pdf
A Pure ruby library to merge PDF files, number pages and maybe more...
Stars: ✭ 552 (+411.11%)
Mutual labels:  pdf, pdf-generation
Pikepdf
A Python library for reading and writing PDF, powered by qpdf
Stars: ✭ 566 (+424.07%)
Mutual labels:  pdf, pdf-generation
Sile
Simon’s Improved Layout Engine
Stars: ✭ 1,032 (+855.56%)
Mutual labels:  pdf, pdf-generation
Jsx Pdf
Generate PDFs using JSX! 🎯
Stars: ✭ 71 (-34.26%)
Mutual labels:  pdf, pdf-generation

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

I created an example application https://github.com/benjohnde/play-pdf/tree/master/example.

You can use a standard Play! scala template like this one:

@(message: String)

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

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

public static Result document() {
    return PDF.ok(document.render("Your new application is ready."));
}

where PDF.ok is a simple shorthand notation for:

public static Result document() {
    return ok(PDF.toBytes(document.render("Your new application is ready."))).as("application/pdf")
}

Template rules

Templates must generate XHTML.

If the template is using an image, stylesheet, etc., it usually is loaded via an http call. The PDF modules tries to optimize that resource loading: If you specify the URI as a path into the classpath of your Play! app, the resource is loaded directly instead. 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.

Fonts you use must be explicitely packaged with your app.

<html>
    <head>
        <style>
            body { font-family: FreeSans; }
        </style>
    </head>
    <body>
    ...
    </body>
</html>

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

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:

git clone https://github.com/benjohnde/play-pdf.git
cd play-pdf/module
sbt publish-local

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

libraryDependencies ++= Seq(
    "de.benjohn.play" %% "pdf" % "1.1.3"
)

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

Kudos

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].