by

Crocodoc .NET API Library released

Reading Time: 2 minutes

It’s probably not the most exciting thing that you could read about, but it’s definitely one of the cooler ones. If you haven’t heard of Crocodoc, you really should check it out.  Crocodoc is an API that converts PDF and Microsoft Office Documents to HTML5. If that still doesn’t quite ring clear, allow me to rephrase; Crocodoc converts documents from something that requires another application (like a PDF reader or Microsoft Word) to read, into something that a web page can read. And it does a really stinking good job at it.

So What’s the Back Story?

At Tahzoo, we had a client who was embedding PDFs on their website, but the existing PDF embedder just wasn’t doing the job. The client had requested that Tahzoo provide a better embedding solution, so we’re obliging them.  Crocodoc is an API that requires server-side communication; Ajax isn’t an option (trust me, I tried). If you’ve looked at their site, you’ll see that the four official API libraries that they offer are for Python, Ruby, Java, and PHP. They have some third party libraries that work in Drupal and WordPress (PHP platforms) as well as another for Node.js, which admittedly, is kinda cool.

At Tahzoo, we specialize in SDL Tridion, which is a Content Management System that runs on .NET at its core. If you’re keeping track, .NET wasn’t on that list anywhere. Further to that, our client wasn’t really using any of the languages that Crocodoc was offering. So, it’s time to get creative.

The Making of a Crocodoc .NET Library

.NET is not one of my strongest languages, but fellow coworker, code-monkey, and friend Alex Klock speaks .NET fluently.  So we teamed up to build a brand new .NET library. We looked over the Java library to get some ideas and inspiration on how to structure things, and then took off with it. We took an object-oriented approach to it and built classes that follow the different methods which Crocodoc’s API uses.  We also used the WebClient class quite a bit, and we threw in some solid exception handling. In addition, Alex caught something that was missed in the Java library, which was an option to work with proxies.

 What else?

There will be some follow-up posts on how to skin and enhance the Crocodoc session at a later date and time. I’ve already worked out some cool fullscreen tricks and whatnot.

Wait, where’s that library?

It’s all open-source-y up on the Googles: https://code.google.com/p/crocodoc-dotnet/