Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neroist/nim-wkhtmltox
Nim bindings to wkhtmltox
https://github.com/neroist/nim-wkhtmltox
bindings html image nim pdf wkhtmltoimage wkhtmltopdf wkhtmltox wrapper
Last synced: 1 day ago
JSON representation
Nim bindings to wkhtmltox
- Host: GitHub
- URL: https://github.com/neroist/nim-wkhtmltox
- Owner: neroist
- License: lgpl-3.0
- Created: 2023-04-26T15:27:40.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-10T15:36:40.000Z (over 1 year ago)
- Last Synced: 2024-12-12T12:06:45.548Z (about 2 months ago)
- Topics: bindings, html, image, nim, pdf, wkhtmltoimage, wkhtmltopdf, wkhtmltox, wrapper
- Language: Nim
- Homepage:
- Size: 46.6 MB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nim-wkhtmltox
Nim bindings to wkhtmltox.
## Distributing
This library depends on the wkhtmltox DLL, so please package it when distributing
your application.You can use `-d:wkImageLib` and `-d:wkPdfLib` to control what directory the DLLs are
looked for, for the `image` and `pdf` submodules respectively.## Get Started
You can get started with the examples listed here or in the
[`examples/`](examples) directory.## Documentation
Follow libwkhtmltox's directly [here](https://wkhtmltopdf.org/libwkhtmltox/)
([*Archive*](https://web.archive.org/web/20221218055802/https://wkhtmltopdf.org/libwkhtmltox/))## Examples
To PDF:
```nim
import nimwkhtmltox/pdfinitPdf()
# from w3schools
let content = """
h1 {
color: blue;
font-family: verdana;
font-size: 300%;
}p {
color: red;
font-family: courier;
font-size: 160%;
}
This is a heading
This is a paragraph.
"""
let settings = createGlobalSettings()
settings.setGlobalSetting("out", "./index.pdf")let conv = createConverter(settings)
let objSettings = createObjectSettings()
conv.addObject(objSettings, content)
conv.convert()
deinitPdf()
``````nim
import nimwkhtmltox/pdfinitPDF()
toPDF(
"https://wkhtmltopdf.org/libwkhtmltox/pagesettings.html",
createGlobalSettings({
"out": "pagesettings.pdf"
})
)deinitPDF()
```To Image:
```nim
import nimwkhtmltox/imageinitImage()
let settings = createGlobalSettings()
settings.setGlobalSettings({
"in": "https://spdx.org/licenses/LGPL-3.0-or-later.html",
"out": "license.png",
"fmt": "png"
})let conv = createConverter(settings, "")
conv.convert()
deinitImage()
``````nim
import nimwkhtmltox/imageinitImage()
toImage(
"https://github.com/neroist/nim-wkhtmltox",
createGlobalSettings({
"out": "nim-wkhtmltox.png",
"fmt": "png"
})
)deinitImage()
```