HTML + CSS现在与生成打印报告有多成熟?

时间:2021-11-04 12:05:38

I'm considering creating all the reports of a series of desktop business apps directly to html. Most of the reports are tables (maybe compound reports), headers, footers, etc. (no images, vector graphics, etc.).

我正在考虑将一系列桌面业务应用程序的所有报告直接创建到html。大多数报告都是表格(可能是复合报告),页眉,页脚等(没有图像,矢量图形等)。

After a search in SO, I've read lots of post regarding problems with page breaks and things like that (I don't need pixel positioning at all, but yes control at page breaks).

在SO搜索之后,我已经阅读了很多关于分页和类似问题的帖子(我根本不需要像素定位,但是在分页符时是控制)。

For example, let's say I have a big table with currency values and I need the last row of the table per page to display the running totals at that point.. it is something feasible to do easily or I will run in lots of trouble?

例如,假设我有一个带有货币值的大表,我需要每页表格的最后一行显示当时的运行总计..​​这是可行的,或者我会遇到很多麻烦?

What technologies can help me here?

哪些技术可以帮助我?

  • HTML5
  • Javascript
  • CSS
  • PHP Librarys
  • JQuery

Some notes:

  • The html will be displayed with the chrome or firefox engine embeded, so the diferences between browsers it's not a problem for me.
  • html将显示嵌入的chrome或firefox引擎,因此浏览器之间的差异对我来说不是问题。

  • I can have the php preprocessor embedded if that helps to generate more easily the reports, I'm just looking fot the best technology at hand to make the work well..
  • 我可以嵌入php预处理器,如果这有助于更容易地生成报告,我只是在寻找手头上最好的技术来使工作顺利进行..

  • I'm tired of report generators with "WYSIWYG" designers (Crystal Report, FastReport, ReportBuilder, etc.)
  • 我厌倦了“WYSIWYG”设计师的报告生成器(Crystal Report,FastReport,ReportBuilder等)

Thanks!

3 个解决方案

#1


8  

We made the exact move you're thinking about almost a year ago and haven't looked back. Most communication with our client is over the web, so it's been a perfect fit. They can view html outputs easily on our website, and can generate pdf's of the page (server side) whenever necessary. The program we use for pdf conversion is a free, easy-to-use, open-source project called wkhtmltopdf.

我们做了你差不多一年前想到的确切行动并没有回头。与客户的大多数沟通都是通过网络进行的,因此它非常适合。他们可以在我们的网站上轻松查看html输出,并在必要时生成页面(服务器端)的pdf。我们用于pdf转换的程序是一个免费的,易于使用的开源项目,名为wkhtmltopdf。

Where we are is great, but getting here was difficult.

我们在哪里很棒,但到这里很困难。

Deciding which pdf engine to use was a long, painful process. The short of it is that HTML is for viewing pages on the internet, not for viewing pages on paper. Page-breaks will be the bane of your existence in this game -- you literally have to measure each page and create your own clean-looking breaks for every single report (otherwise, all html-to-pdf converters out there will just keep rendering the document onto the next page as it if encountered no page-break at all). Further complicating the matter is that every html-to-pdf engine out there handles this sh*t differently and you'll have to write a tailored solution to test each one to see if it meets your individual needs.

