首页 > 解决方案 > 根本不支持 itext7.pdfhtml 中的 css 属性

问题描述

我正在使用itext7.pdfHtml附加组件将我的 html 模板转换为 PDF 文档,一切正常,结果生成没有任何错误,但我的是有一堆 CSS 属性无法用 pdfhtml dll 识别。其中一些属性显示在此片段中:

.day-meta-wrapper {
    font-size: 15px;
    line-height: normal;
    height: 24px;
    border-radius: 12px;
    color: #ffffff;
    background: #00000033;----> not support
    padding: 0 6px;
    display: flex;----> not support
    align-items: center;----> not support
    justify-content: center;----> not support
}

这是我的 html 文件结果:

在此处输入图像描述

正如您在浏览器视图中看到的那样,没有问题,所有属性都正常工作,但这是我的 PDF 结果: 在此处输入图像描述

如图所示 PDF doc 松散了 CSS 属性

h1 {
    background-color: red;
}

.day-meta {
    margin: 5px 0;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.day-meta-wrapper {
    font-size: 15px;
    line-height: normal;
    height: 24px;
    border-radius: 12px;
    color: #ffffff;
    background-color: #00000033;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <link rel="stylesheet" href="css/DayMeta.css">
</head>
<body style="background: #979797;">
    <h1>Hello IText7 PDFHtml</h1>
    <div class="day-meta">
        <div class="day-meta-wrapper">
            <div>December 11, 2018</div>
        </div>
    </div>
</body>
</html>

标签: itextitext7html-to-pdf

解决方案


推荐阅读