{"id":16320272,"url":"https://github.com/hellonico/lein-plugin-pdf","last_synced_at":"2025-08-01T10:38:38.576Z","repository":{"id":62433317,"uuid":"1576827","full_name":"hellonico/lein-plugin-pdf","owner":"hellonico","description":"Lein plugin to generate PDF from a set of different temple systems","archived":false,"fork":false,"pushed_at":"2011-04-17T02:26:00.000Z","size":12564,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T02:17:28.768Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellonico.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGES.textile","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-04-06T11:47:12.000Z","updated_at":"2014-03-05T11:23:34.000Z","dependencies_parsed_at":"2022-11-01T21:15:58.334Z","dependency_job_id":null,"html_url":"https://github.com/hellonico/lein-plugin-pdf","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellonico%2Flein-plugin-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellonico%2Flein-plugin-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellonico%2Flein-plugin-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellonico%2Flein-plugin-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellonico","download_url":"https://codeload.github.com/hellonico/lein-plugin-pdf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101559,"owners_count":22014908,"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":[],"created_at":"2024-10-10T22:43:47.524Z","updated_at":"2025-05-14T08:10:31.573Z","avatar_url":"https://github.com/hellonico.png","language":"Clojure","readme":"This lein plugin generates PDF based on different templating system.\r\nI did not see anything out of the box for [lein](https://github.com/technomancy/leiningen) but since I am using clojure every day at work, I thought about making a little contribution.\r\n\r\nThe idea was that you could keep the documentation you have already build and just use this plugin to generate the PDF including a set of files.\r\nThis was developed when I was asked to create documentation for a project and we had no way to be multiple user to work on it at the same time.\r\n\r\nUsing this plugin you can get people working on different section and integrates everything when wanted, without people stepping on each other's work.\r\n\r\n# Templating Support #\r\n\r\nThe following templating system are currently supported\r\n\r\n## Plain Html (*.html) \r\n\r\nWe are using [flying saucer](http://xhtmlrenderer.java.net/) to transform html to PDF and this will be the based of all our transformation in the other templates system. As far as Plain Html conversion is concerned, we are just feeding the original HTML document, links and images will be resolved and included in the generated PDF.\r\n\r\n## Markdown (*.markdown) \r\n\r\nUsing [MarkdownJ](http://code.google.com/p/markdownj/), we are converting the markdown template to HTML, in turn included in the final PDF file.\r\nHere is a reference for the [Markdown syntax](http://help.couch.it/Markdown_Syntax).\r\n\r\nMarkdown templates generated HTML will be added all the CSS in the local folders automatically along with necessary html headers.\r\n\r\n## Textile + integrated CSS (*.textile)\r\n\r\nThe lack of documentation for the [Wikitext](http://wiki.eclipse.org/Mylyn/Incubator/WikiText) java library was scary. Had to decompile code and see what method could be called. \r\nWe are using a convention here so that if a CSS file exist with the same base name as the textile template, we include it in the resulting HTML file.\r\n\r\nFor example, if we are converting a file:``test.textile`` then if there is a file named ``test.css`` it will be automatically integrated as a ``\u003cstyle\u003e`` tag in the resulting html file.\r\n\r\n## Freemarker and dynamic properties (*.ftl)\r\n\r\nThis provides support for [Freemarker](http://freemarker.sourceforge.net/) templates. Files will be converted to html using the ``.ftl`` file and some dynamic properties. See the [Dynamic Properties](#dp) section to see how to load the properties dynamically.\r\n\r\n## StringTemplate and dynamic properties (*.st)\r\n\r\nThis uses [string template](http://www.stringtemplate.org/) to generate the HTML file them again with dynamic properties integrated to make the generation dynamic. See the [Dynamic Properties](#dp) \r\n\r\n## Remote document (*.url)\r\n\r\nA text filename ending in \".url\" can contain a clojure map, like this:\r\n\r\n``{:url \"http://www.webheadstart.org/snippets/index4ef9.html?id=12\"}`` \r\n\r\nThat will point the plugin to download the document at the given URL and will include a PDF.\r\nYou can also use a proxy, the following way:\r\n\r\n\u003cpre\u003e\r\n{\r\n:url \"http://www.webheadstart.org/snippets/index4ef9.html?id=12\"\r\n:proxy-host \"221.213.50.115\"\r\n:proxy-port 8000\r\n}\r\n\u003c/pre\u003e\r\n\r\n## Clojure, Enlive templates (*.clj)\r\n\r\nThis opens the door to what ever scripting you want to do to generate the document. \r\nThe [enlive sample](src/samples/enlive/test.clj) shows how to embed the concept of templates within a clojure script. \r\n\r\n\u003cpre\u003e\r\n(apply str  (microblog-template \"Hello Enlive templates!\" \r\n               {:title \"post1\" :body \"content of post\"}))\r\n\u003c/pre\u003e\r\n\r\nThe only requirement for the script is that the return value must be the full html content of the document.\r\n\r\n## Xilize templates (*.xil)\r\n\r\nLooking at the Flying Saucer documentation in details, we realized they use another templating system, named [xilize](http://xilize.sourceforge.net/) that has some useful integration of macros in it.\r\n\r\n# Dynamic Properties\r\n\u003ca name=\"dp\"/\u003e\r\n\r\nIn case one of the template supports dynamic properties,  the plugin will look for [Yaml](http://www.yaml.org/) or [Java Properties](http://download.oracle.com/javase/6/docs/api/java/util/Properties.html).\r\nThe way it look for the properties is by taking the basename of the template and loading \u0026lt;basename\u003e.yaml and \u0026lt;basename\u003e.properties as properties to use for the template.\r\n\r\n# PDF Plugin Usage\r\n\r\n## Add to your clojure project\r\n\r\nThe plugin is on [clojars](http://clojars.org/repo/lein-doc-pdf/lein-doc-pdf/).\r\nTo add this plugin to your lein-based clojure project, here is what to put in the *project.clj* file:\r\n\r\n``[lein-doc-pdf \"1.0.10\"]``\r\n\r\nThen running \r\n\r\n``lein deps``\r\n\r\n``lein help`` \r\n\r\nwill display the new task:\r\n\r\n``pdf         Convert text document under different markup languages to PDF``\r\n\r\n## Run it\r\n\r\n### Basic\r\nTo run the task, just type\r\n\r\n``lein pdf``\r\n\r\nBy default, this will pick up all the templates in a folder named ``src/doc`` and generate a resulting PDF. The order of the pages is computed by the order of the filename on the filesystem.\r\n\r\nYou can also specify a different folder, for example:\r\n\r\n``lein pdf src/my-templates``\r\n\r\nThe name of the resulting pdf file will be based on the name of the folder.\r\n\r\n### Support for project metadata\r\n\r\nYou can add the following parameters in your ``project.clj`` file:\r\n\r\n* output-file: the name of the file to output \r\n* fonts-folder: the place to load font for the resulting PDF. Those fonts will be included in the resulting file\r\n* input-files: the source folder, or file to load templates from. If this points to a folder, this will include all the files in that folder.\r\n\r\nProfiles are also supported. So if you define something like this in your project.clj file:\r\n\u003cpre\u003e\r\n:doc-pdf {\r\n  :samples-remote {\r\n  \t:input-files \"src/samples/remote\"    \r\n  \t:output-file \"classes/remote.pdf\"\r\n      :fonts-folder \"src/fonts\"\r\n  }\r\n  :changes {\r\n      :input-files \"CHANGES.textile\"\r\n      :output-file \"changes.pdf\"\r\n      :style \"src/style/changes.jar/changes.jar\"\r\n  }\r\n\u003c/pre\u003e\r\n\r\nThen you can use the following\r\n\r\n``lein pdf :changes`` \r\n\r\nTo use the settings from the :changes submap of the :doc-pdf map.\r\n\r\n### Support for utf-8\r\n\r\nYou need to force the JVM to use the file encoding to handle encoding characters along those line:\r\n``export JAVA_OPTS=\"-Dfile.encoding=utf-8\" ; lein pdf``\r\n\r\nThen the JVM will pick up the proper encoding to handle files and will display the fonts in the resulting document.\r\n\r\n### Support for styles\r\n\r\nProject metadata supports styles in the following way:\r\n\r\n``:style \"src/style/changes\"``\r\n\r\nor\r\n\r\n``:style \"src/style/changes.jar/changes.jar\"``\r\n\r\nThe content of the changes, changes.zip or changes.jar style is a set of resources that you can distribute and reuse throughout \r\ndifferent sets of documents.\r\n\r\nAt runtime, the content of the folder or archive is extracted to the working directory, and all useful resources are included.\r\nWhen the run is finished, those resources are being cleaned up.\r\n \r\nYou can overwrite a partial set of those resources by using the same file name, in this case, that resource will not be deleted.\r\n\r\n### Support for encryption\r\n\r\nThe following set of metadata:\r\n\r\n``:encryption {:userpassword \"user\" :ownerpassword \"owner\" :strength true :permissions 0}``\r\n\r\nwill encrypt the resulting PDF with the given password. \r\n\r\n### Support for signature\r\n\r\nThe following set of metadata:\r\n\r\n``:sign {:keystore \"src/security/keystore.sample\" :password \"nicolas\" :keyalias \"docpdf\" :keypwd \"nicolas\" :certificate \"docpdf\"}``\r\n\r\nwill sign the document with the key and certificate contained in the given keystore.\r\nThis is very basic at the moment.\r\n\r\n### Interactive development\r\n\r\nStart lein in interactive mode:\r\n\r\n``lein interactive``\r\n\r\nAnd you can now use and re-use the ``pdf`` commands without restarting the JVM.\r\n\r\n### Automatic Recreation of PDF\r\n\r\nYou can use the command \r\n\r\n``lein pdf @\u003cprofile-name\u003e``\r\n\r\nAnd the plugin will start polling in the directory which is the parent of the input-file of the profile.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellonico%2Flein-plugin-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellonico%2Flein-plugin-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellonico%2Flein-plugin-pdf/lists"}