{"id":17188777,"url":"https://github.com/benjohnde/play-pdf","last_synced_at":"2025-04-13T19:22:54.625Z","repository":{"id":3330098,"uuid":"4373734","full_name":"benjohnde/play-pdf","owner":"benjohnde","description":"A PDF module for the Play framework","archived":false,"fork":false,"pushed_at":"2018-01-26T14:51:38.000Z","size":14948,"stargazers_count":109,"open_issues_count":0,"forks_count":68,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-06T19:39:52.605Z","etag":null,"topics":["java","pdf","pdf-generation","play-framework","playframework"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"nbessi/oerpscenario","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benjohnde.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-18T21:29:32.000Z","updated_at":"2025-01-02T22:53:34.000Z","dependencies_parsed_at":"2022-09-21T12:00:41.651Z","dependency_job_id":null,"html_url":"https://github.com/benjohnde/play-pdf","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjohnde%2Fplay-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjohnde%2Fplay-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjohnde%2Fplay-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjohnde%2Fplay-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benjohnde","download_url":"https://codeload.github.com/benjohnde/play-pdf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766688,"owners_count":21158302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","pdf","pdf-generation","play-framework","playframework"],"created_at":"2024-10-15T01:09:50.369Z","updated_at":"2025-04-13T19:22:54.595Z","avatar_url":"https://github.com/benjohnde.png","language":"Java","readme":"# play-pdf\n\nThis module helps generating PDF documents dynamically from your Play! web application.\nIt simply renders your HTML- and CSS-based templates to PDF.\nIt is based on the Flying Saucer library, which in turn uses iText for PDF generation.\n\n## Usage\n\nI created an example application https://github.com/benjohnde/play-pdf/tree/master/example.\n\nYou can use a standard Play! scala template like this one:\n```html\n@(message: String)\n\n@main(\"Welcome to Play 2.6.2\") {\n    Image: \u003cimg src=\"/public/images/favicon.png\"/\u003e\u003cbr/\u003e\n    Hello world! \u003cbr/\u003e\n    @message \u003cbr/\u003e\n}\n```\n\nThen this template, after having imported `de.benjohn.play.pdf.PDF`, can simply be rendered as:\n\n```java\npublic static Result document() {\n    return PDF.ok(document.render(\"Your new application is ready.\"));\n}\n```  \nwhere ```PDF.ok``` is a simple shorthand notation for:\n```java\npublic static Result document() {\n    return ok(PDF.toBytes(document.render(\"Your new application is ready.\"))).as(\"application/pdf\")\n}\n```\n\n## Template rules\n\nTemplates must generate XHTML.\n\nIf the template is using an image, stylesheet, etc., it usually is loaded via an http call.\nThe PDF modules tries to optimize that resource loading:\nIf you specify the URI as a path into the classpath of your Play! app, the resource is loaded directly instead.\nSee the above sample template for an example.\n\nOf course you can link to CSS files in your class path also, but be aware not to\nuse the `media=\"screen\"` qualifier.\n\nFonts you use must be explicitely packaged with your app.\n\n```html\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003cstyle\u003e\n            body { font-family: FreeSans; }\n        \u003c/style\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n    ...\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nThe module imports font resources as specified in your [application configuration](https://github.com/benjohnde/play-pdf/blob/master/example/conf/application.conf).\n\nSpecify fonts as follows:\n\n```bash\npdf.fonts = [\"Arial.ttf\", \"Helvetica.ttf\"]\n```\n\nEach font file should be placed in your Play app configuration folder, so that they will be included.\nSee also the example project.\n\n## Installation\n\nCurrently the module is not hosted anywhere. In order to use it, you need to publish it locally in the current play-maven-repository. Therefore:\n\n```bash\ngit clone https://github.com/benjohnde/play-pdf.git\ncd play-pdf/module\nsbt publish-local\n```\n\nThen, add to your libraryDependencies in your `build.sbt`:\n\n```scala\nlibraryDependencies ++= Seq(\n    \"de.benjohn.play\" %% \"pdf\" % \"1.1.3\"\n)\n```\n\nAfter the next restart of the `sbt`, the module should be available.\nIf you are using an IDE like Eclipse, remember to re-generate your project files.\n\n## Kudos\n\n- [joergviola](https://github.com/joergviola) initial creator of this project\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjohnde%2Fplay-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenjohnde%2Fplay-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjohnde%2Fplay-pdf/lists"}