Play 2.3.x PDF : Basic example for generating PDF documents dynamically from Play Application with the help of play2-pdf module


Knoldus

alt tag

In this blog I have created a basic example for generating PDF documents dynamically from Play Application with the help of play2-pdf module

Play 2.3.x PDF module: 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

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

@(message: String)

@main("Play!ng PDF") {
    Image: <imgsrc="/public/images/favicon.png"/><br/>
    Hello world! <br/>
    @message <br/>
}

Check the below template list for more complex template design:

  1. Letter PDF
  2. News Letter PDF

Then this template, after having imported it.innove.PdfGenerator, can simply be rendered as:

defletter:Action[AnyContent] =Action { implicit request =>Ok(PdfGenerator.toBytes(views.html.letter("

View original post 281 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s