How to print PDF from ASP on a tightly-managed network.
April 9, 2010 8:13 PM   Subscribe

Looking for a free PDF creator/library that works from ASP for a very picky client.

OK, I know there are a bunch of different PDF libraries out there, but I'm having trouble finding one that will pass muster for the current project.

I am programming a portal on a government network that will accept inspection reports from numerous field offices through a web interface (ASP-based) and store them in an SQL Database. In addition to simply accepting the reports, it needs to be able to output the information into a properly-formatted memorandum -- preferably PDF, although MS Word is also possible in a pinch -- that can then be printed and handed to the bosses at different levels for signature.

The problem is that it is very difficult to get new software authorized on government networks, so some form of ASP library is the only way I have to dynamically generate the reports. (The only reason I can use ASP is because they started using SharePoint and it requires ASP to power the back end.) Any suggestion is useful, however free would certainly make it easier to justify.
posted by mystyk to Computers & Internet (7 answers total)
Having gone through a very similar process recently, and being appalled at the scarcity of suitable alternatives, I can recommend these two: ABCpdf and iTextSharp.
posted by Cobalt at 8:38 PM on April 9, 2010

Keep in mind, free in cost doesn't always mean free of obligations. ABCpdf is free if you put a link to them in your application, possibly disallowed in a government application, it does have a pretty cheap commercial license available. The current release of iTextSharp appears to be licensed under the Affero General Public License which is the more viral / copyeft license there is. It is almost certainly not going to be allowed on a government or commercial application/ website. Older versions may be available under a more liberal open source license. I believe you can buy a commercial license for it as well which allows you to ignore the AGPL.
posted by bottlebrushtree at 10:48 PM on April 9, 2010

CutePDF has a very liberal licence. Can it be persuaded to do what you want?
posted by flabdablet at 2:17 AM on April 10, 2010

it needs to be able to output the information into a properly-formatted memorandum -- preferably PDF

I did something similar with php (almost a decade ago). I first created a PDF template with unique placeholders for different fields (e.g. %%project_description%%). So for each document request, I read the template pdf into a variable, replaced the placeholder text with fields retrieved from the database and saved that to a new pdf with an appropriate filename and served it to the browser.

Could you do something like that?
posted by special-k at 3:29 AM on April 10, 2010

Does it need to be exported to a document format or does it just need to be printed in a specific way? Because if the requirement is just about how it looks when printed, you can probably achieve what you want with a print style sheet, which will allow you to make the report look totally different when printed.

If it has to be a PDF, there are a number of resources here including this library which works with ASP.
posted by yerfatma at 8:41 AM on April 10, 2010

Unfortunately, none of these gave me the answer I was hoping for, but they certainly have me good leads for how to accomplish it.

I may have found a solution that also saves money, but isn't optimal. The problem comes, as yerfatma was questioning, from the fact that the output has to be a memorandum. Depending on the circumstances, they may vary from 3 to 20 pages, although there are only 3 main layouts (individual, partial roll-up, and complete roll-up). It is normally produced in Word, and needs specific margins as well as paragraph controls and headers/footers that differ for the first page.

One of the leads took me to a page explaining how to output directly as a word document from ASP by virtue of formatting the document using XML. Since word is the way things are done now, it will suffice until I can find a PDF-based solution. Plus, it's free and requires no plugins or libraries.
posted by mystyk at 11:04 AM on April 10, 2010

Would XSL-FO and FOP be helpful to you? (XSL:FO = eXtensible Stylesheet Language - Formatting Objects; FOP = Formatting Object Processor.)

XSL:FO is yet another XML kin that lets you create markup to generate print formats, including PDF. I think FOP was originally developed with the Apache project, but there may be FOP ports for .Net and the Microsoft IIS web server. (I'm guessing that, since you're using ASP.Net and the site is using Sharepoint, you're stuck with an IIS web server.)

The basic idea is that you'd dump your data from the SQL databse to XML, transform that XML using XSLT to an XSL:FO document, then use FOP to push that out as a PDF document.

One aspect I'm not so certain of what's available for FOP in Microsoft's world, and ideally in .Net.

The mini tutorial at presents the ideas failry well. The rest of the tuturial is also a good read, if you're interested in XML. Also take a look at

Hope this helps.

[I can't believe I finally joined MetaFileter just so I could share my "knows just enough to be dangerous" knowledge of XSL:FO!]
posted by sbigelow at 11:31 AM on April 10, 2010

« Older Need help with scrollable credits for a video.   |   Chicken Soup for the Girlfriend's Stomach Newer »
This thread is closed to new comments.