danfickle/openhtmltopdf

Border not printed with "overflow: hidden"

maresja1 opened this issue · 3 comments

In RC-17 there is a problem with rendering span with overflow: hidden and border. For following HTML:

<!DOCTYPE HTML>
<html>
<head>
	<style>
		@page {size:  500px 500px;}body {margin: 0;}

		.letterField {
			border: 2px solid #008e7e;
			border-right: 0;
			border-left-width: 1px;
			float: left;
			padding: 2px 3px;
			font-size: 10px;
			display: inline-block;
			color: #000;
			font-weight: bold;
			width: 6px;
			overflow: hidden;
		}

		.letterField:first-child {
			border-left: 2px solid #008e7e;
		}

		.letterField:last-child {
			border-right: 2px solid #008e7e;
		}

	</style>
</head>
<title></title>
<body>
<span class="letterField">AASLKDJ</span>
</body>
</html>

I get this on RC-17:
image
And this on RC-16:
image

See attached PDF files.
border-overflow-RC16.pdf
border-overflow-RC17.pdf

Also noticed now, that I can see very very thin border when displaying the PDF inside the browser, but not at all with gnome's evince.

Hi @maresja1,

Thanks for the concise example and expected images.

I could replicate your behavior (very thin border in Mac Preview, none in Acrobat), but only when I used the fast mode renderer, which is not ready for production use yet. The output was equivalent to RC16 image when using this builder code:

    public static void main(String... args) throws Exception { 
        try (OutputStream os = new FileOutputStream("/Users/me/Documents/pdf-issues/output/issue-297.pdf")) {
            PdfRendererBuilder builder = new PdfRendererBuilder();
            builder.withUri("file:///Users/me/Documents/pdf-issues/issue-297.htm");
            builder.toStream(os);
            builder.testMode(true);
            //builder.useFastMode(); // Could only replicate by uncommenting this line!
            builder.run();
        }
    }

I can confirm this is still an issue in head in the fast mode renderer and will add a test now. If by any chance you are not using the fast mode, could you post your builder code so I can replicate?

It appears the problem only appears with floated elements with overflow hidden and a border. I never would have found that so thanks for reporting.