https://github.com/luabagg/orcgen
Web pages and HTML content conversion
https://github.com/luabagg/orcgen
file-conversion html-to-image html-to-image-converter html-to-pdf html-to-pdf-converter
Last synced: 5 months ago
JSON representation
Web pages and HTML content conversion
- Host: GitHub
- URL: https://github.com/luabagg/orcgen
- Owner: luabagg
- License: mit
- Created: 2022-12-28T00:40:45.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-11-22T04:00:03.000Z (6 months ago)
- Last Synced: 2025-11-22T05:34:27.643Z (6 months ago)
- Topics: file-conversion, html-to-image, html-to-image-converter, html-to-pdf, html-to-pdf-converter
- Language: Go
- Homepage: https://pkg.go.dev/github.com/luabagg/orcgen
- Size: 4.34 MB
- Stars: 13
- Watchers: 1
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Orcgen
Orcgen is a Go package that enables an easy-to-use conversion of web pages and HTML content to various file formats like PDF, PNG, and JPEG.
The underlying implementation uses the [Rod library](https://github.com/go-rod/rod) for the page conversion.
## Functionalities and packages
Orcgen provides the following functionalities:
- Conversion of web pages and HTML content to a static file (PNG, PDF...).
- This can be done simply using the Generate function, but if you need
prior configuration, you can access all the webdriver functionalities.
- You can also use the other functions at orcgen.go, as specified in the examples page.
### Package folder
- FileInfo:
A struct to standardize the returns and file saves.
There's a Output function that writes the content to a output file.
- Handlers:
The implementations of the page file save functionality (PDF / Screenshots).
- Webdriver:
Simple wrapper over rod library.
## Installation
To use Orcgen, you can install it via Go modules:
```sh
go get github.com/luabagg/orcgen/v2
```
Then you can import it in your Go code:
```go
import "github.com/luabagg/orcgen/v2"
```
## Usage Example
```go
import "github.com/luabagg/orcgen/v2"
// Webpage conversion
orcgen.Generate(
"https://www.github.com",
orcgen.ScreenshotConfig{
Format: "webp",
},
"github.webp",
)
// HTML conversion
orcgen.Generate(
[]byte("my html"),
orcgen.PDFConfig{
Landscape: true,
PrintBackground: true,
PreferCSSPageSize: true,
},
"html.pdf",
)
```
The package comes with examples that demonstrate the usage of the various functions and features provided by Orcgen. It's the way-to-go if you're trying to use this package for the first time.
You can see more in [examples_test.go](https://github.com/luabagg/orcgen/tree/main/examples_test.go) page.
## Contributors
This project is an open-source project, and contributions from other developers are welcome. If you encounter any issues or have suggestions for improvement, please submit them on the project's GitHub page.