{"id":18769723,"url":"https://github.com/aleksandr-m/struts2-pdfstream","last_synced_at":"2025-04-13T07:31:41.996Z","repository":{"id":25124580,"uuid":"28546353","full_name":"aleksandr-m/struts2-pdfstream","owner":"aleksandr-m","description":"A Struts2 plugin for creating PDF-s from HTML-s, JSP-s, FreeMarker templates and Apache Tiles definitions.","archived":false,"fork":false,"pushed_at":"2023-06-14T20:22:55.000Z","size":506,"stargazers_count":12,"open_issues_count":2,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-01T12:36:51.300Z","etag":null,"topics":["apache-tiles","freemarker","jsp","openhtmltopdf","pdf","pdfbox","struts2","struts2-plugin"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aleksandr-m.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":"2014-12-27T21:06:21.000Z","updated_at":"2023-09-07T17:19:29.000Z","dependencies_parsed_at":"2022-08-23T02:21:33.909Z","dependency_job_id":null,"html_url":"https://github.com/aleksandr-m/struts2-pdfstream","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksandr-m%2Fstruts2-pdfstream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksandr-m%2Fstruts2-pdfstream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksandr-m%2Fstruts2-pdfstream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksandr-m%2Fstruts2-pdfstream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aleksandr-m","download_url":"https://codeload.github.com/aleksandr-m/struts2-pdfstream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223573740,"owners_count":17167370,"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":["apache-tiles","freemarker","jsp","openhtmltopdf","pdf","pdfbox","struts2","struts2-plugin"],"created_at":"2024-11-07T19:16:45.009Z","updated_at":"2024-11-07T19:16:45.760Z","avatar_url":"https://github.com/aleksandr-m.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Struts2 PDF Stream Plugin\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.amashchenko.struts2.pdfstream/struts2-pdfstream-plugin/badge.svg?subject=Maven%20Central)](https://maven-badges.herokuapp.com/maven-central/com.amashchenko.struts2.pdfstream/struts2-pdfstream-plugin/)\n[![License](https://img.shields.io/badge/License-Apache%20License%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n\nThe PDF Stream plugin allows to transform a view into a PDF stream and return it as a result from Action.\n\nDefault supported views:\n\n- HTML\n- JSP\n- FreeMarker template\n- Apache Tiles definition\n\n\n## Struts2 PDF Stream v2\n\n#### Apache PDFBox 2\n\nStarting from 2.0.0, HTML into PDF rendering is done by the [openhtmltopdf](https://github.com/danfickle/openhtmltopdf) library which uses the [Apache PDFBox 2](https://pdfbox.apache.org/) to create PDF documents.\nApache PDFBox 2 is an open source Java tool for working with PDF documents and it is published under the Apache License v2.0.\n\n#### Apache Struts 2.5\n\nUpgraded to be compatible with Apache Struts 2.5\n\n#### Java 7\n\nSwitched to Java 7 \n\n\n\n## Features Overview\n\n- Direct transformation of HTML, JSP, FreeMarker template and Apache Tiles definition to PDF via Struts2 result\n- PDF content styling using CSS\n- Support of wide range of characters in PDF thanks to the [DejaVu fonts](https://dejavu-fonts.github.io/)\n- Handling of the malformed HTML thanks to the [jsoup](https://jsoup.org/)\n\n\n## Showcase\n\nShowcase application can be downloaded from the Maven Central Repository.\n\n[Download struts2-pdfstream-showcase](https://search.maven.org/remotecontent?filepath=com/amashchenko/struts2/pdfstream/struts2-pdfstream-showcase/2.0.0/struts2-pdfstream-showcase-2.0.0.war)\n\n\n## Contributing\n\nFound a bug or have a feature request? [Create a new issue](https://github.com/aleksandr-m/struts2-pdfstream/issues/new) or submit a [Pull Request](https://github.com/aleksandr-m/struts2-pdfstream/pulls).\n\n## Questions\n\nIf you have questions about how to use `struts2-pdfstream-plugin` [create a new issue](https://github.com/aleksandr-m/struts2-pdfstream/issues/new) or ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/struts2-pdfstream-plugin).\n\n\n## Installation\n\nCopy following jars into your classpath (WEB-INF/lib):\n\n- struts2-pdfstream-plugin-2.0.0.jar\n- jsoup-1.9.2.jar\n- openhtmltopdf-core-0.0.1-RC4.jar\n- openhtmltopdf-pdfbox-0.0.1-RC4.jar\n- pdfbox-2.0.0.jar\n- fontbox-2.0.0.jar\n\nIf you are using Maven, add this to your project POM:\n\n    \u003cdependencies\u003e\n        ...\n        \u003cdependency\u003e\n            \u003cgroupId\u003ecom.amashchenko.struts2.pdfstream\u003c/groupId\u003e\n            \u003cartifactId\u003estruts2-pdfstream-plugin\u003c/artifactId\u003e\n            \u003cversion\u003e2.0.0\u003c/version\u003e\n        \u003c/dependency\u003e\n        ...\n    \u003c/dependencies\u003e\n\nIf you intend to transform Apache Tiles definition additional jar must be included.\n\nFor the Apache Tiles support add the `struts2-pdfstream-tiles`.\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.amashchenko.struts2.pdfstream\u003c/groupId\u003e\n        \u003cartifactId\u003estruts2-pdfstream-tiles\u003c/artifactId\u003e\n        \u003cversion\u003e2.0.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\n\n## Usage\n\n1. Install this plugin by adding dependency to your POM or by copying jars into /WEB-INF/lib directory.\n2. Make your action package extend `pdfstream-default` package or add `pdfstream` result type.\n3. Use `pdfstream` result type.\n\n\n## Examples\n\n### JSP to PDF stream\n\n    \u003caction name=\"jspToPdf\"\u003e\n        \u003cresult type=\"pdfstream\"\u003e\n            \u003cparam name=\"location\"\u003e/WEB-INF/pages/example.jsp\u003c/param\u003e\n            \u003cparam name=\"cssPaths\"\u003ecss/bootstrap.min.css, css/style.css\u003c/param\u003e\n            \u003cparam name=\"contentDisposition\"\u003eattachment;filename=jsppdf.pdf\u003c/param\u003e\n        \u003c/result\u003e\n    \u003c/action\u003e\n    \n### HTML to PDF stream\n\n    \u003caction name=\"htmlToPdf\"\u003e\n        \u003cresult type=\"pdfstream\"\u003e\n            \u003cparam name=\"location\"\u003e/WEB-INF/pages/example.html\u003c/param\u003e\n            \u003cparam name=\"cssPaths\"\u003ecss/bootstrap.min.css, css/style.css\u003c/param\u003e\n            \u003cparam name=\"contentDisposition\"\u003eattachment;filename=htmlpdf.pdf\u003c/param\u003e\n        \u003c/result\u003e\n    \u003c/action\u003e\n\n### Tiles definition to PDF stream\n\n    \u003caction name=\"tilesToPdf\"\u003e\n        \u003cresult type=\"pdfstream\"\u003e\n            \u003cparam name=\"location\"\u003eexample\u003c/param\u003e\n            \u003cparam name=\"renderer\"\u003etiles\u003c/param\u003e\n            \u003cparam name=\"contentDisposition\"\u003eattachment;filename=tilespdf.pdf\u003c/param\u003e\n        \u003c/result\u003e\n    \u003c/action\u003e\n\n### FreeMarker template to PDF stream\n\n    \u003caction name=\"freemarkerToPdf\"\u003e\n        \u003cresult type=\"pdfstream\"\u003e\n            \u003cparam name=\"location\"\u003e/WEB-INF/ftl/example.ftl\u003c/param\u003e\n            \u003cparam name=\"renderer\"\u003efreemarker\u003c/param\u003e\n            \u003cparam name=\"cssPaths\"\u003ecss/bootstrap.min.css, css/style.css\u003c/param\u003e\n            \u003cparam name=\"contentDisposition\"\u003eattachment;filename=ftlpdf.pdf\u003c/param\u003e\n        \u003c/result\u003e\n    \u003c/action\u003e\n\n\n\n## Extending the plugin\n### Adding support for other views\n\nThis plugin can be easily extended in order to add support for transforming other views (e.g. Velocity) into PDF.\n\n1. Implement `com.amashchenko.struts2.pdfstream.ViewRenderer` interface.\n2. Create bean definition in struts.xml or in struts-plugin.xml with `type=\"com.amashchenko.struts2.pdfstream.ViewRenderer\"` and custom name.\n\n        \u003cbean type=\"com.amashchenko.struts2.pdfstream.ViewRenderer\" \n              class=\"some.package.CustomRenderer\" name=\"customrenderer\" /\u003e\n\n3. Use `pdfstream` result with the `renderer` parameter set to the name of the bean you have defined.\n\n        \u003caction name=\"customToPdf\"\u003e\n            \u003cresult type=\"pdfstream\"\u003e\n                \u003cparam name=\"location\"\u003eexample\u003c/param\u003e\n                \u003cparam name=\"renderer\"\u003ecustomrenderer\u003c/param\u003e\n            \u003c/result\u003e\n        \u003c/action\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleksandr-m%2Fstruts2-pdfstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faleksandr-m%2Fstruts2-pdfstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleksandr-m%2Fstruts2-pdfstream/lists"}