如何使用CSS创建PDF [英] How to create PDF with CSS apply

查看:89
本文介绍了如何使用CSS创建PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我需要创建一个包含css的PDF,怎么可能。我正在使用itext dll,但css没有应用。

Hi All,

I need to create a PDF including css how is it possible. I am using itext dll but css not appying.

<asp:Panel ID="pnl1" runat="server">
            <h1>
                <img src="../images/logo.png" style="height: 70px; text-indent: -9999px; width: 180px;" /></h1>
            <table class="pop-form-sec p-detail">
                <tr>
                    <td colspan="2">
                        <h2>Center Wise Roll Number Details</h2>
                    </td>
                </tr>

                <tr>
                    <td>Session:
                    </td>
                    <td><%Response.Write(dtDetails.Rows[0]["pkksession"]);%></td>
                </tr>
                <tr>
                    <td>Center Code:
                    </td>
                    <td><%Response.Write(dtDetails.Rows[0]["CCode"]);%></td>
                </tr>
                <tr>
                    <td>Center Name:
                    </td>
                    <td><%Response.Write(dtDetails.Rows[0]["CName"]);%></td>
                </tr>
                <tr>
                    <td>Center Head:
                    </td>
                    <td><%Response.Write(dtDetails.Rows[0]["CHead"]);%></td>
                </tr>
                <tr>
                    <td>Center Address:
                    </td>
                    <td><%Response.Write(dtDetails.Rows[0]["CAddress"]);%></td>
                </tr>
                <tr>
                    <td>Start RollNumber:
                    </td>
                    <td><%Response.Write(dtDetails.Rows[0]["StartRollno"]);%></td>
                </tr>
                <tr>
                    <td>End RollNumber:
                    </td>
                    <td><%Response.Write(dtDetails.Rows[0]["EndRollno"]);%></td>
                </tr>
                <tr>
                    <td>Last RollNumber:
                    </td>
                    <td><%Response.Write(dtDetails.Rows[0]["LastRollno"]);%></td>
                </tr>
                <tr>
                    <td>Allocated RollNumber:
                    </td>
                    <td><%Response.Write(dtDetails.Rows[0]["AllocatedRollno"]);%></td>
                </tr>
            </table>
        </asp:Panel>

推荐答案

HTML概念(包括CSS)不适用于PDF。概念非常不同。 PDF与打印结果非常相似(HTML或任何可以在打印机上呈现的内容);这是一种软件纸质文档。



所有HTML到PDF转换器都不是真正的转换器,因为转换的概念不适用。到目前为止我所看到的只是为一些固定的页面大小和渲染方法创建了一些HTML文档的固定渲染,并将其写入PDF文件。输出文档中丢失了大量信息。不仅是样式,甚至是段落和其他流元素:它们被分成单独的对象,每个对象代表一个具有单独格式属性的印刷行;一般情况下,你不能判断两条这样的线是否属于同一段(div,任何其他流元素)或不同的段。



你可以这样做考虑到输入中的样式和其他HTML功能,并在输出中丢失它们,只创建固定呈现页面的硬拷贝。考虑到以上所有因素,您应该看到您的问题没有严格意义。



-SA
HTML concepts, including CSS, are inapplicable to PDF. The concepts are very different. PDF is very similar to the result of the print (of HTML or anything which can be rendered on a printer); this is a kind of "software paper document".

All HTML to PDF "converters" are not really converters, because the concept of conversion is inapplicable. All I saw so far just create some fixed rendering of some HTML document for some fixed page size and rendering methods and write it to PDF file. A lot of information is lost in the output document. Not only the styles, but even the paragraphs and other flow elements: they are broken into separate objects each representing a single typographic line with individual formatting properties; in general case, you cannot tell if two such lines belong to the same paragraph (div, any other flow element) or different ones.

You can do something like this, taking into account the styles and other HTML features on input and losing them all on output, creating just a hard copy of the fixed rendered pages. Taking all of the above into account, you should see that your question does not make strict sense.

—SA


这篇关于如何使用CSS创建PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