Giter VIP home page Giter VIP logo

orcgen's Introduction

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 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:

    go get github.com/luabagg/orcgen

Then you can import it in your Go code:

    import "github.com/luabagg/orcgen"

Usage Example

    import "github.com/luabagg/orcgen"

    // Webpage conversion
    orcgen.Generate(
        "https://www.github.com",
        proto.PageCaptureScreenshot{
            Format: proto.PageCaptureScreenshotFormatWebp,
        },
        "github.webp",
    )

    // HTML conversion
    orcgen.Generate(
        []byte("my html"),
        proto.PagePrintToPDF{
            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 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.

orcgen's People

Contributors

luabagg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

orcgen's Issues

multi page pdf

When i have an html that needs more than one page it creates only the first page

Modify the project to admit configurations per type of output

Hi,

I am eyeballing utilizing this package for a prototype I am building at my current workplace to generate PDFs from a dynamically generated HTML.

As it stands today, the package allows to generate such PDFs nicely. However, I would like to be able to configure the output, namely, I would like to configure DisplayHeaderFooter. Currently, there is only one configuration available (for all types of output) that is SetFullPage. I have been dabbling in different ways to propose a change to the project to do properly dependency injection. However, it is clear that doing dependency injection would affect the main interface of the package becoming a breaking change.

I was wondering how would you approach this and how willing to accept these type of breaking changes. If you are positive to that, I could take a stab at it.

What I am thinking on is the following:

  • Simplifying the Generator interface to just Generate function.
  • Creating a Configurator interface that defines a Configure method. Such would be implemented in the specific generators themselves.
  • Deprecate SetFullPage by de-coupling from the Generator interface and let Configure do its thing instead.
  • Inject the configuration at instantiation time depending on the type of builder.

Do you have any thoughts on this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.