We blog on issues relating to development with ASP.NET – the platform from Microsoft which allows you to build dynamic websites fast.

Case Study: Creating PDFs From ASP.NET Automatically

We completed another interesting project using technologies that we don’t normally use – creating PDFs from ASP.NET.

Our client supplies materials around the world to research institutions. For decades, every year they produced a paper-based catalogue – an impressive heavyweight document – which they send to all their clients and anybody else who wanted one anywhere in the world.

This was a successful marketing strategy and great customer service, but extremely expensive and very time-consuming.

They approached us to find out if we could automate the production of their product catalogue and make it downloadable from their web site. We said “Of course!” Then we had find out how to do that.

PDFs from ASP.NET

Since their web site technology stack includes ASP.NET, C# code, and Microsoft SQL Server, it made sense to source a software library that would easily fit in. We looked at several PDF libraries for ASP.NET and found the  most popular to be iText – but when we received a license quotation from them we realised it would not be financially viable to use this software. In the end we plumped for PDFSharp and MigraDoc.

Getting the data

Once installed, these libraries allow programmers to create PDF documents, add pages, images, paragraphs, tables of data, tables of contents, headers, footers, page numbers – exactly what we wanted.

First we created software classed that would extract the relevant data from the database, using the specified currency – our clients sell in GBP, Euros, US dollars, Japanese Yen and Swiss Francs.

Then we created classes using PDFSharp that would inject the product data in the right format and right currency into the document.

Once that was done, we focussed on building a table of contents.

Tables of Contents

Seemingly simple, the table of contents turned out to be one of the most challenging parts of the project. The client wanted two nested levels of contents – the main material and within that, the form of the material (sheet, rod, wire etc). All these had to linked to the relevant pages in the document, but of course it’s impossible to know which pages those products might appear on. Fortunately PDFSharp provides a way of setting up a bookmark and taking care of the page numbers itself – a very handy feature which makes internal linking easy.

Finishing touches

Finally we added a full-page cover image with the company’s logo, a terms and conditions page and introduction pages. We added headers and footers to the product pages with the company’s logo as a watermark to add polish and panache to the finished product.

Automatically generating the catalogue

The last piece of the project was to get the catalogue to be generated daily in each of the five currencies. To do this we set up a .net page which generates the catalogues and saves to the server’s filesystem, making them available to be linked to for download. We set up a scheduled task to allow this to happen daily at 5am. Finally, we added links to the catalogues from all the relevant points of the web site.

Good outcomes

This automatic system now does away with the heavy, expensive and out-of-date catalogue. Now our client can point their customers to a brand new downloadable catalogue that is produced every day so has the most up-to-date prices. They will save considerable amounts by not having to send the paper-based catalogue around the world. And customers can now download the catalogue in their preferred currency at any time from anywhere in the world.

Visit the client site

Use HTML5 for Killer Cross-Platform Graphics

PrezzieFrames screenshot

We’re pleased to announce the launch of a graphically intensive site developed in HTML5 using the Canvas technologies.

PrezzieFrames is a site offering customers the ability to customize a photo which is delivered anywhere in the world in a top-quality silver presentation frame.

On the surfac

change the background image;e the idea is simple – a user can upload a photo from their phone or computer, and this is placed in a virtual frame. The user can then manipulate the photo in a number of ways:

  • move the photo;
  • rotate;
  • zoom;

Users can also add text to the photo image and choose fonts and colours for the photo. The aim of the user interface is to ensure the user is guided intuitively through the process at every stage, using skills they already have (point, zoom, rotate).

Under the hood, some complex JavaScript and HTML5 Canvas coding has been developed, to allow the manipulation and saving of the image from the screen to a JPEG file of high enough quality to be printed and delivered within the presentation frame.

We used the fantastic Kinetic JS engine to deal with complex image manipulation routines.