Click to Convert SDK / API for the Server and Desktop

Use our easy API to convert documents to PDF or HTML on your server or desktop. Click to Convert's API works on any Windows PC and you can control the conversion process using a simple script. Check out the examples below and download the samples - you'll be up and running in minutes.

How Easy is it?

It's really quite easy - you can download the samples and modify them to your needs quickly. The basic script for using the API is made up of two sections - setting conversion settings and then converting documents.

Simple Example?

Below is a simple example that creates a PDF and HTML conversion from a Microsoft Word document. Download this and other examples from the link on the right.

		
  ' Create the Click to Convert "API" object so that we can access settings etc.
  Set oApi = CreateObject("ClickToConvert.API")
  Set oDocumentRenderer = CreateObject("ClickToConvert.DocumentRenderer")

  ' Set some basic conversion settings.
  oApi.CreateHTML = 1	' Create HTML web-pages
  oApi.CreatePDF = 1	' Create a PDF file
  oApi.AppendPDF = 0	' Don't append the PDF to an existing PDF
  oApi.OpenHTML = 1		' Open the HTML after conversion
  oApi.OpenPDF = 1		' Open the PDF after conversion

  ' Set the output folders for the PDF and HTML conversions.
  oApi.PDFFilename = "C:\\Temp\\abc.pdf"
  oApi.HTMLOutputPath = "C:\\Temp\\"

  ' Automate the conversion - don't ask for user for settings:
  oApi.ShowUI = 0		' Automatic conversion - no user interaction

  ' Set some font, security and bookmark options for the PDF conversion.
  oApi.PDF_BuildTOC = 1				' Create a table of contents in the PDF
  oApi.PDF_FontEmbedding = 1		' Embed TrueType font subsets in the PDF
  oApi.PDF_WatermarkText = "Sample"
  oApi.PDF_Security = 1				' Secure the PDF (MUST set open or change password)
  oApi.PDF_OpemPassword = ""		' Anyone can open the PDF
  oApi.PDF_ChangePassword = "abc"	' Password required to change PDF
  oApi.PDF_PreventPrinting = 1		' Security - prevent printing of PDF
  
  ' Create a table of contents for the HTML conversion.
  oApi.HTML_BuildTOC = 1	' Build a table of contents from document headings
  oApi.HTML_Navigation = 1	' Add a navigation bar at the top of HTML pages

  ' Lock Click to Convert for other conversions.
  oWS.RegWrite "HKEY_LOCAL_MACHINE\Software\Inzone Software\ClickToConvert2\CallingMode", 1, "REG_DWORD"

  ' Convert the file to PDF and HTML using the above settings.
  If (oDocumentRenderer.GetLock = True) Then
    sPDFFile = oDocumentRenderer.RenderDocument(CStr("C:\\Temp\\WordDocument.doc"), "CLICK TO CONVERT COM-OBJECT LICENSE KEY HERE")
    oDocumentRenderer.ReleaseLock
  End If

		

COM API Key

You need a COM API key to use the SDK - to get one simply e-mail us and we'll send you one.

API Settings

Controlling the PDF and HTML conversion process is easy. Use the API settings documentation below for examples:

Creating the API and DocumentRenderer Objects

The first step you must take whenever you use the Click to Convert API is to create the API and the DocumentRenderer objects.

Example (VBScript):

Dim oApi
Dim oDocumentRenderer
Set oApi = CreateObject("ClickToConvert.API")
Set oDocumentRenderer = CreateObject("ClickToConvert.DocumentRenderer")

Controlling PDF and/or HTML Generation

CreateHTML
CreatePDF

Integer 0 = No
Integer 1 = Yes
Default = let the user choose through the interface

These settings let you choose if Click to Convert generates PDF, HTML or both renditions. Setting the values to 1 will cause a rendition of that type to be generated, setting them to 0 will cause the type not to be generated. The default is to let the user choose through the Click to Convert user interface.

Example (VBScript):

oApi.CreateHTML = 1	' Create HTML web-pages
oApi.CreatePDF = 1		' Create PDF

Showing and Hiding the User Interface

ShowUI

Integer 0 = No
Integer 1 = Yes
Default = 1

This setting tells Click to Convert to either show or hide the user interface during generation of PDF and HTML renditions. A value of 0 will cause the interface to be hidden, a value of 1 will allow the interface to be visible to the user. The “ShowUI” setting refers to the main “Publish Settings” user window which gives users control of the conversion.

Example (VBScript):

oApi.ShowUI = 0	' Automate the conversion

Naming your PDF Files

PDFFilename

String Value
Default = let the user choose through the interface

This setting controls what Click to Convert will name the PDF file it creates. The default is to let the user choose through the Click to Convert user interface.

Example (VBScript):

oApi.PDFFilename = "C:\\Temp\\abc.pdf"

Appending PDF Files

AppendPDF

Integer 0 = No
Integer 1 = Yes
Default = 0

This setting allows you to tell Click to Convert to append (join/combine) PDF files together to form compound PDF documents. To do this you need to make sure you set the PDFFilename value (described above) to an existing PDF file. If the PDFFilename value does not contain an existing PDF file then a new PDF file is created. If Click to Convert does find a PDF that exists with that name, it appends the new PDF file to the end of the existing PDF file.

Example (VBScript):

oApi.AppendPDF = 0	' Don't append PDFs - overwrite them

Controlling where HTML Files are Saved

HTMLOutputPath

String Value
Default = let the user choose through the interface

This setting controls where Click to Convert will place the HTML renditions that it creates. If you do not set the PDFFilename value and you are also creates PDFs then this value will be used as the folder to save the PDF files in. HTML renditions are always created in a sub-folder under this location. The default is to let the user choose through the Click to Convert user interface.

