{"id":13705212,"url":"https://github.com/marrek13/kotenberg","last_synced_at":"2025-12-27T13:34:09.211Z","repository":{"id":209944584,"uuid":"725321953","full_name":"marrek13/kotenberg","owner":"marrek13","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-12T09:12:50.000Z","size":713,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-12T09:31:40.526Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marrek13.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-29T22:40:01.000Z","updated_at":"2024-11-12T09:12:35.000Z","dependencies_parsed_at":"2023-12-24T08:24:52.761Z","dependency_job_id":"10832d60-d55d-4fbf-b5cb-70a2df4b65e9","html_url":"https://github.com/marrek13/kotenberg","commit_stats":null,"previous_names":["marrek13/kotenberg"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marrek13%2Fkotenberg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marrek13%2Fkotenberg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marrek13%2Fkotenberg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marrek13%2Fkotenberg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marrek13","download_url":"https://codeload.github.com/marrek13/kotenberg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224455794,"owners_count":17314186,"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-08-02T22:00:35.503Z","updated_at":"2025-12-27T13:34:09.203Z","avatar_url":"https://github.com/marrek13.png","language":"Kotlin","funding_links":[],"categories":["Clients"],"sub_categories":[],"readme":"# Kotenberg\n\n[![build](https://github.com/marrek13/kotenberg/actions/workflows/build.yml/badge.svg)](https://github.com/marrek13/kotenberg/actions/workflows/build.yml)\n\nA Kotlin library that interacts with [Gotenberg](https://gotenberg.dev/)'s different modules to convert a variety of document formats to PDF files.\n\n## Snippets\nTo incorporate `kotenberg` into your project, follow the snippets below for Gradle dependencies.\n\n### Gradle Kotlin DSL\n```kotlin\nrepositories {\n    maven {\n        url = uri(\"https://maven.pkg.github.com/marrek13/kotenberg\")\n        credentials {\n            username = project.findProperty(\"gpr.user\")?.toString() ?: System.getenv(\"GITHUB_USERNAME\")\n            password = project.findProperty(\"gpr.key\")?.toString() ?: System.getenv(\"GITHUB_TOKEN\")\n        }\n    }\n}\n\ndependencies {\n    implementation(\"dev.marrek13:kotenberg:1.0.0\")\n}\n```\n\n## Prerequisites\n\nBefore attempting to use `Kotenberg`, be sure you install [Docker](https://www.docker.com/) if you have not already done so.\n\nOnce the docker Daemon is up and running, you can start a default Docker container of [Gotenberg](https://gotenberg.dev/) as follows:\n\n```bash\ndocker run --rm -p 8090:8090 gotenberg/gotenberg:7 gotenberg --api-port=8090\n```\n\nAfter that, you need to download the latest `Kotenberg` JAR library from the GitHub [Releases](https://github.com/marrek13/kotenberg/releases) page and add it to your Java project `classpath`.\n\n## Get Started\n\nCreate an instance of `Kotenberg` class and pass your `Gotenberg` `endpoint` url as a constructor parameter.\n\n```kotlin\nval client = Kotenberg(\"http://localhost:8090/\")\n```\n\n### Chromium\n\n`Kotenberg` client comes with a `convertUrl`, `convertHtml` and `convertMarkdown` methods that call one of Chromium's [routes](https://gotenberg.dev/docs/modules/chromium#routes) to convert `html` and `markdown` files, or a `url` to a `CloseableHttpResponse` that contains the `HttpEntity` which holds the content of the converted PDF file.\n\n`convert` expects two parameters; the first parameter represents what will be converted (i.e. `url`, `html`, or `markdown` files), and the second one is a `PageProperties` parameter.\n\n#### URL\n\n```kotlin\nval response = client.convertUrl(\"https://gotenberg.dev/\")\n```\n\n#### HTML\n\nThe only requirement is that one of the files name should be `index.html`.\n\n```kotlin\nval index = File(\"path/to/index.html\")\nval header = File(\"path/to/header.html\")\nval response = client.convertHtml(listOf(index, header))\n```\n\n#### Markdown\n\nThis route accepts an `index.html` file plus markdown files. Check [Gotenberg docs](https://gotenberg.dev/docs/routes#markdown-files-into-pdf-route) for details.\n\n```kotlin\nval index = File(\"path/to/index.html\")\nval markdown = File(\"path/to/markdown.md\")\n\nval response = client.convertMarkdown(listOf(index, markdown))\n```\n\n### Customization\n\n`Kotenberg` client comes with `PageProperties` which is a builder class that allows you to customize the style of the generated PDF. The default page properties can be found [here](https://gotenberg.dev/docs/routes#page-properties-chromium).\n\n```kotlin\nval pageProperties = PageProperties.Builder().build()\nval response = client.convertMarkdown(listOf(index), pageProperties)\n```\n### LibreOffice\n`Kotenberg` client provides a `convertWithLibreOffice` method which interacts with [LibreOffice](https://gotenberg.dev/docs/routes#convert-with-libreoffice) to convert different types of documents such as `.docx`, `.epub`, `.eps`, and so on. You can find the list of all file extensions [here](https://gotenberg.dev/docs/routes#office-documents-into-pdfs-route).\n\n```kotlin\nval docx = File(\"path/to/file.docx\")\nval xlsx = File(\"path/to/file.xlsx\")\n\nval response = client.convertWithLibreOffice(listOf(docx, xlsx))\n```\n\n### PDF Engines\nSimilarly, `Kotenberg` client provides a `convertWithPdfEngines` method which interacts with [PDF Engines](https://gotenberg.dev/docs/routes#office-documents-into-pdfs-route) to convert PDF files to a specific format (i.e. `PDF/A-1a`, `PDF/A-2b`, `PDF/A-3b`)).\n\nThe supported formats can be found in `PdfFormat`.\n\n```kotlin\nval pdf1 = File(\"path/to/first.pdf\")\nval pdf2 = File(\"path/to/second.pdf\")\n\nval pageProperties = PageProperties.Builder()\n    .addPdfFormat(PdfFormat.A_3B.format())\n    .build()\n\nval response = client.convertWithPdfEngines(listOf(pdf1, pdf2), pageProperties)\n```\n\nAdditionally, you can also use `mergeWithPdfEngines` method to [alphabetically](https://gotenberg.dev/docs/routes#merge-pdfs-route) merge the PDF files.\n\n```kotlin\nval pdf1 = File(\"path/to/first.pdf\")\nval pdf2 = File(\"path/to/second.pdf\")\n\nval response = client.mergeWithPdfEngines(listOf(pdf1, pdf2))\n```\n\n## DSL API\n\nKotenberg provides a Kotlin DSL for more concise code:\n\n```kotlin\n// URL conversion\nval response = client.url(\"https://example.com\") {\n    pageProperties {\n        landscape = true\n        margins(1f)\n    }\n}\n\n// HTML conversion\nval response = client.html {\n    +\"index.html\"\n    +\"header.html\"\n    pageProperties {\n        printBackground = true\n    }\n}\n\n// PDF merge\nval response = client.mergePdfs {\n    files(\"doc1.pdf\", \"doc2.pdf\")\n    pageProperties {\n        pdfUniversalAccess = true\n    }\n}\n```\n\nAvailable methods: `html {}`, `url {}`, `markdown {}`, `libreOffice {}`, `pdfEngines {}`, `mergePdfs {}`\n\nThe DSL is fully backward compatible - all existing code continues to work.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarrek13%2Fkotenberg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarrek13%2Fkotenberg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarrek13%2Fkotenberg/lists"}