Project Description
Generate a PDF document from your webpage, selecting the HTML portions you want to add.

See a live demo


IIS 6+
MigraDoc (dll provided in the release zip) . Source code here
PDFSharp (dlls provided in the release zip). Source code here


The project is a Visual Studio 2010 solution, so it can be installed and tested directly on the development environment. The release download already have the required assemblies so you don't need to download MigraDoc and PDFSharp libraries.

If you are not interested in the source code, the project can be deployed as an IIS application, and for that you need to :
  1. Download the latest release from the Downloads tab.
  2. Copy the contents of the website folder contained in the rar file in a local directory (I usually use C:\Inetpub\wwwroot\DestinationPDF)
  3. Create a new Virtual directory and make it an IIS application in IIS Manager. In IIS7 you directly create the application by clicking "Add application"
  4. Make sure your new application's application pool is .NET 3.5
  5. Point the new application to the created folder (C:\Inetpub\wwwroot\DestinationPDF)

How to use the library in your own web page.

  1. Create a new ASPX page (or WCF service) that will receive the DestinationPDF requests from your web page. You can copy the ASPX included in the website
  2. Add the following references to it:
  • DestinationPDF.dll,
  • HTMLShot.dll,
  • MigraDoc.DocumentObjectModel.dll
  • MigraDoc.Rendering.dll
  • MigraDoc.RtfRendering.dll
  • PDFSharp.dll
  • PDFSharp.Charting.dll
  1. Add the following code to the <head> section of your web page
<script src='DestinationPDF.js' >
  1. Use the following code to add snippets of HTML to your PDF

var destinationPdf = new DestinationPDF({ 'URL': 'ServerScripts/DestinationPdf.aspx' });
/* repeat the following 3 lines to add more widgets */
        var titlePDFWidget = new PdfWidget({ 'type': 'HTMLStruct' });
        titlePDFWidget.setContent({ 'HTMLString': getHtmlString(document.getElementById('yourContainerHere').innerHTML), 
                                    'FullPath': window.location.href });
/* repeat these lines to add more widgets */


yourContainerHere is a <DIV> or other HTML element that contains the html snippet you want to add to the PDF.


Authors: Nicolas Lareu | Juan Sagasti


AustralTek is a US based company dedicated to developing industry solutions in the areas of Electrical Engineering, Automation and Industrial IT.
We utilize state of the art technology to produce tools that help optimizing the different production areas in a plant.
We are specialists in technological upgrades and in the integration of existing systems with superseded platforms, thus obtaining more accurate data and homogenizing plant information flow.

Last edited Apr 30, 2010 at 8:23 PM by jsagasti, version 14