Example (VBScript):

oApi.HTMLOutputPath = "C:\\Temp\\"

Opening PDF or HTML Files Post-Conversion

OpenPDF
OpenHTML

Integer 0 = No
Integer 1 = Yes
Default = let the user choose through the interface

These settings let you choose if Click to Convert opens the PDF, HTML or both renditions after they are created. Setting the values to 1 will cause a rendition of that type to be opened, setting them to 0 will cause the type not to be opened. The default is to let the user choose through the Click to Convert user interface.

Example (VBScript):

oApi.OpenPDF = 1	' Open the PDF conversion
oApi.OpenHTML = 1	' Open the HTML conversion in the web browser

PDF Conversion Settings

PDF_BuildTOC

Integer 0 = No
Integer 1 = Yes (Default)

Should Click to Convert build bookmark for your PDF file? If the original file is a Microsoft Word document then headings from the Word document will be used.

PDF_WatermarkText

String
Default = No watermark (empty string)

If this property is set to a valid string then Click to Convert will "stamp" all pages of the PDF with this watermark text at a 45 degree angle.

PDF_FontEmbedding

Integer 0 = Embed TrueType fonts
Integer 1 = Embed TrueType font subsets (Default)
Integer 2 = Embed symbol fonts only

This setting control how fonts should be embedded in the PDF documents.

PDF_Security

Integer 0 = No (Default)
Integer 1 = Yes (128-bit security)

Should Click to Convert secure the PDF file it creates? When secured, you can use the following settings to control what type of security is applied:

PDF_OpenPassword

String
Default = No password (empty string)

If this property is set to a valid string then the created PDF will have password protection and a user will need to enter this password before they can open the PDF to read it.

PDF_ChangePassword

String
Default = No password (empty string)

If this property is set to a valid string then the created PDF will have password protection and a user will need to enter this password before they can modify or change the PDF.

PDF_PreventPrinting

Integer 0 = No (Default)
Integer 1 = Yes

Allow the user to print the created PDF?

PDF_PreventChanges

Integer 0 = No
Integer 1 = Yes (Default)

Allow the user to change or edit the created PDF?

PDF_PreventSelection

Integer 0 = No (Default)
Integer 1 = Yes

Allow the user to copy and paste and select content in the created PDF?

PDF_PreventFormChanges

Integer 0 = No (Default)
Integer 1 = Yes

Allow the user to use forms and add comments in the created PDF?

HTML Conversion Settings

HTML_Navigation

Integer 0 = No navigation
Integer 1 = Add back/next/etc navigation to pages (Default)

Should Click to Convert create navigation at the top of each HTML page for the user to navigate through the converted document?

HTML_BuildTOC

Integer 0 = None
Integer 1 = Framed navigation from headings (Default)
Integer 2 = Framed navigation with page numbers only

Should the HTML document have a framed table of contents for navigation and should it be built from the original documents headings or only contain page numbers?

HTML_PageCount

Integer 0 = Create a one page HTML document containing every page form the original
Integer 1 = Create one HTML page for each page from the original (Default)
Integer 2..15 = Put X pages from the original on each HTML page created

How many pages from the original document should Click to Convert put on each HTML page?

HTML_PrintableVersion

Integer 0 = No (Default)
Integer 1 = Yes

Should a separate single-page printer-friendly HTML page be created and a link included for users to print? Hint: If you have a large document then the printing process can be slow.

PDF_TemplateFilename

String = TemplateFilename
Default = Empty string

Allows you to specify the HTML template to wrap the HTML conversion in. Useful when you want the HTML conversions to fit into your website's look and feel.


Converting the Document

Once you've set any API settings you need to you're ready to ask Click to Convert to convert the document. Firstly you need to call the DocumentRenderer objects GetLock method to obtain a conversion lock so you have exclusive access to Click to Convert. After you have a successful lock, call the RenderDocument method with your API key and the document name to convert. After that you can safely release the lock using ReleaseLock.

If (oDocumentRenderer.GetLock = True) Then
  sPDFFile = oDocumentRenderer.RenderDocument(CStr(sDocumentPath), "CLICK TO CONVERT COM-OBJECT LICENSE KEY HERE")
  oDocumentRenderer.ReleaseLock
 End If

Waiting for the Conversion to Finish

If you're converting multiple documents with Click to Convert's API then you need a simple way of knowing when the conversion has completed. The following example demonstrates how to do this using Windows Management objects and VBScript. Simply call this after you have called the DocumentRenderer.RenderDocument method.


Sub LoopUntilComplete
  Dim wmi, results, wql, ConvertCount, PurepageCount

  set wmi = getobject("winmgmts:")

  ConvertCount = 1
  PurepageCount = 1
  Do While (ConvertCount > 0) Or (PurepageCount > 0)
    wql = "select * from win32 process where name='convert.exe'"
    set results = wmi.execquery(wql)
    ConvertCount = results.count

    wql = "select * from win32 process where name='purepage.exe'"
    set results = wmi.execquery(wql)
    PurepageCount = results.count
  Loop

End Sub
 

Download Samples

Basic Word to PDF samples- Download
Excel to PDF - Download
Suggest an example...

Support and Help

If you have any questions about the Click to Convert API or how to use it, please feel free to contact our technical support: tech@clicktoconvert.com or post your questions on our support site.

COM API Key

You need a COM API key to use the SDK - to get one simply e-mail us and we'll send you one.

Licensing and Pricing

Licensing is easy and falls in to two categories...

If you want to use Click to Convert on your server, you will need a server license (USD$849).

If you simply want to control Click to Convert on desktops then you only need to purchase a normal Click to Convert desktop license (USD$89).