Ask Slashdot: Best PDF Handling Library? 132
New submitter Fotis Georgatos (3006465) writes I recently engaged in a conversation about handling PDF texts for a range of needs, such as creation, manipulation, merging, text extraction and searching, digital signing etc etc. A couple of potential picks popped up (PDFBox, itext), given some Java experience of the other fellows. And then comes the reality of choosing software as a long term knowledge investment! ideally, we would like to combine these features:
- open source, with a community following ; the kind of stuff Slashdotters would prefer
- tidy software architecture; simple things should remain simple
- allow open API allowing usage across many languages (say: Python & Java)
- clear licensing status, not estranging future commercial use
- serious multilingual & font support
- PDF-handling rich features, not limiting usage for invoicing, e-commerce, reports & data mining
- digital signing should not go against other features
I'd like to poll the collective Slashdot crowd wisdom about if/which PDF related libraries, they have written software with, keeps them happy for *all* the above reasons. And if not happy with that all, what do they thing is the best bet for learning one piece of software in the area, with great reusability across different circumstances and little need for extra hacks? I'd really like to hear the smoked out war stories. It is easy to obtain a list of such libraries, yet tricky to understand whethe people have obtained success with them!
Re: Why? (Score:2, Insightful)
To be fair the OP does say "ideally."
Re: (Score:1)
Re: (Score:3)
Indeed. I'm curious why is not "closed source, with a strong industry support" an option?
Because both "open source" and "strong industry support" when put together like that pretty
much means that they don't want to get stuck holding the bag if the company goes out of business.
With "strong industry support" the odds of a company going out of business is minimized and
with "open source" even if it does go out of business then you can still continue to use the
software indefinitely while you look for a replacement.
Re:Why? (Score:4, Interesting)
I'm using a non-free, but source-provided library called Clib-PDF. It's a pretty nice library with a pretty easy API, and even has PHP bindings (so it must've been a viable mainstream choice at one point). But somehow the company (or was it just a single guy) disappeared years ago. Luckily, we paid for and got the source, and I've been able to keep using it (and even fixing things in the source) without any ongoing support. So not quite open source, but not quite the disaster of discontinued closed source.
I suspect that the author of this library sold it to one of the commercial companies who proceeded to shut down a viable competitor. But who knows...
Re: (Score:1)
Indeed. I'm curious why is not "closed source, with a strong industry support" an option?
i guess because he knows what kind of crap *that* can be.
of course his full requirement list is ridiculous, nevertheless as a request to the community on a public forum. anything else? this dude is just looking for someone else wanting to do his fucking job, but he also wants a medal for it (read: a tap on the shoulder). likely he *is* in a "closed source, with a strong industry support" environment, so screw him.
Re: (Score:2)
Re: (Score:1)
Re: (Score:2)
your nice language
please note that the ad hominem in my comment was rethoric. It was actually referring to the content of your article and the attitude it implies. I think it should be obvious but maybe it is worth pointing it out now.
of course many may have learnt something interesting from the ensuing threads. like with any other discussions. that's the cool thing about fora. but I still find that simply dumping the full set of requirements for your assignement on a public forum isn't professional or nice at all. you can
Re: (Score:2)
Any number of reasons. A big one is stability. If it's open source, it won't go *POOF* one day. It won't double in price one day. It won't get an ugly redesign with no ability to stick with the version that worked.
Then there's the ability to work out the finer points where the documentation was unclear, greater ability to debug any problems
I can't imagine a good reason that open source with a strong community wouldn't at least be a nice to have for any software.
Re: (Score:1, Insightful)
Yes ... and their principles are; I want somebody else to do a lot of hard work and I want the benefit for free. Oh, and I don't even want to research this myself, I want others to do the work ... for free.
Re: (Score:2)
Oh, and I don't even want to research this myself, I want others to do the work ... for free.
Thats a bit unfair. I had a need to convert some output into PDF a while back and started looking thru the many proprietary and open source options, and there were a lot to choose from. It was awfully hard to determine which were quality and which weren't. Installing and trying to program a working solution against each API would have taken up a huge amount of time. There is nothing at all wrong with asking if others have been thru some of that process and found a favorite. I certainly would have liked
Re: (Score:2, Funny)
Well, he's dealing with PDFs, so he doesn't have *strong* principles.
Re: (Score:2)
Re: (Score:1)
How open is it really?
Is it a true open standard like TCP/IP, or more like a rubberstamped "standard" by a single company like OOXML?
What prevents Adobe from adding incompatible features to Acrobat and Adobe Reader, and thus make the PDF unreadable by software that adheres to the so-called standard? For example, last year, I could connect to the danish tax department from my Linux machine, using standard TCP/IP, only to be told that to view my tax returns I would have to install Adobe Reader.
Never have I be
Re: (Score:2)
Re: (Score:2)
Nothing prevents Adobe from adding incompatible features. In fact, nothing stops Adobe from adding compatible features. We have a use case for U3Ds embedded in PDFs (as per the ISO Standard, 13.6), and I haven't found any PDF reader other than Adobe's that displays that.
Re: (Score:1)
Re: (Score:2)
I think that means you haven't seen enough PDFS. Adobe makes heavy use of proprietary add ons that only work with Adobe products. Then there are all the security vulnerabilities they can contain.
PDFS are great for internal use, if you create them and you consume them. Dealing with those made by random people kind of sucks. Sometimes you get a pdf that's just composed of images for each page. So no text extraction is possible.
I'm not recommending any libraries for the original poster, because they all suck i
Re: (Score:2)
Text extraction can be a pain even if the text is not images, due to encodings and text placement. Also, it doesn't take proprietary add-ons to lose all open source viewers I'm aware of: I know of none that support the 3D images in the Standard, chapter 13.6.;
Re: (Score:2)
Specially if you need to extract data from it
That's not what it's for, is it? Except by the method of reading, with your eyes.
Re: (Score:3)
Re: (Score:2)
Other people have politicians that require you to use open source if available.
Re: (Score:3)
Some people have principles.
He could be working on an open source project
Re: (Score:3)
open source, with a community following ;
Why? So if you find one that fits every other requirement but this one you will refuse to use it?
Derp,
Probably because if there is no community following it there is not going to be much in the way of development going on.
Re: (Score:2)
Probably because if there is no community following it there is not going to be much in the way of development going on.
Right. With mid-tier open source projects, there's a good chance they're either unfinished or abandonware. (Lower-tier open source projects are both.) There's only so much attention available.
Yeah! Why would anyone want it maintained? (Score:5, Insightful)
Because maybe it's not his first project? Fine, let me ask you: how many times did you get burned by totally unmaintainable third-party dependencies, before you vowed "NEVER AGAIN will I get so utterly fucked over?"
Was your fifth project the one where you couldn't ever port to a new architecture or OS, or was it the one where the only company who had the source, went into bankruptcy and it took years for the liquidation to happen and you never really figured out where the assets are? No wait, your fifth project was the one where they just withdrew it from the market for "strategic reasons" and you never found out why and there was no replacement. Ah, then there was the race condition that you knew you could find if only you could read through the code, but the sole developer didn't even know what "race condition" means so he ignored your bug report. And the time the DRM server incorectly said the API key had expired so you didn't get any sales that day. Then there was that time you had the source but weren't allowed to change some parts of it: I loved the comment "by reading this you are violating the License Agreement" followed by the base64 string of dynamically interpreted code. Of course you violated the agreement, and decoded it: finding a bug you weren't allowed to fix. And of course let's not forget the time the developer might have actually hypothetically allowed the code to be maintained or might have even done it himself, but he had lost it, the one and only copy in the entire world, which had been used to compile the code that literally tens of thousands of people were depending on. That one's a classic, almost right up there with the vendor who died, taking all his customers' hopes of maintenance with him to the grave.
Holy crap. I get why the public doesn't know to demand Free Software. Even smart people can be uninformed or lack expertise outside their areas. But developers, really? You have to be LITERALLY STUPID to not see "open source" as at least a major advantage, if not necessarily always the winner. Maybe it's not always a solid requirement, but if you don't always at least start your searches that way and try to get something that at least can be maintained, then yes, you're a moron.
"Oh no, I'm not a moron," you explain, "I just happen to think that some large projects aren't ever going to need maintenance, because surely it's simple enought that a good programmer will get everything right the first time." You're right: you're not a moron; you're an imbecil. Sorry about the mistake.
Re: (Score:3)
Because maybe it's not his first project? Fine, let me ask you: how many times did you get burned by totally unmaintainable third-party dependencies, before you vowed "NEVER AGAIN will I get so utterly fucked over?"
This. Wish I hadn't run out of mod points -- and frankly I'm tired of some bottom of the barrel programmer who's attitude is "we can just rewrite everything every 5 years" get promoted into management and then tie our code to whatever proprietary crap the next cute sales person brings.
Separate. Isolate. Defend. Treat every piece of third-party code that you don't have source for as an enemy whose only goal is to financially rape you. I don't care if that enemy goes by Oracle, Microsoft, or Joe's Dis
Re: (Score:2)
Separate. Isolate. Defend. Treat every piece of third-party code that you don't have source for as an enemy whose only goal is to financially rape you. I don't care if that enemy goes by Oracle, Microsoft, or Joe's Discount Software.
Having the source doesn't help you if it's an unmaintainable piece of crap, which is presumably where the OP's requirement for a community came from - if a load of people are hacking on it actively then there's a good chance that, if you end up needing to maintain it in-house, there's a pool of people to hire or send consulting work to.
Re: (Score:2)
Having the source doesn't help you if it's an unmaintainable piece of crap,
Agreed. Having the source is necessary, not sufficient.
Re: (Score:1)
ReportLab (Score:4, Informative)
Python only, but I've used it successfully.
PDFLib (Score:2, Insightful)
Well, there's PDFLib, which is hideously expensive and not open source, but if you're after a professional package for serious purposes that just works I can only recommend it.
Re:PDFLib (Score:4, Informative)
PDFlib is cheap compared to licensing Adobe's libraries from DataLogics. (speaking as one who switched from the latter to the former).... A full source license for pdflib and tetlib were much less that Adobe/DataLogics non-source license... less than 1 FTE. Then again, your milage may vary.
PDFLib happens to be the cleanest and best PDF code solution I've ever worked with.
Re: (Score:3)
You know whats funny is PDFLib is what Adobe calls the set of core tech libraries to generate PDF files inside their own apps. (source: used to work at Adobe - on Acrobat no less)
Re: (Score:3)
FPDF [fpdf.org] Combine with TCPDF above to create a PDF-writer using PHP
SetAssign [setasign.com] Not open-source but this company offers both free and paid libraries that combine with the libraries above to allow PDF encryption / decryption using PHP.- The paid versions support more complex ciphers and I swear by them personally
Not sure if you meant desktop software or...
Re: (Score:1)
I second this. PDFlib is good software for making PDFs. Their TET tool for extracting text can return to you where (coordinates) each letter on a page is, if you desire, or just dump the whole page or each word at a time, etc.
pdf.js (Score:5, Informative)
pdf.js is great for parsing and manipulating pdfs.
I can't go into great detail as to how I've used it (Still under NDA), but it's rendering and manipulating of pdfs is pretty darn good.
As for converting office formats to pdf, your best bet is to use office automation. It can be built to scale up, but it needs a lot of work to do so.
Re: (Score:3)
Office Automation is problematic -- because it literally opens up a hidden window of your Office app and simulates clicking around the UI to do what you need, if something unexpected happens it can unhide the window to show the user a message. This might be good enough for a desktop app, but if you're running it on a server it'll just freeze up your process with noone there to click it.
For Office->PDF conversion of word docs, Aspose.Words has a fairly easy API and generally very accurate rendering. I hig
Re: (Score:3, Informative)
Re: (Score:3)
I've found these tools useful (Score:5, Informative)
I've found these tools useful, with an honorable mention to gnupdf. I've never used it personally, but the code looks pretty solid. That said, when I really needed to produce great multilingual PDF I pulled out the PDF spec, gritted my teeth, and generated it directly.
leptonica - turn images into PDF
tesseract - turn images into searchable PDF
qpdf - linearize PDF for random access over HTTP
jhove - basic validation
jhove-pdf-a - validation with better compatibility guarantees
pdftk - command line tool for splicing pages together or apart
ttx/FontTools - tool for modifying custom fonts
reportlab - python library, easy to use but works best with Latin scripts
Re: (Score:2)
You know any that can convert simple HTML with simple CSS into pdfs? Preferably with support for dataURL in image tags?
Re: (Score:3, Interesting)
sudo apt-get install wkhtmltopdf
wkhtmltopdf www.google.com google.com.pdf
Re: (Score:2)
Great tool for HTML conversion. Doesn't meet the OP's criteria, but it's the best open source HTML to PDF converter I've found.
Re: (Score:3)
I have no idea if it supports data: URIs but I've used HTMLDOC to turn html tables into PDF (since every PDF library I've ever used is absolutely shit at tables compared to HTML). It supports inline styles and <style type="text/css"> tags. It's not quite dead, but this year's update was the first since 2006 [msweet.org].
Re:I've found these tools useful (Score:4, Interesting)
Yes the Flying Saucer [google.com] Java library. It is one of the best XHTML to PDF converstion tool.
Re: (Score:2)
This library uses iText, unfortunately my projects are closed source and the budget for libraries is zero.
Re: (Score:1)
FlyingSaucer uses iText 2, which is licensed under the LGPL - that might maybe make it OK (and free) to use?
Re: (Score:2)
Hm, if I am not mistaken iText 2 is LGPL so I believe it would work for me. Thanks!
Re: (Score:2)
I forgot to mention PDF rendering engines. Neither support the entire spec, nor do I blame them.
poppler - widely used
pdfium - high performance, recently open sourced
IText (Score:1)
You might try IText:
http://en.wikipedia.org/wiki/IText
pdftk uses it.
Re: (Score:2)
Re: (Score:1)
itext appears to miss two-three major targets:
Re: (Score:1)
The problem with iText is that it used to be MPL, but the maintainer got ticked off at commercial users several years ago and changed to license to AGPL. Apparently now they're relaxing the license for a fee, but they've changed their mind before - no guarantees that they won't change it again.
Prince XML (Score:3)
The best PDF software I've ever used is Prince XML.
For years, we got by with HTMLDoc but finally dumped it because we absolutely needed unicode support.
After trying many different packages, we settled on Prince. Our main constraints were performance related which you apparently aren't worried about, so maybe it's overkill for what you need.
Re: (Score:2)
After investigating and trying at least 9 other open source kits I eventually gave up and went with PrinceXml. You can try the 'trial' version easily and it just works easily. Their support is actually good as well. I wish there was a good pdf toolkit that was open source. But they all seem to just do one odd piece of the puzzle poorly.
Re: (Score:1)
PrinceXML is reliable, simple and produces the most beautiful PDFs ever. We've used it to replace InDesign as a tool for high end magazine page generation and have analysed the output of both - PrinceXML is significantly cleaner. However, it does help if you combine it with an image (re)sizing tool otherwise you end up with huge bloat with oversized images embedded in your PDF.
"Slashdot Crowd Wisdom" ! (Score:5, Funny)
See, now thanks to you I have to clean all this coffee off my monitor...
Re: (Score:2)
You should post a question to the Ask section, maybe some of us have some tips for cleaning it off? ;-)
Re:"Slashdot Crowd Wisdom" ! (Score:4, Funny)
Re: (Score:3)
I suggest librag.
Re: (Score:2)
I stick a mop head into a 600W cordless drill. Be sure to weak safety glasses.
It does a lousy job of cleaning coffee off your monitor, but your co-workers will think you're a total badass.
And like jones_supa says, make sure it's an open source mop. And post photos, please.
Re: (Score:3)
iText has some problems with licensing for commercial applications and government projects. I am looking for an alternative.
For serious archiving. (Score:1, Interesting)
Make this becomes a requirement: support for making PDF/A.
I'm convinced there is no elegant PDF library (Score:5, Informative)
At least on the C# side of things, the three libraries I've used (iTextSharp, PdfSharp, and Aspose.Pdf) are all a bit of an unintuitive mess with inconsistencies all over the place and very little documentation. In the case of iText, their revenue stream is putting all their documentation into a book for people to buy, so it's not uncommon to get an intentionally vague response when asking for help.
I cycle between each depending on what I need to do, because they all have their own quirks and supported features. I've even piped from one to another to get certain parts of the process working.
Good luck.
Re: (Score:3)
It could be that iText is just what he needs though. iTextSharp is the C# port of the original iText Java library. At times, it is easier to find code examples for iText than iTextSharp. Since the iTextSharp folks did their best to use C# conventions, the Java call names aren't always the same as the C# ones.
Re: (Score:2)
try... (Score:4, Informative)
sudo apt-get install ghostscript pdftk poppler-utils
ghostscript: /usr/bin/dvipdf /usr/bin/pdf2dsc /usr/bin/pdf2ps /usr/bin/pdfopt /usr/bin/ps2pdf /usr/bin/pdftk /usr/bin/pdffonts /usr/bin/pdfimages /usr/bin/pdfinfo /usr/bin/pdfseparate /usr/bin/pdftocairo /usr/bin/pdftohtml /usr/bin/pdftoppm /usr/bin/pdftops /usr/bin/pdftotext /usr/bin/pdfunite
ghostscript:
ghostscript:
ghostscript:
ghostscript:
pdftk:
poppler-utils:
poppler-utils:
poppler-utils:
poppler-utils:
poppler-utils:
poppler-utils:
poppler-utils:
poppler-utils:
poppler-utils:
poppler-utils:
Re: (Score:1)
This. These three are what you need; you can then script a wrapper around them if you need to, but they'll provide you with everything you need as far as actual manipulation and display goes. Poppler keeps it simple, pdftk can handle most manipulation needs, and ghostscript is there to covere any esoteric issues that still fall under postscript/pdf/EPS.
Might want to also include imagemagick, for import/export/optimization of most image formats you might be bursting/adding in PDF.
Re: (Score:2)
here is one (Score:1)
itext [itextpdf.com] may be one of those. It comes under AGPL and under a commercial license if you buy support from the company.
One word: PDFLib (Score:5, Informative)
PDFLib GmbH [pdflib.com] (german LLC) build exactly one product: PDFLib. And they've been doing that since 1997. AFAIK the company was run by one guy - the initial developer - alone for most of the time. Now it's probably a shop of 5 or so.
So it's not FOSS - yeah, that's a real shame. But the devs get to eat, you can demand service and response if you run into a bug and you can expect a good product and with PDFLib you're probably going to get it too.
I haven't come across a single project doing non-trivial PDF stuff that doesn't use PDFLib. I've used it myself a little, and the cookbook that comes with the product was very good, so it comes recommended.
My 2 cents.
Re: (Score:2)
Re: (Score:2)
The trouble I can see with PDFLib is the stupid "per machine" licensing. Per machine licensing for a software library is ridiculous - the description of the license on their website pretty much rules out using it in any situation other than some sort of central PDF processing behemoth service.
Clearly you haven't dealt with Oracle's licensing, compared to that, PDFLib is highly liberal stuff. They even give you one machine free (dev box).
BFO (Score:2)
Java-only. Commercial. Feature-rich. Great company name. [faceless.org]
PDF Clown (Score:2)
We used PDFClown [stefanochizzolini.it] (open source - Java) for production applications that were generating PDF's on the fly with hundreds of pages using Java and it performed very well.
iText (Score:2)
iText meets some of your criteria.
* open source, with a community following ; the kind of stuff Slashdotters would prefer = yep. Including several commercial books .NET. Not a good fir for dynamic languages.
* tidy software architecture; simple things should remain simple = It's big and complete.
* allow open API allowing usage across many languages (say: Python & Java) = Native Java. iText# is a port to
* clear licensing status, not estranging future commercial use = AGPL + commercial license. Clear but
WeasyPrint (Score:2)
MuPDF? (Score:1)
HMRC's CT600 form - PDF forms (Score:2)
Is there anything that can handle the gruesome CT600 forms that the UK Tax authority require us to fill in every year? These have lots of embedded scripting and can only be read with Acrobat Reader. However, this year, Adobe have stopped releasing Acrobat for Linux.
(An added bonus, the internal logic of the CT600 is buggy: for example if a particular tax option does not apply, it is fussy about the distinction of 0 vs empty, and this leads to subsequent validation errors (naturally with confusing messages)
PrinceXML (Score:1)
FOP? (Score:3)
Not sure how current it is, but when I was looking for the same a few years back all that was really available for PHP was HTML->PDF libraries which were not sufficient for anything but the most basic forms. A decent invoice form was hard to get right with these tools. Then I came across FOP. Or more specifically XML-FOP. Combine that with a little XSL and the output was amazing, and could do more than the HTML converters. The only problem is that the FOP tool was a Java based program so PHP would need to execute a shell command to call it. With tight control of what info was passed to that shell command, it seemed an appropriate trade-off for the job at hand. You can still get FOP in the ubuntu repos - apt-get install fop. The learning curve for FOP is a little steep to begin, but no more than any other XML dialect. And being XML, you have a lot of options in building the required FOP file. I opted to put my data into my own XML file, then utilize an XSL file to convert it if/when needed. More details here: http://xmlgraphics.apache.org/... [apache.org]
grep (Score:2)
dpkg -l | grep pdf | grep lib | grep ii
ii libqpdf13:i386 5.1.1-1 i386 runtime library for PDF transformation/inspection software
PDF::API2 and CAM::PDF (Score:1)
Are both quite good, as they names suggest these are Perl modules though.
Re: (Score:1)
Re: (Score:1)
MuPDF for rendering (Score:2)
At least on the rendering side, I have found MuPDF to be really good and stable: http://mupdf.com/ [mupdf.com]
PDFSharp, if you're using .NET or Mono (Score:1)
I'll be honest that I don't have a broad range of experience with libraries. I've used a couple of html-to-pdf implementations and PDFSharp. The licensing for PDFSharp is very permissive, support can be paid for if required and the library is quite fast. As an aside, it has a cousin, MigraDoc, which produces abstract documents which you can finalise to Office formats, if you need that too.
IMO, there is no perfect tool, but PDFSharp has served me well.
most likely (Score:1)
Re: (Score:2)
libpoppler works; it just only meets the requirements that libpoppler was designed for. It correctly displays most PDFs, but fails with esoteric features used only in a small subset.
In that sense, libpoppler is like a swiffer mop: it handles most normal dirt, dust, and general cleaning needs for tile and hardwood; but you will need a mop, or potentially nylon or bristle scrubbers and power tools, to clean some deep-set grime from linoleum or porcelain tile. I've had mops fail to clean traffic grime fr
Re: (Score:3)
I use a cordless drill and brush bit to make my PDF files, too. It's slow, and it doesn't really scale well, but at least it's not from Adobe.
Re: (Score:2)
Re: (Score:1)