From 0cd215cfe71521ce25f8d77eac4fe03b98d051cb Mon Sep 17 00:00:00 2001 From: Dechen-Choden Date: Wed, 11 Sep 2024 13:39:47 +0600 Subject: [PATCH 1/2] Fonts and style note on gotenberg --- README.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 230197a..6679881 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # gotenberg -According to the official documentation, Gotenberg is a Docker-powered stateless API for PDF files. It offers a developer-friendly API that utilizes powerful tools like Chromium and LibreOffice to convert various document formats (such as HTML, Markdown, Word, Excel, and more) into PDF files and beyond. The gotenberg gem is a simple Ruby client for interacting with this API. Gotenberg provides multiple APIs for tasks such as converting HTML to PDF, URL to PDF, Markdown to PDF, and more. +According to the official documentation, Gotenberg is a Docker-powered stateless API for PDF files. It offers a developer-friendly API that utilizes powerful tools like Chromium and LibreOffice to convert various document formats (such as HTML, Markdown, Word, Excel, and more) into PDF files and beyond. The gotenberg gem is a simple Ruby client for interacting with this API. Gotenberg provides multiple APIs for tasks such as converting HTML to PDF, URL to PDF, Markdown to PDF, and more. Currently, this gem only supports the HTML conversion to PDF and health endpoint APIs. This gem seamlessly integrates the Rails asset pipeline with Gotenberg's requirements for HTML and assets and includes useful helper methods for assets which can be used in `.erb` files or other Ruby classes. @@ -122,6 +122,31 @@ gem 'gotenberg' 2. `GOTENBERG_API_BASIC_AUTH_USERNAME='username'` 3. `GOTENBERG_API_BASIC_AUTH_PASSWORD='password'` +9. Fonts + 1. Use `Base64` encoding so that the font file is embedded directly in the CSS file, eliminating the need for an external font file. + ```html + Example: + @font-face { + font-family: "AvenirNextLTPro-Regular"; + src: url('AvenirNextLTPro-Regular.otf?base64, ') format('opentype'); + } + ``` + 2.Use `goten_static_asset_path` to generates a URL or path to the static version of the asset, typically in its original form without any modifications from the build process. It points to the location of the raw, uncompiled version of the font files. + ```html + Example: + goten_static_asset_path('AvenirNextLTPro-Regular.otf'), + ``` + +10. Styling + 1. By default, Pdf Layout has 1 inch margin in all the sides, to modify use `@page` css property. + ```html + Example: + @page { + margin-top: 100px; + margin-bottom: 60px; + } + ``` + ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/SELISEdigitalplatforms/gotenberg.git From 65349007d630306c780ca18e453436475ddc19a9 Mon Sep 17 00:00:00 2001 From: Dechen-Choden Date: Wed, 11 Sep 2024 13:59:04 +0600 Subject: [PATCH 2/2] Fonts and style note on gotenberg --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6679881..351344b 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ gem 'gotenberg' src: url('AvenirNextLTPro-Regular.otf?base64, ') format('opentype'); } ``` - 2.Use `goten_static_asset_path` to generates a URL or path to the static version of the asset, typically in its original form without any modifications from the build process. It points to the location of the raw, uncompiled version of the font files. + 2.Use `goten_static_asset_path` to generates a URL or path to the static version of the fonts, typically in its original form without any modifications from the build process. ```html Example: goten_static_asset_path('AvenirNextLTPro-Regular.otf'), @@ -146,7 +146,12 @@ gem 'gotenberg' margin-bottom: 60px; } ``` - + 2. For different pdf if you need different layout and styling, make multiple scss or css files for each pdf. + ```html + Example: + goten_compiled_asset_path('pdf/pdf1.css'), + goten_compiled_asset_path('pdf/pdf2.css'), + ``` ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/SELISEdigitalplatforms/gotenberg.git