Getting started

Development environment

TallPDF.NET has been compiled and tested with Microsoft Visual Studio.NET 2010 and Microsoft .NET Framework 2.0 and 4.0. TallPDF.NET is a 100% managed .NET component and consists of just a single assembly: TallComponents.PDF.Layout.dll. TallPDF.NET can be used with any .NET application, including console applications, WinForms applications, ASP.NET web applications, ASP.NET web services and Windows services.

NET Framework 2.0 and 4.0

TallPDF.NET 4.0 has been compiled against version 2.0 and 4.0 of the .NET framework. For .Net 4.0 we provide a “normal” version as well as a Client Profile build and a WPF build.

64-bit

All builds of TallPDF.NET 4.0 can be used on 64-bit machines.

Dependencies

TallPDF.NET does not depend on any third-party product other than the Microsoft .NET platform. It consists of just a single assembly.

The Microsoft .NET framework may be redistributed. It can be included in the installer for any product. For more information please read "Redistributing the Microsoft .NET Framework" at the Microsoft MSDN website.

Deployment

TallPDF.NET is fully compatible with the XCopy deployment principle of .NET. This means that installing TallPDF.NET is as simple as copying the single assembly to the installation folder of your application. For web applications this would be the /bin folder inside the virtual folder of your web site.

Although it is possible, there is no need to install TallPDF.NET in the GAC (Global Assembly Cache).

Classic ASP and COM

TallPDF.NET does not support the legacy technologies COM and ASP out of the box. However, the .NET Framework allows you to call .NET assemblies from a COM component. See "Calling a .NET Component from a COM Component" for more information.

