convert html to pdf software

Looking to convert HTML to PDF, or perhaps URLs to PDF, but you aren't sure where to start? Our WebGrabber PDF API makes it so easy, even someone with minimal coding knowledge can use it. But, rather than tell you how easy it is to use, we'll show you.

How to convert HTML to PDF in just 6 steps:

1. Ensure you have the necessary hardware and software

First and foremost, you can't expect to convert HTML to PDF without the necessary hardware and software. Luckily, the requirements are pretty low.

Basic Requirements

The following software is required:

  • Windows Server® 2008 (32- or 64-bit edition) OR
  • Windows Server 2008 R2 OR
  • Windows Server 2012 R2
  • Microsoft® .NET Framework (both .NET 3.5 and .NET 4.0)

The minimum hardware requirements are:

  • 350 MB of RAM
  • 175 MB of hard disk space (for application)

Download WebGrabber Installer

Installing WebGrabber

After verifying you have the appropriate software and hardware, there's one more vital piece to the puzzle: ActivePDF's WebGrabber. Our WebGrabber enables rapid, high quality, and server-based HTML to PDF conversion. It's dead simple to use, and best of all, you can download a free, single developer trial that includes unlimited assistance.

Once downloaded, you'll go through a typical installation phase:

  1. Log on to Windows Server (2012 and above) as Admin user.
  2. Create a new user account for the WebGrabber user.
  3. Add the new WebGrabber user to the Remote Desktop Users group to grant remote login privileges.
  4. Note: For more information about Remote Desktop Users, see this Microsoft article: 
    >> Configure the Remote Desktop Users Group
  5. Launch WebGrabber installer.
  6. Follow the Quick Start Installation instructions, and in the WebGrabber Internet Explorer Login Information section, when prompted for IE login, enter the WebGrabber user account created in the steps above.
  7. Complete the installation.

From there, you can select IE to enable it's use as a rendering engine (we'll cover this more later) by doing the following:

  1. Launch the WebGrabber Configuration Manager.
  2. In the WebGrabber top page, make sure the Enable Internet Explorer option is checked, then click the Save icon.

2. Add WebGrabber to your project

The code used in this tutorial will be C# since it's widely adopted by corporations both large and small, but WebGrabber works with VB.NET, VBS, ASP, PHP, CF, and Ruby as well. If you want to see how to convert HTML to PDF in those languages take a look at some of the code examples on our site.

Now at this point, you may be saying: "But I thought you said 6 easy steps! Code isn't easy!". But, as you'll soon see, WebGrabber was made to be as simple to use as possible. The PDF API calls you'll be adding to your application are simple and straightforward. So, let's dive right in.

For starters, you'll need to add ActivePDF's .net DLL(s) to your app and instantiate the object. By default, the .NET Assembly can be found at C:\Program Files\activePDF\WebGrabber\bin\APWebGrabber.Net35.dll

using System;
class Examples
{
   public static void Example()
   {
   string strPath;
   WebGrabberDK.Results.WebGrabberResult results;
   strPath = System.AppDomain.CurrentDomain.BaseDirectory;
   APWebGrabber.WebGrabber oWG = new APWebGrabber.WebGrabber();
   }
}

3. Choose Your Rendering Engine

WebGrabber offers two rendering engines for your choosing, each with pros and cons that enable you to either optimize for performance or for quality of the rendering. You can use IE or our own native engine. Before we tell you how to pick each, let's first go over which is best for your application:

Native Engine

The Native Engine is WebGrabber's default, built-in rendering engine. It is designed to provide the best print output.

Pros

  • Provides faster conversion speeds than the IE Engine
  • Handles output designed for print format better than the IE Engine
  • Embeds Flash® images
  • Supports Intelligent PDF features, such as preserving buttons and text-box functions
  • Creates bookmarks from HTML headings (h1-h6) by default
  • Creates links from href attributes found in HTML "a" elements

