开发者

HTML and PDF generation from XML

I have document source in XML. I need to generate PDF and HTML pages from it, and the problem is HTML and PDF copies should look exactly the same (if in PDF dcument on 2nd page, the first word in 3rd row is "computer", then in HTML it has to be the same). Also I need to print out thi开发者_开发问答s document from web browser and page layout should also be the same.

I need advise, what tools to use and how better realize this solution. Also it is preferrable to do this with PHP/javascript, not java...


Margins, font sizes may be different, I just need to make position of words absolutely the same in all copies. The document format is quite simple, it looks like a book.

I was thinking to generate PDF first and then show it in web-browser and use it for printing, but I'm


You'll never get identical PDF and HTML copies as you must generally go via a rendering engine and, as we know from using different browsers and operating systems, rendering engines often don't render equal code equally.

Similarly, when a user prints a page, the page is re-rendered as a 'print' layout; it doesn't use the regular stylesheet, unless we set media="all". But even then, there are differences to the printed version:

... most browsers are configured not to print backgrounds; and pixel-based fonts, while nice for screen media, are not so useful in print media.

So unless your styling is very simple, you won't get similar print/browser views. Even if the styling is simple, that's all you'll get: similarity, not an identical page.


This is just not possible to get right 100%.


Yes.getting 100% identical pdf is not possible. I am using itext to generate pdf's for my html content.Go through http://itextpdf.com/ they have their book as well as many examples.It might help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