TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What do you use for PDF reports these days?

94 点作者 jguimont超过 10 年前
I am creating some entreprise software and almost every other information needs to be sent by email in pdf format. Reports, invoices, etc. I am using whtmltopdf right now, but it is far from ideal.<p>My idea setup would be to create some template with fixed parts, growable parts (texts that can vary in size), repeatable parts (lines in a table). And then just feed the data to have a nice pdf built.<p>The closest I found was using LibreOffice to convert a document to pdf (http:&#x2F;&#x2F;railsblog.kieser.net&#x2F;2013&#x2F;04&#x2F;part-ii-creating-beautiful-reports-in.html).<p>It seems PDF generation should be a solved problem. Maybe, Adobe LiveCycle is doing exactly what I need, but it is not open source and I do not have $50k to find out.<p>What are you guys using?

34 条评论

mkhattab超过 10 年前
I&#x27;m using Org-mode which can export to LaTeX -&gt; PDF [0]. I use Org-mode for invoices [1], reports, time-tracking, etc. Using org-babel you can use Gnuplot[2] or R [3] to embed charts and other visuals.<p>[0]: <a href="http://orgmode.org/manual/LaTeX-and-PDF-export.html#LaTeX-and-PDF-export" rel="nofollow">http:&#x2F;&#x2F;orgmode.org&#x2F;manual&#x2F;LaTeX-and-PDF-export.html#LaTeX-an...</a><p>[1]: <a href="http://orgmode.org/worg/org-contrib/" rel="nofollow">http:&#x2F;&#x2F;orgmode.org&#x2F;worg&#x2F;org-contrib&#x2F;</a><p>[2]: <a href="http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-gnuplot.html" rel="nofollow">http:&#x2F;&#x2F;orgmode.org&#x2F;worg&#x2F;org-contrib&#x2F;babel&#x2F;languages&#x2F;ob-doc-g...</a><p>[3]: <a href="http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html" rel="nofollow">http:&#x2F;&#x2F;orgmode.org&#x2F;worg&#x2F;org-contrib&#x2F;babel&#x2F;languages&#x2F;ob-doc-R...</a>
评论 #8444986 未加载
car超过 10 年前
I&#x27;ve used PhantomJS with CoffeeScript, and Reportlab with Python.<p>The PhantomJS solution became a bit painful, since there are issues with the way Qt converts HTML into PDF. I was impressed that even SVG generated with D3 faithfully was converted to PDF. But not being able to precisely control formatting was a problem.<p>After that I decided to try Reportlab, and it&#x27;s been amazing. There is a free open source Python API version, and the commercial Report Markup Language product (RML). It&#x27;s possible to mix Python and RML with a template engine (Preppy), very powerful. We opted for the commercial support, since time was a factor. RML is really baked, it&#x27;s been around for over a decade. The documentation is extensive, but I still had to find a couple of things via googling. However, their commercial support is awesome.<p>If you don&#x27;t want to spend a lot of time handcrafting documents, I recommend RML, despite the cost. It has features for page layout control, fonts, tables, styling and multipage text flow. There&#x27;s even a charting library, which I didn&#x27;t use yet. Also important was the ability to include existing PDF pages as backgrounds or chart inserts.
tambourine_man超过 10 年前
Honestly, I&#x27;ve been Chrome&#x27;s print to PDF + Quartz Filter to compress JPEGs for over a year.<p>These are the most important tricks:<p><pre><code> .A4page { width: 793px; height: 1120px; position: relative; padding: 200px 50px 50px; box-sizing: border-box; } @media all { .page-break { display: none; margin-bottom: 100px; } } @media print { .page-break { display: block; page-break-before: always; } } </code></pre> Good font rendering, selectable text. Not perfect, but the best I&#x27;ve seen so far.
评论 #8445048 未加载
veidr超过 10 年前
I use the Prawn gem. I usually have a Rails controller to spit out the PDF files, even if the main project isn&#x27;t Rails.<p>Prawn provides very fine control over the rendering, at the expense of having to finely control your render.<p>You can use your own fonts (and have to, for Asian languages etc) and it is easy to do layouts where the size is fixed and you shrink the text down to fit it in (or truncate it). On the other hand is not good for really rich text layout like you can do in HTML and CSS, where the size might vary.
评论 #8445154 未加载
评论 #8444686 未加载
评论 #8446432 未加载
评论 #8444945 未加载
Geee超过 10 年前
Docraptor, <a href="http://docraptor.com" rel="nofollow">http:&#x2F;&#x2F;docraptor.com</a><p>It uses the Prince engine (<a href="http://www.princexml.com/" rel="nofollow">http:&#x2F;&#x2F;www.princexml.com&#x2F;</a>), so it supports paging, headers, footers, page numbers etc. in addition to standard HTML+CSS3. It&#x27;s great overall but quite pricey.
评论 #8444391 未加载
评论 #8456858 未加载
评论 #8445555 未加载
Aheinemann超过 10 年前
For Reports with lots of tables and mathematics: generate LaTeX file -&gt; PDFTEX to PDF using MiKTeX
评论 #8444233 未加载
评论 #8444150 未加载
nbevans超过 10 年前
What&#x27;s wrong with WkHtmlToPdf? It is pretty damn good in a &quot;it just works&quot; way.
评论 #8444394 未加载
评论 #8444332 未加载
JohnHaugeland超过 10 年前
I use PrinceXML, which is a few hundred or a few thousand depending on what you need, instead of fifty thousand. Prince converts [html&#x2F;xml + css] to PDF, and has the most complete CSS3 implementation I&#x27;m aware of by a green mile.<p>There&#x27;s a free version you can experiment with, to find out.
评论 #8444336 未加载
redact207超过 10 年前
Microsoft Sql Server Reporting Services - does everything you mentioned and exports to pdf<p>same for Business Objects, but IMHO needlessly more complicated than the former.<p>obviously neither are open source, and an SSRS license is worth it if your business spits out many reports.
评论 #8444750 未加载
vram22超过 10 年前
ReportLab is a good product all right. Also, it has been around for a while and is pretty stable.<p>For text-only PDF reports (i.e. no styling, graphics or image support), my xtopdf toolkit may be worth a look, since it provides a higher-level and really simple to use API for basic use cases of PDF report generation: lines of text with pagination and page numbering, headers and footers, and setting the font - that&#x27;s about it. But it turns out that you can generate many kinds of useful reports with just those features. As an aside, xtopdf can also create simple PDF ebooks from either text or XML. xtopdf is built using ReportLab.<p>xtopdf is open source, under the BSD license, and free.<p>A good high-level overview of xtopdf:<p><a href="http://slid.es/vasudevram/xtopdf" rel="nofollow">http:&#x2F;&#x2F;slid.es&#x2F;vasudevram&#x2F;xtopdf</a><p>The above URL is a presentation with many links in it, to more information about xtopdf, and many programming examples of the use of xtopdf for various applications.<p>The xtopdf project is at:<p><a href="https://bitbucket.org/vasudevram/xtopdf" rel="nofollow">https:&#x2F;&#x2F;bitbucket.org&#x2F;vasudevram&#x2F;xtopdf</a><p>Also, a plug: I&#x27;ve available for consulting on PDF report generation from Python, using either xtopdf or Reportlab, or to some extent (can be decided on a case by case basis), even for PDF report generation using other libraries and from other languages, at least Ruby, Java and PHP.<p>I&#x27;m interested in feedback on xtopdf, including bugs, suggestions for features, etc.
评论 #8446762 未加载
maxharris超过 10 年前
I use pdfkit.js: <a href="http://pdfkit.org/" rel="nofollow">http:&#x2F;&#x2F;pdfkit.org&#x2F;</a><p>You can run it directly on the client (or the server, if you like), which is really nice.
eschutte2超过 10 年前
Jasper works pretty well and gives you a designer, but you could also roll your own like Aheinemann says. I&#x27;ve done the wkhtmltopdf road before and it was tough to deal with paging.<p>I&#x27;m working on a related problem right now (end-user report design in the browser) so I&#x27;ll be interested to see what other people say.
lambdasgr超过 10 年前
LaTeX. Here are some custom latex classes I uses for different purpose. Some are created by me, some are I get from elsewhere: <a href="https://github.com/malloc82/latex_classes" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;malloc82&#x2F;latex_classes</a>
vivekchand19超过 10 年前
We use reportlab (<a href="https://pypi.python.org/pypi/reportlab" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;reportlab</a>) for invoice generation. Once you decide upon the template it&#x27;s very easy to use.
评论 #8444919 未加载
kawera超过 10 年前
I&#x27;ve been using speedata-publisher[1] and pdf-writer[2] with good results.<p>[1] <a href="https://github.com/speedata/publisher" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;speedata&#x2F;publisher</a><p>[2] <a href="https://github.com/galkahana/PDF-Writer" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;galkahana&#x2F;PDF-Writer</a><p>Some other options I&#x27;ve played with:<p>- <a href="https://github.com/signintech/gopdf" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;signintech&#x2F;gopdf</a><p>- <a href="https://github.com/mstamy2/PyPDF2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mstamy2&#x2F;PyPDF2</a><p>- <a href="http://www.jagpdf.org/" rel="nofollow">http:&#x2F;&#x2F;www.jagpdf.org&#x2F;</a>
xiljin超过 10 年前
Our rails app generates dozens of accounting related reports on the fly in HTML and we use Flying Saucer to generate a PDF version -<p><a href="https://github.com/flyingsaucerproject/flyingsaucer" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;flyingsaucerproject&#x2F;flyingsaucer</a><p>To help minimize request time, we keep Flying Saucer persisted with Nailgun -<p><a href="https://github.com/martylamb/nailgun" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;martylamb&#x2F;nailgun</a><p>For generating checks, IRS forms and other PDFs that involve precise formatting we use Prawn -<p><a href="https://github.com/prawnpdf/prawn" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;prawnpdf&#x2F;prawn</a>
评论 #8444308 未加载
yogthos超过 10 年前
I ended up wrapping iIText with my [clj-pdf](<a href="https://github.com/yogthos/clj-pdf" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;yogthos&#x2F;clj-pdf</a>) library for doing that sort of thing. I also created a standalone service using it, that accepts JSON and returns a PDF that can be found [here](<a href="https://github.com/yogthos/instant-pdf" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;yogthos&#x2F;instant-pdf</a>).
seven超过 10 年前
I run <a href="http://template2pdf.com/" rel="nofollow">http:&#x2F;&#x2F;template2pdf.com&#x2F;</a> as a side project.<p>Take a LibreOffice&#x2F;OpenOffice document as your template and send a simple http request with the values you want to replace (with support for images and what you call &#x27;repeatable parts&#x27;). The system will then return a link where you can pick up your generated pdf.
thematt超过 10 年前
I generate the report as a normal HTML page and then render&#x2F;export it using PhantomJS. Easiest solution I&#x27;ve found so far and I&#x27;ve done quite a bit of exploring.<p><a href="https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ariya&#x2F;phantomjs&#x2F;blob&#x2F;master&#x2F;examples&#x2F;rast...</a>
bemmu超过 10 年前
In the one place where I need to create PDFs from code (generating address labels), I use the fpdf port of Python. It is probably too limited for most cases, but if you just need to position some simple images and text it might be enough.<p><a href="https://code.google.com/p/pyfpdf/" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;pyfpdf&#x2F;</a>
jonah超过 10 年前
Apache PDFBox. <a href="https://pdfbox.apache.org/" rel="nofollow">https:&#x2F;&#x2F;pdfbox.apache.org&#x2F;</a>
nextw33k超过 10 年前
Good reports are hard, I&#x27;ve not found a good open source solution for anything other than basic reports.<p>Last year I migrated 200+ reports from Crystal Reports to Microsoft ReportViewer Control.<p>Telerik Reporting is a product that we considered but didn&#x27;t go with as we had the Microsoft Server.
ashokvarma2超过 10 年前
We use shrimp(<a href="https://github.com/adjust/shrimp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;adjust&#x2F;shrimp</a>) which internally uses phantomjs. It works well but you will need to do the page break yourself which can become a pain.
raphael_kimmig超过 10 年前
We used to do wkhtmltopdf but nowadays we are using weasyprint + django templates. Much better support for css (including CSS Paged Media). See <a href="http://weasyprint.org/" rel="nofollow">http:&#x2F;&#x2F;weasyprint.org&#x2F;</a>
LarryMade2超过 10 年前
In PHP the best one is TCPDF (replaces FPDF) along with FPDI. TCPDF is a library to generate PDF content, FPDI extends TCPDF&#x2F;FPDF to allow for importing PDF (as templates, etc) for use in your creations.<p>Works really well.
razzaj超过 10 年前
We use BIRT to design &amp; run our reports. It is flexible and renders in all sorts of ways (including PDF). We have not had major issues with it.
danellis超过 10 年前
ReportLab.
评论 #8444879 未加载
评论 #8444575 未加载
enduser超过 10 年前
Generate SVG using an XML DOM library and then convert to PDF using Inkscape on the command-line.
sandstrom超过 10 年前
Somewhat related: what is a good process for turning html-emails into PDFs (or images)?
chris11超过 10 年前
PDFsharp is a pretty good opensource library for .NET languages.
ibotty超过 10 年前
pandoc is great too. you supply it with e.g. markdown and it can generate many different output formats. pdf via tex is one of it.
asteiger超过 10 年前
there is always itext &#x2F; itextsharp. or pdflib. i think ghostscript does pdf conversions as well.
sebastianavina超过 10 年前
ReportLab
Koldark超过 10 年前
I use Telerik Reporting.