Visual Studio .NET IntelliSense (C#/VB.NET)

The TallPDF.NET 4.0 installation includes the XML document file TallComponents.PDF.Layout.xml which is generated from our C# comments. If this file is in the same folder as the TallComponents.PDF.Layout.dll that is referenced from your project, TallPDF.NET documentation is added to Visual Studio .NET IntelliSense as shown in the following figure.

visual-studio-.NET-code-intellisense

Visual Studio .NET IntelliSense (XML)

The TallPDF.NET 4.0 installation includes the TallPDF.NET 4.0 XML schema file TallComponents.PDF.Layout.xsd. Copy this file to the following location:  

  • <program files (x86)>\Microsoft Visual Studio \Xml\Schemas
  Now you can select it as the targetSchema in the Properties view of Visual Studio .NET after which IntelliSense support is added.

select-the-TallPDF.NET-4.0-XML-schema-file

visual-studio-.NET-XML-intellisense

Hello World Console Application – C#

To create a Console Application in C# that generates a PDF document, do the following:  

  1. Start Visual Studio .NET.
  2. Select menu item File > New > Project.
  3. From the New project dialog, select project type ‘Visual C#’ and project template ‘Console application’.
  4. Enter a name for the project and the folder to store the project, then click Ok.
  5. A default project is created.
  6. Select menu item Project > Add Reference…
  7. Select the Browse… tab, select TallComponents.PDF.Layout.dll and click Ok.
  8. Open Program.cs or main.cs from the solution explorer.
  9. Replace the code in this file with the code below.
  10. Save, compile and run the application.
  11. Open the newly generated PDF document.
 

using System;
using System.IO;

using TallComponents.PDF.Layout;
using TallComponents.PDF.Layout.Paragraphs;

class Hello
{
   static void Main( string[] args )
   {
      // create a document
      Document doc = new Document();

      // add a section
      Section section = new Section();
      doc.Sections.Add( section );

      // add a text paragraph
      TextParagraph textParagraph = new TextParagraph();
      section.Paragraphs.Add( textParagraph );

      // add a text fragment
      Fragment fragment = new Fragment();
      fragment.Text = "Hello world!";
      textParagraph.Fragments.Add( fragment );

      // save document as PDF to disk
      using ( FileStream fs = new FileStream(
         “hello.pdf”, FileMode.Create ) )
      {
         doc.Write( fs );
      }
   }
}

Code sample: Hello World Console Application in C#

Hello World Console Application – VB.NET

To create a Console Application in VB.NET that generates a PDF document, do the following:  

  1. Start Visual Studio .NET.
  2. Select menu item File > New > Project.
  3. From the New project dialog, select project type ‘Visual Basic’ and project template ‘Console application’.
  4. Enter a name for the project and the folder to store the project, then click Ok.
  5. A default project is created.
  6. Select menu item Project > Add Reference…
  7. Select the Browse… tab, select TallComponents.PDF.Layout.dll and click Ok.
  8. Open Module1.vb from the solution explorer.
  9. Replace the code in this file with the code below.
  10. Save, compile and run the application.
  11. Open the newly generated PDF document.
 

Imports System.IO

Imports TallComponents.PDF.Layout
Imports TallComponents.PDF.Layout.Paragraphs

Module HelloWorld
   Sub Main()
      ' create a document
      Dim doc As New Document

      ' add a section
      Dim section As New Section
      doc.Sections.Add(section)

      ' add a text paragraph
      Dim textParagraph As New TextParagraph
      section.Paragraphs.Add(textParagraph)

      ' add a text fragment
      Dim fragment As New Fragment
      fragment.Text = "Hello world!"
      textParagraph.Fragments.Add(fragment)

      ' save document as PDF to disk
      Using fs As FileStream = New FileStream("hello.pdf", FileMode.Create)
         doc.Write(fs)
      End Using
   End Sub
End Module

Code sample: Hello World Console Application in VB.NET

Hello World ASP.NET Application – C#

To create an ASP.NET Application in C# that generates a PDF document, do the following:  

  1. Start Visual Studio .NET.
  2. Select menu item File > New > Project.
  3. From the New project dialog, select project type ‘Visual C#’ and project template ‘ASP.NET Web Application’.
  4. Enter a name for the project and the folder to store the project, then click Ok.
  5. A default project is created.
  6. Select menu item Project > Add Reference…
  7. Select the Browse… tab, select TallComponents.PDF.Layout.dll and click Ok.
  8. Open Default.aspx and delete all code except the first line: the @Page directive.
  9. Open Default.aspx.cs and replace all code with the code below.
  10. Save, compile and run the application.
  11. The PDF opens in the web browser.
 

using System;

using TallComponents.PDF.Layout;
using TallComponents.PDF.Layout.Paragraphs;

namespace WebApplication1
{
   public class MyPage : System.Web.UI.Page
   {
      protected void Page_Load(object sender, EventArgs e)
      {
         // create document
         Document doc = new Document();

         // add a section
         Section section = new Section();
         doc.Sections.Add(section);

         // add a text paragraph
         TextParagraph textParagraph = new TextParagraph();
         section.Paragraphs.Add(textParagraph);

         // add a text fragment
         Fragment fragment = new Fragment();
         fragment.Text = "Hello world!";
         textParagraph.Fragments.Add(fragment);

         // save the PDF directly to the browser
         doc.Write(Response);
      }
   }
}

Code sample: ASP.NET Web Application in C#

Hello World ASP.NET Application – VB.NET

To create an ASP.NET Application in C# that generates a PDF document, do the following:  

  1. Start Visual Studio .NET.
  2. Select menu item File > New > Project.
  3. From the New project dialog, select project type ‘Visual Basic’ and project template ‘ASP.NET Web Application’.
  4. Enter a name for the project and the folder to store the project, then click Ok.
  5. A default project is created.
  6. Select menu item Project > Add Reference…
  7. Select the Browse… tab, select TallComponents.PDF.Layout.dll and click Ok.
  8. Open Default.aspx and delete all code except the first line: the @Page directive.
  9. Open Default.aspx.vb and replace all code with the code below.
  10. Save, compile and run the application.
  11. The PDF opens in the web browser.
 

Imports TallComponents.PDF.Layout
Imports TallComponents.PDF.Layout.Paragraphs

Public Class MyPage
   Inherits System.Web.UI.Page

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _ 
      Handles Me.Load

      ' create a document
      Dim doc As New Document

      ' add a section
      Dim section As New Section
      doc.Sections.Add(section)

      ' add a text paragraph
      Dim textParagraph As New TextParagraph
      section.Paragraphs.Add(textParagraph)

      ' add a text fragment
      Dim fragment As New Fragment
      fragment.Text = "Hello world!"
      textParagraph.Fragments.Add(fragment)

      ' save the PDF directly to the browser
      doc.Write(Response)
   End Sub
End Class

Code sample: ASP.NET Web Application in VB.NET

Further reading