0

How to use a module written in java to be used in scala playframework project(for ex pdf module in playframework only available for java)

1 Answer 1

1

I don't think there is a clear distinction between java/scala modules in play 2.x, although you may experience some problems running modules labeled as "scala" in java project and vice versa.

I have used pdf module just OK in scala project, my dependency is "pdf" % "pdf_2.10" % "0.5", Following Action renders pdf from sample template named testPdf:

def renderSamplePdf() =   Action {      
    SimpleResult(
        header = ResponseHeader(OK, Map(
            CONTENT_DISPOSITION -> (s"""attachment; filename="document.pdf"; filename*=UTF-8''""" + java.net.URLEncoder.encode("document.pdf", "UTF-8").replace("+", "%20")),
            CONTENT_TYPE -> "application/pdf")),
            body =  Enumerator(PDF.toBytes(views.html.testPdf())))
}

Note that this module version has some bugs, like it produces errors when you use absolute positioned elements.

Sign up to request clarification or add additional context in comments.

1 Comment

in play 2.3 SimpleResult renamed as Result...github.com/playframework/playframework/pull/2526

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.