Cons

  • Output PDF may not match the source HTML as well as the IE Engine conversion

IE Engine

The IE Engine instantiates Internet Explorer for rendering. In general, anything rendered by Internet Explorer will appear in your output PDF.

Pros

  • Output PDF may match the source HTML more closely than the Native Engine
  • Handles output designed for online viewing better than the Native Engine
  • Prints Flash® images
  • Handles ill-formed HTML and CSS more gracefully

Cons

  • Does not render as quickly as the Native Engine
  • Custom tags may not render as expected
  • Does not support Intelligent PDF
  • Does not convert HTML headings to bookmarks

Selecting Your Engine

Choosing which engine to use is simple with the command below:

// Rendering engine used for the HTML
// Native = APWebGrabberInterface.ConversionEngine.Native; IE = APWebGrabberInterface.ConversionEngine.IE:
oWG.EngineToUse = APWebGrabberInterface.ConversionEngine.Native;

4. Determine How Your HTML will be Output

At this point, your app has loaded ActivePDF and you're ready to begin telling it what to output. This is done through several simple API calls. We've listed the most commonly used ones below:

  • Debug (extra logging for troubleshooting purposes)

// true = enable, false = disable
oWG.Debug = true;

  • Linearize PDF (fast web view)

// true - enable, false = disable
oWG.LinearizePDF = true;

  • Timeout Span (the amount of time before a request times out)

// (hours, minutes, seconds)
oWG.TimeoutSpan = new TimeSpan(0, 0, 40);

  • Set Margins (page margins)

// (Top, Bottom, Left, Right) and 1.0 = 1"
oWG.SetMargins(0.75f, 0.75f, 0.75f, 0.75f);

  • Orientation (page orientation)

// 0 = Portrait, 1 = Landscape
oWG.Orientation = 0;

  • Print Background (choose whether or not to convert the HTML background)

// true = enable, false = disable
oWG.PrintBackground = true;

  • Output Directory (where your PDF will be output to)

oWG.OutputDirectory = strPath;

  • New Document Name (the name of your new PDF)

oWG.NewDocumentName = "example.pdf";

Download WebGrabber

5. Choose the HTML you wish to convert

Choosing what HTML you wish to convert is incredibly easy! First you must decide whether you wish to convert a URL or HTMLText. We'll cover both below:

Converting from a URL:

To convert from a URL, you simply need to add the oWG.URL call to your application. You can choose both file locations, like: "c:\folder\file.html", and locations from the web, such as "http://domain.com/path/file.aspx". Used in your app, it'll appear like this:

oWG.URL = "http://examples.activepdf.com/samples/doc";

Converting from HTMLText:

Converting from HTMLText is a little more difficult, but can still be done in only 4 lines of code. There are two major steps that need to be considered. First is whether or not to save the HTML text into a file before conversion. This is done with the following API call:

// true = enable, false = disable
oWG.HTMLTextToFile = true;

From there, you simply need to specify the HTML to convert:

oWG.CreateFromHTMLText = "<html><body>";
oWG.CreateFromHTMLText = "Hello World!";
oWG.CreateFromHTMLText = "</body></html>";

6. Convert the HTML to PDF

Next, you need to perform the HTML to PDF conversion. No worries, WebGrabber will do all the heavy lifting for you. Simply add the following code to your app and you'll be good to go:

results = oWG.ConvertToPDF();
if (results.WebGrabberStatus != WebGrabberDK.Results.WebGrabberStatus.Success)
{
     ErrorHandler("ConvertToPDF", results, results.WebGrabberStatus.ToString());
     }
     oWG = null;
     WriteResults("Done!");
}

And there you have it. You now have everything you need to convert HTML to PDF!

Got a Question?

ActivePDF's support is unsurpassed. And those aren't our words, they're our customers! If you still need help converting HTML to a secure PDF File, reach out to our technology advisers and we'll answer your questions, find solutions, and give you a greater turnaround time than any other company can.