飞碟对细胞中图像的处理是一个错误吗?
我设法将我的示例缩减为以下内容(它使用了一些相当大的数据 URL,但 stackoverflow 应该很好地将它们从侧面流出......):
static
{
String oldValue = System.getProperty("java.protocol.handler.pkgs");
if (oldValue == null)
{
System.setProperty("java.protocol.handler.pkgs", "org.xhtmlrenderer.protocols");
}
else if (!oldValue.contains("org.xhtmlrenderer.protocols"))
{
System.setProperty("java.protocol.handler.pkgs", oldValue + "|org.xhtmlrenderer.protocols");
}
}
@Test
public void testLegacyCellSpacing() throws Exception
{
ITextRenderer renderer = new ITextRenderer();
renderer.setDocumentFromString("<html>\n" +
" <head>\n" +
" <title>Some title</title>\n" +
" </head>\n" +
" <body>\n" +
" <div>\n" +
"<table cellpadding=\"0\" cellspacing=\"0\">\n" +
"<tr>\n" +
"<td>\n" +
" <img src=\"data:image/png;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAHgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAEAsLCwwLEAwMEBcPDQ8XGxQQEBQbHxcXFxcXHx4XGhoaGhceHiMlJyUjHi8vMzMvL0BAQEBAQEBAQEBAQEBAQAERDw8RExEVEhIVFBEUERQaFBYWFBomGhocGhomMCMeHh4eIzArLicnJy4rNTUwMDU1QEA/QEBAQEBAQEBAQEBA/8AAEQgAUwC5AwEiAAIRAQMRAf/EAJQAAAEFAQEAAAAAAAAAAAAAAAIAAQMEBQYHAQADAQEBAAAAAAAAAAAAAAAAAQIDBAUQAAEDAwIDBgQEBgEFAAAAAAERAgMAIQQxEkETBVFhcYEiMpFCFAahscHR4VIjM2M08fBygqIVEQACAgEDAgUDBAMBAAAAAAAAARECMSFBEnEDUWGBIjKRQoKhwRMz4VJyBP/aAAwDAQACEQMRAD8Ayl/5pwUShA8+6nW9eqecHuQ0bfitQrf8hVfNzXQpDAN07u3RtDaSljSbcIvlhbcrTFBWOB1lQ4SFexf0q1j5mTu5GXHtcR6JALHuNSry4dbV6obrG9X0Li6FKZSaZ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I1yR9wdxOAtg4BcSBFFYuI94aVnmaAOruHQWpHUx4YGayD7fdY93tqoByiPUU9LbNcAYQM5p10MWVEaB50AA3fFvRCFcjNXbgQIwGZFE1m5I04jiKFn7WeEnLzoAW+2S63bkhWPUefhQ/+PtP+M/Ktu3VSweQeXEya2RROYHGJJZZbNtbKCAoxjnRTJOHUePGsxLgtpMcWamWXU9KY6R1N41k67LT0MgTA9KuDGcUKSCTMk5mjLg4cqTGglGEE1GYLkJ8aHUoOeNWYNSUUpZ2ygcTTRFJLEQFpb3jqKjGKfa2Lug0sVzNJddXSAceNc3eb+5ZKlhnlFI/9HdIveZDpOCDP51a+trZLunoLfrs7FxbSmbrZKPpGcmsPct2iCzTics5NTc33uXA3b03OJ8Kz3WRrwmAFHU3ia0Rmxl99ZlXJnCP3mlPb0jrzABwyqu5Z2vcZxrZhCBcaXrvRN1CpbhTAYzTCA4nhwNCbo0STqIyBg/OlziGYRh8hR27aAG42Jn2+FACrT2QzFiUkYim7fcql2MgfZhHzpJhX1FZGRn9tZrl0OzKxhcYOU8KQHZP3FLVwK0uGyIOFbLd3q1p515/YWrRcC4cG9s11rVy5bftwXtmPOmB0lutEg48qqHuYnTC5k0plKdUyuYBoluyRrXDkDhQBp20mQMDhHLxrZDc6w2m7d0Nhjy4VplvxFLY9EaO2conx9eNPtf4x7f7cqlSs7cbLXOic6H8YVKlJACtW04RP9sfnUqVW/cWvYJchVLxy/OpUqRmDd5XPbMcc/wC3hQW47CT/ALp9IqVK1Rmzn3v8pzyOX51zt177n9P0eXGpUpgL2cd+zz/1+XDhNdLdzJ93CMv9tSpSAyH/ABmZ4+7P04ULz21zjwqVKYF49sZ5N7orntHcGXHOYqVKAGW8hnmfwK7P2/24T+OU1KlAHQu+3H1/hQ248PhNSpQBH/yifD8YVtw8PWpUpAf/2Q==\" width=\"185\" height=\"83\"/>\n" +
"</td>\n" +
"</tr>\n" +
"</table>\n" +
" </div>\n" +
" </body>\n" +
"</html>", null);
renderer.layout();
File pdfFile = File.createTempFile("TestFlyingSaucer", ".pdf");
OutputStream output = new BufferedOutputStream(new FileOutputStream(pdfFile));
try
{
renderer.createPDF(output, true);
}
finally
{
output.close();
}
System.out.println(); // breakpointing here to look at the output. no good assertions available for checking this problem yet. :(
}
此代码运行,并生成一个 PDF,每个图像之间的空格不正确。我无法弄清楚是什么导致了这些空格,但我也无法弄清楚这是否是一个错误。我所知道的是:
- 网络浏览器不会在图像之间显示空格。
- 如果您删除图像并将其替换为固定大小的 div 之类的内容,问题就会神奇地消失(这证明飞碟正在使用旧的 cellpadding 和 cellspacing 属性做正确的事情,这是我最初关心的问题。)
- 如果您添加单元格的 1 像素边框 (
td { border: 1px Solid red; }
),它表明额外的空间位于 td 元素之外。 - 如果删除
和
之间的空格,问题似乎就会消失。
对我来说,元素内部的额外空间可能会导致元素外部的额外填充/边距,这似乎很奇怪。也许我完全误解了 HTML,所以我希望有人能在我将问题塞进他们的跟踪器之前在这里纠正我。
(另外:抢占“不要为此使用表格”的典型下意识答案 - 这不是我的 HTML,我试图在清理后将现实世界的 HTML 渲染为 PDF。此示例显示清理后的 HTML以排除清理代码中的问题。)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
浏览器对 HTML 中许多地方的空白很敏感,包括元素内部和元素之间,甚至是您意想不到的地方。例如,如果您有一个带有
li
元素的ul
,如果您使用 CSS 使用li {display:inline}
来设置项目的样式,水平菜单,和下一个
之间的任何空格都会将菜单项分开!
在这种特殊情况下,看到第一个子元素缩进的空格肯定是不寻常的,但我不能明确地说根据 HTML 标准它是否会被视为错误。最好的解决方案确实是简单地消除引起问题的空白。
Browsers are sensitive to white space in HTML in many places, including inside and in between elements, and even in places you would not expect. For instance, if you had a
ul
withli
elements, if you use CSS to style the items withli {display:inline}
to make a horizontal menu, any white space between</li>
and the next<li>
will space the menu items apart!In this particular case, seeing the white space indenting the first child element is certainly unusual but I can't say categorically if it would be considered a bug according to the HTML standards. Your best solution is indeed to simply eliminate white space where it causes issues.