决定使用哪个pdf引擎是一个漫长而痛苦的过程。缺点是HTML用于在互联网上查看页面,而不是用于在纸上查看页面。分页符号将成为你在这个游戏中存在的祸根 - 你必须测量每个页面并为每个报告创建自己干净的休息时间(否则,所有html-to-pdf转换器都将继续呈现将文档放到下一页上,如果没有遇到页面中断的话。更复杂的是,每个html-to-pdf引擎都会以不同的方式处理这个问题,你必须编写一个量身定制的解决方案来测试每一个,看看它是否满足你的个性化需求。

Now, the good news:

现在,好消息:

You can save yourself a lot of trouble by heeding my advice and going with wkhtmltopdf for your finalized reporting outputs. This little program is simply amazing -- it uses a webkit engine, renders CSS/javascript accurately, has header/footer control, optionally creates a table-of-contents page, and (most importantly) consistently produces excellent looking pdf's without having to customize your code base. It also has a variety of great command line switches, and it is very, very fast. I say again: it is very, very fast.

您可以通过听取我的建议并使用wkhtmltopdf获取最终报告输出来节省很多麻烦。这个小程序简直太棒了 - 它使用webkit引擎,准确呈现CSS / javascript,具有页眉/页脚控件,可选地创建目录页面,并且(最重要的是)始终如一地生成出色的外观pdf而无需定制你的代码库。它还有各种出色的命令行开关,非常非常快。我再说一遍:它非常非常快。

Best of all, it's a command line tool that can be used in batch processing. And did I mention that it's really, really fast?

最重要的是,它是一个可用于批处理的命令行工具。我是否提到它真的非常快?

#2


6  

Browser support for printing is generally terrible. However, there are other tools, notably Prince (which is not free) and Flying Saucer (which is free) that can generate PDF output from XML/HTML plus CSS. Prince even supports JavaScript though I don't have any experience with it.

浏览器对打印的支持通常很糟糕。但是,还有其他工具,特别是Prince(不是免费的)和Flying Saucer(免费),它可以从XML / HTML和CSS生成PDF输出。 Prince甚至支持JavaScript,虽然我对它没有任何经验。

I've got a Java back end in my current application, so for me Flying Saucer works fine for simple reports. I pre-process an HTML template with FreeMarker and then run the result through Flying Saucer. It's got a surprisingly smart rendering engine.

我目前的应用程序中有一个Java后端,所以对我来说,Flying Saucer适用于简单的报告。我使用FreeMarker预处理HTML模板,然后通过Flying Saucer运行结果。它有一个令人惊讶的智能渲染引擎。

The CSS3 Paged Media spec (well, proposed spec) has all sorts of cool stuff in it but they're almost totally unimplemented in the browsers. Even the CSS2 paged media stuff is only supported half-heartedly.

CSS3分页媒体规范(好的,提议的规范)中有各种很酷的东西,但它们在浏览器中几乎完全没有实现。即使是CSS2分页媒体也只能半心半意地支持。

#3


0  

Speaking of Prince, you might look into DocRaptor. DocRaptor is another HTML to PDF conversion application. It uses Prince XML, and handles CSS better than comparable programs.

说到Prince,您可以查看DocRaptor。 DocRaptor是另一种HTML到PDF转换应用程序。它使用Prince XML,并且比同类程序更好地处理CSS。

It isn't free, but offers a free 30 day trial for all accounts, so there's no harm in trying it out, at least.

它不是免费的,但为所有帐户提供30天的免费试用,所以至少尝试一下也没有坏处。

DocRaptor

#1


8  

We made the exact move you're thinking about almost a year ago and haven't looked back. Most communication with our client is over the web, so it's been a perfect fit. They can view html outputs easily on our website, and can generate pdf's of the page (server side) whenever necessary. The program we use for pdf conversion is a free, easy-to-use, open-source project called wkhtmltopdf.

我们做了你差不多一年前想到的确切行动并没有回头。与客户的大多数沟通都是通过网络进行的,因此它非常适合。他们可以在我们的网站上轻松查看html输出,并在必要时生成页面(服务器端)的pdf。我们用于pdf转换的程序是一个免费的,易于使用的开源项目,名为wkhtmltopdf。

Where we are is great, but getting here was difficult.

我们在哪里很棒,但到这里很困难。

Deciding which pdf engine to use was a long, painful process. The short of it is that HTML is for viewing pages on the internet, not for viewing pages on paper. Page-breaks will be the bane of your existence in this game -- you literally have to measure each page and create your own clean-looking breaks for every single report (otherwise, all html-to-pdf converters out there will just keep rendering the document onto the next page as it if encountered no page-break at all). Further complicating the matter is that every html-to-pdf engine out there handles this sh*t differently and you'll have to write a tailored solution to test each one to see if it meets your individual needs.

决定使用哪个pdf引擎是一个漫长而痛苦的过程。缺点是HTML用于在互联网上查看页面,而不是用于在纸上查看页面。分页符号将成为你在这个游戏中存在的祸根 - 你必须测量每个页面并为每个报告创建自己干净的休息时间(否则,所有html-to-pdf转换器都将继续呈现将文档放到下一页上,如果没有遇到页面中断的话。更复杂的是,每个html-to-pdf引擎都会以不同的方式处理这个问题,你必须编写一个量身定制的解决方案来测试每一个,看看它是否满足你的个性化需求。

Now, the good news:

现在,好消息:

You can save yourself a lot of trouble by heeding my advice and going with wkhtmltopdf for your finalized reporting outputs. This little program is simply amazing -- it uses a webkit engine, renders CSS/javascript accurately, has header/footer control, optionally creates a table-of-contents page, and (most importantly) consistently produces excellent looking pdf's without having to customize your code base. It also has a variety of great command line switches, and it is very, very fast. I say again: it is very, very fast.

您可以通过听取我的建议并使用wkhtmltopdf获取最终报告输出来节省很多麻烦。这个小程序简直太棒了 - 它使用webkit引擎,准确呈现CSS / javascript,具有页眉/页脚控件,可选地创建目录页面,并且(最重要的是)始终如一地生成出色的外观pdf而无需定制你的代码库。它还有各种出色的命令行开关,非常非常快。我再说一遍:它非常非常快。

Best of all, it's a command line tool that can be used in batch processing. And did I mention that it's really, really fast?

最重要的是,它是一个可用于批处理的命令行工具。我是否提到它真的非常快?

#2


6  

Browser support for printing is generally terrible. However, there are other tools, notably Prince (which is not free) and Flying Saucer (which is free) that can generate PDF output from XML/HTML plus CSS. Prince even supports JavaScript though I don't have any experience with it.

浏览器对打印的支持通常很糟糕。但是,还有其他工具,特别是Prince(不是免费的)和Flying Saucer(免费),它可以从XML / HTML和CSS生成PDF输出。 Prince甚至支持JavaScript,虽然我对它没有任何经验。

I've got a Java back end in my current application, so for me Flying Saucer works fine for simple reports. I pre-process an HTML template with FreeMarker and then run the result through Flying Saucer. It's got a surprisingly smart rendering engine.

我目前的应用程序中有一个Java后端,所以对我来说,Flying Saucer适用于简单的报告。我使用FreeMarker预处理HTML模板,然后通过Flying Saucer运行结果。它有一个令人惊讶的智能渲染引擎。

The CSS3 Paged Media spec (well, proposed spec) has all sorts of cool stuff in it but they're almost totally unimplemented in the browsers. Even the CSS2 paged media stuff is only supported half-heartedly.

CSS3分页媒体规范(好的,提议的规范)中有各种很酷的东西,但它们在浏览器中几乎完全没有实现。即使是CSS2分页媒体也只能半心半意地支持。

#3


0  

Speaking of Prince, you might look into DocRaptor. DocRaptor is another HTML to PDF conversion application. It uses Prince XML, and handles CSS better than comparable programs.

说到Prince,您可以查看DocRaptor。 DocRaptor是另一种HTML到PDF转换应用程序。它使用Prince XML,并且比同类程序更好地处理CSS。

It isn't free, but offers a free 30 day trial for all accounts, so there's no harm in trying it out, at least.

它不是免费的,但为所有帐户提供30天的免费试用,所以至少尝试一下也没有坏处。

DocRaptor