Skip to main content

Posts

Showing posts from September, 2009

Dynamically Alter a PDF in ASP.NET Using iTextSharp...

Here's a class/method that can be used to generate a PDF order form on the fly, on your website.
It's only really applicable in the current state if you had a site that was selling a single product at a time, but this provides a proof-of-concept which you could extend/evolve to do more-or-less whatever you want, within reason. You wouldn't want to be (re)generating the PDF each time an order was placed for example, but it could be useful if you had a fax order form for a product(s) and their price(s) needed to be changed by (e.g.) 10%:

using System; using System.IO; using iTextSharp.text; using iTextSharp.text.pdf;
namespace YourProject.Utils { public class PDFGeneration { public static void RegenerateFaxOrderForm( string title, string rrp, string price) { // get the filename #if DEBUG string fileNameFaxOrderForm = @"\Content\Images\FaxOrderForm\FaxOrderForm.pdf"; string…