Apache PDFBox – A Java PDF Library
pdfbox.apache.org
pdfbox.apache.org
I'm sure there are arguments in favour of libraries like this such as performance or better control but when all you need is to generate a simple invoice with a couple of dynamic fields, just use Inkscape to draw your template and your favourite XML library to put values in it in your code. When you need the PDF, use inkscape --export-pdf to get your PDF document.
SVG also makes it quite easy to show an in-browser preview of the generated document before performing the actual conversion, avoiding a costly PDF generation most of the time.
After all, we run Unix commands tens or hundreds of times a day, alone or in pipelines, to get things done, vs. putting all the needed functionality into one program and calling it.
Various pros and cons exist for both approaches ...
For an invoice with a couple of fields filled in, you could also consider using a PDF form. (And use a library like iText or pdfbox to fill it in.)
Despite a few problems, the library is good. I will certainly use it again.
Edit: I used 2.0.0-RC1.
http://mirror.vorboss.net/apache/pdfbox/
[DIR] 1.8.11/ 2016-01-17 21:55 -
[DIR] 2.0.0/ 2016-03-18 12:02 -In fact, I see so many "what's the news" posts that I sometimes think they should change the name!
https://blogs.apache.org/foundation/entry/the_apache_softwar...
https://youtu.be/TC_uv_AD808?t=1m31s all the PDF's in that video where generated, that was an early alpha of the product.
disclaimer: i wrote it
LaTeX (or any TeX variety) on the other hand give you so many different powerful features to generate any arbitrary document, and not only in PDF. There are, of course, a few associated risks that would need to be mitigated as with anywhere user input gets compiled in some turing-complete system, but I'd imagine it would be fairly straightforward to make sure input gets properly escaped so an attacker couldn't run arbitrary code.
Maybe this has changed with newer versions of PDFBox, but 5+ years ago, the internet wisdom was to use PDFBox for extraction and something else, like a version of iText that suited your license needs, for generation.
As much as I like LaTeX, if you have made no prior time investment in typesetting with it, it is not trivial to produce custom good-looking output with it.
Have you tried using (La)TeX in a real world project? Would be cool to hear from someone on whether compilation time is an issue. Some TeX packages have a quite severe impact on performance.
He apparently did not look at iText, which can generate docs with support for all major fonts and bidirectional writing, forms (interactive and not), and sign them digitally.
Disclaimer: I'm part of the team. Also see http://docs.telerik.com/kendo-ui/framework/drawing/drawing-d...
Latest version of Tika parser has 44 compile time dependencies: http://mvnrepository.com/artifact/org.apache.tika/tika-parse...
I realize the scope is different, which is why I mentioned that Tika supports more formats.
I've had a few issues with Tika (at least one of which turned out to be a PDFBox issue). The mailing lists and bug trackers have been very helpful - down to people fixing bugs or writing me custom code to work around the issue, often in a few hours.
Very impressed, and the atmosphere reminds me of my first few years on the web: people helping each other, before it became so commercialised.
I am struggle finding some good solution with the same.
Their website doesnt have any proper answer to this.
Windows 10 and OS X have built in PDF printers now.
Because the MS Office PDF integration is shit, when I get such PDFs in Preview on Mac OS X and then want to print it.
Apache OpenOffice API used to be able to do this. Not sure about output quality. Also not sure if LibreOffice API too supports it.
You might also want to evaluate a commercial framework like Aspose [1] (not affiliated, I've just come across their marketing pieces)
[1]: http://www.aspose.com/docs/display/slidesnet/Converting+Pres...
However by far the easiest for you might just be to use the Microsoft Office addin that allows you to print to PDF[1]
If you need to do this programmatically then you could use the LibreOffice command line tools for converting files[2]
[1] https://support.office.com/en-us/article/Print-share-and-pro...
[2] https://ask.libreoffice.org/en/question/2641/convert-to-comm...
If you're comfortable with an external API for this, converting MS Office documents to PDF is as simple as:
curl -X POST --form "document=@$SOURCE" -H "Authorization: da.key=$API_KEY" https://documentalchemy.com/api/v1/document/-/rendition/pdf -o "$DEST"
You can test it directly online here - https://documentalchemy.com/demoIf you're not comfortable with an external API for this, I think the conventional answer to your question is to use unoconv [1] which is simply a Python script that uses LibreOffice [2] or OpenOffice (formerly StarOffice) [3] to do the conversion.
[1] https://github.com/dagwieers/unoconv
[2] https://www.libreoffice.org/
[3] http://www.openoffice.org/
You can also use Libre/OpenOffice directly for the conversion, but unoconv is geared toward having an always-on version of office running in the background that you use for the conversion, which is a significant performance boost relative to launching the app for every conversion.
unoconv is a little flaky, but works well in general (it's certainly a part of the DocumentAlchemy backend).
Where I work, we ended up paying for the commercial Aspose products. Example doc to pdf code: http://www.aspose.com/docs/display/wordsnet/How+to++Convert+...
If you are trying to generate PDFs in a web-application, I would delegate this task to the back-end.
[1] https://github.com/apache/pdfbox/search?utf8=%E2%9C%93&q=awt