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

How to set transparency background? #58

Open
Luyao1271 opened this issue Apr 9, 2020 · 2 comments
Open

How to set transparency background? #58

Luyao1271 opened this issue Apr 9, 2020 · 2 comments

Comments

@Luyao1271
Copy link

Now I need a transparency background,but the setting "rgba(255,255,255,0)" is not work.

@radkovo
Copy link
Owner

radkovo commented Apr 9, 2020

This actually should work. If you suspect a bug in CSSBox, please provide an example (a simple HTML/CSS code) that shows when it does not work. Another option is to use background-color: transparent.

@tbutter
Copy link

tbutter commented Jan 23, 2022

To get a transparent background of the Image returned from GraphicsEngine you need to set the Viewport Background and supply your own image:

GraphicsEngine contentCanvas = new GraphicsEngine(da.getRoot(), da, docSource.getURL());
            contentCanvas.setImage(new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB));
            contentCanvas.setAutoMediaUpdate(false); // we have a correct media specification, do not update
            contentCanvas.getConfig().setClipViewport(true);
            contentCanvas.getConfig().setLoadImages(true);
            contentCanvas.getConfig().setLoadBackgroundImages(true);

            contentCanvas.createLayout(windowSize, new Rectangle(windowSize), false);
            contentCanvas.getViewport().getConfig().setViewportBackgroundColor(new Color(0, 0, 0, 0));
            contentCanvas.redrawBoxes();
            bi = contentCanvas.getImage();

That only works for one render because the canvas is not cleared when you set a transparent background.

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

4 participants
@radkovo @tbutter @Luyao1271 and others