Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to resolve Images/Css locally #91

Open
schmitch opened this issue Apr 28, 2017 · 2 comments
Open

Add a way to resolve Images/Css locally #91

schmitch opened this issue Apr 28, 2017 · 2 comments

Comments

@schmitch
Copy link
Contributor

schmitch commented Apr 28, 2017

Currently it would be great if there was a way to have a CssProvider and a ImageProvider,
that can actually resolve images and fonts.

Consider a HTML with multiple Images that have relative paths like: images/my_image.png it would be amazing if one could resolve them locally without making a URL request, like it's done in iText via:

new AbstractImageProvider() {
    @Override
    public String getImageRootPath() {
        return environmentPath("/my_path");
     }

    @Override
     public Image retrieve(String src) {
        if (src.startsWith("/barcode/delivery/")) {
            String type = src.substring(18);
            return barcode((DeliveryRequest) data, writer, type);
        } else {
            return super.retrieve(src);
        }
    }
}

this would also give the possibility to create a image dynamically.

Same goes for CSS. (Currently the only way is to override the httpStreamImplementation, which works for Images only I guess. And a CSS should be providable without being inside the html)

@ieugen
Copy link
Contributor

ieugen commented Apr 28, 2017

Hi @schmitch ,

Annother use case would be to resolve the resources in memory, not necessary on disk.
We use wkhtmltopdf and generate custom CSS per report. With wkhtmltopdf we need to write it to disk.
Since it is a temporary file, it will be removed after the report is generated.

Having the ability to plug in resolvers, we might provide resources via another path like InputStreams and such.

@danfickle
Copy link
Owner

Hello,
With the pluggable http stream factory, you can already do that for http/https urls. Possibly, you could also abuse the pluggable cache to provide Image objects. See integration guide. However, it has become apparent from this thread that you should be able to do it with all url protocols and that we need a better API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants