ExportToHTML5, PDF2HTML5

The ExportToHTML5 and PDF2HTML5 methods are used to export a PDF document to HTML5 format.

 

This method needs special license.  Please, contact our Sales Department for more information

 

ActiveX

Syntax:

System.Boolean ExportToHTML5(System.String FileName, CDIntfEx.acHtml5ExportOptions HtmlOption, System.String imageNamingInfo, System.Int32 fromPage, System.Int32 toPage)

Parameters:

FileName

Full path of resulting HTML file.

HtmlOption

ActiveX Constants

Options

Value

Description

acHtml5ExportOptionIncludeHeader

1

Include HTML tags like <head> and <meta> in the output file

acHtml5ExportOptionEmbedImages

2

Embed raster images from the PDF file inside the output file instead of generating external files.

acHtml5ExportOptionUTF8Encoding

4

Use UTF8 encoding for the output file

acHtml5ExportOptionUTF16Encoding

8

Use UTF16 encoding for the output file

acHtml5ExportOptionDefault

7

Default settings (a combination of acHtml5ExportOptionIncludeHeader, acHtml5ExportOptionEmbedImages and acHtml5ExportOptionUTF8Encoding)

imageNamingInfo

It contains the image folder name, then the background folder name, and then the image prefix, all separated by "|".

fromPage

Starting page for export.

toPage

Ending page for export.

 

DLL

Syntax:

boolean PDF2HTML5(LPCWSTR InputFile, LPCSTR Password, LPCWSTR OutputFile, long Options, long OptimizeLevel)

Parameters:

InputFile

Full path of source PDF file.

Password

Owner or user password associated with the document.

OutputFile

Full path of resulting HTML file.

Options

DLL Constants

Options

Value

Description

HTML5OPTION_INCLUDEHEADER

1

Include HTML tags like <head> and <meta> in the output file

HTML5OPTION_EMBEDIMAGES

2

Embed raster images from the PDF file inside the output file instead of generating external files.

HTML5OPTION_UTF8ENCODING

4

Use UTF8 encoding for the output file

HTML5OPTION_UTF16ENCODING

8

Use UTF16 encoding for the output file

HTML5OPTION_DEFAULT

7

Default settings (a combination of HTML5OPTION_INCLUDEHEADER, HTML5OPTION_EMBEDIMAGES and HTML5OPTION_UTF8ENCODING)

OptimizeLevel

Optimization level to apply to PDF document.

 

Optimization Level

Value

No optimization

0

Line optimization (Recommended)

1

Paragraph optimization

2

Table optimization

3

 

Return Value

The return value is True if the document was converted, False otherwise.

 

Remarks

 It is recommended to use this method together with Optimize method.

The parameter imageNamingInfo consists of a string containing an image prefix, the images output folder, and then a base url, all separated by a "|". So basically if the user wants every image to be preceded by the prefix "img", the images output folder to be "c:\intepub\wwwroot\mywebsite\images" and the internal references to every image to have the base url "images", then the image naming info string should be set to "img|c:\intepub\wwwroot\mywebsite\images|images".

 

We usually export images in the pdf file as independent images and store them in the "images" folders, whereas we output anything else that can’t be handled by the built in html support as a background image for the page.

 

Member of CDIntfEx.Document.

 

Example

<Flags()>

Public Enum OPTIMIZE As Integer

    NO_OPTIMIZATION = 0

    LINE_OPTIMIZATION = 1

    PARAGRAPH_OPTIMIZATION = 2

    TABLE_OPTIMIZATION = 3

End Enum

 

Private Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"

    Const strActivationCode As String = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

    ' Declare a new cdintfex document if it does not exist in the form.

    Dim pdfDoc As New CDIntfEx.Document

 

    ' The SetLicenseKey method should be called after creating an object of type 

    ' CDIntfEx.Document to activate the advanced methods that require the object 

    ' activation code to work properly

    pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode)

 

    ' Open the document

    pdfDoc.Open("c:\temp\test.pdf")

 

    ' Optimize the document in Paragraph level

    pdfDoc.Optimize(OPTIMIZE.PARAGRAPH_OPTIMIZATION)

 

    ' Export to HTML5, but the license needs to have that option

    pdfDoc.ExportToHTML5("c:\temp\page.html", CDIntfEx.acHtml5ExportOptions.acHtml5ExportOptionDefault, "", 1, pdfDoc.PageCount)

End Sub

[Flags]

public enum OPTIMIZE

{

    NO_OPTIMIZATION = 0,

    LINE_OPTIMIZATION = 1,

    PARAGRAPH_OPTIMIZATION = 2,

    TABLE_OPTIMIZATION = 3

}

private void Sample ()

{

    // Constants for Activation codes

    const string strLicenseTo = "Amyuni PDF Converter Evaluation";

    const string strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";

 

    // Declare a new cdintfex document if it does not exist in the form.

    CDIntfEx.Document pdfDoc = new CDIntfEx.Document();

 

    // The SetLicenseKey method should be called after creating an object of type 

    // CDIntfEx.Document to activate the advanced methods that require the object 

    // activation code to work properly

    pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode);

 

    // Open the document

    pdfDoc.Open("c:\\temp\\test.pdf");

 

    // Optimize the document in Paragraph level

    pdfDoc.Optimize((int)OPTIMIZE.PARAGRAPH_OPTIMIZATION);

 

    // Export to HTML5, but the license needs to have that option

    pdfDoc.ExportToHTML5("c:\\temp\\page.html", CDIntfEx.acHtml5ExportOptions.acHtml5ExportOptionDefault,

        "", 1, pdfDoc.PageCount());

}

// PDF Converter Cpp.cpp : Defines the entry point for the console application.

// 

#include <Windows.h>

#include <string>

#include <iostream>

#include "CdIntf.h"

#pragma comment (lib, "CDIntf.lib")

 

using namespace std;

 

enum OPTIMIZE 

{

    NO_OPTIMIZATION = 0,

    LINE_OPTIMIZATION = 1,

    PARAGRAPH_OPTIMIZATION = 2,

    TABLE_OPTIMIZATION = 3

};

 

int main()

{

     // Constants for Activation codes

    #define strLicenseTo  (LPCSTR)"Amyuni PDF Converter Evaluation"

    #define strActivationCode (LPCSTR)"07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

    // The SetLicenseKey method should be called after creating an object of type 

    // CDIntfEx.Document to activate the advanced methods that require the object 

    // activation code to work properly

    SetLicenseKeyA(strLicenseTo, strActivationCode);

 

    // Export to HTML5, but the license needs to have that option

    PDF2HTML5((LPCSTR)"c:\\temp\\test.pdf", "", (LPCSTR)"c:\\temp\\page.html", HTML5OPTION_DEFAULT, OPTIMIZE::TABLE_OPTIMIZATION);

    return 0;

}

package Example;

 

import com.jacob.activeX.ActiveXComponent;

import com.jacob.com.Dispatch;

import com.jacob.com.Variant;

 

public class Sample {

    public enum OPTIMIZE 

    {

        NO_OPTIMIZATION (0),

        LINE_OPTIMIZATION (1),

        PARAGRAPH_OPTIMIZATION (2),

        TABLE_OPTIMIZATION (3);

        private int value;

        private OPTIMIZE(int value)

        {

            this.value = value;

        }

        public Object value(){

            return value;

        }

    }

 

    public enum HTML5OPTION 

    {

        Html5ExportOptionIncludeHeader (1),

        Html5ExportOptionEmbedImages (2),

        Html5ExportOptionUTF8Encoding (4),

        Html5ExportOptionUTF16Encoding(8),

        Html5ExportOptionDefault (7);

        private int value;

        private HTML5OPTION(int value)

        {

            this.value = value;

        }

        public Object value(){

            return value;

        }

    }

 

    public static void main(String[] args)

    {

        // Constants for Activation codes

        String strLicenseTo  = "Amyuni PDF Converter Evaluation";

        String strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";

 

        // Declare a new cdintfex document if it does not exist in the form.

        ActiveXComponent pdfDoc = new ActiveXComponent("CDIntfEx.Document.6.5"); 

 

        // The SetLicenseKey method should be called after creating an object of type 

        // CDIntfEx.Document to activate the advanced methods that require the object 

        // activation code to work properly

        Dispatch.call(pdfDoc, "SetLicenseKey", strLicenseTo, strActivationCode);

 

        // Open the document

        Dispatch.call(pdfDoc, "Open", "c:\\temp\\test.pdf");

 

        // Optimize the document in Paragraph level

        Dispatch.call(pdfDoc, "Optimize",OPTIMIZE.PARAGRAPH_OPTIMIZATION.value);

 

        // Number of pages

        Variant Pages = Dispatch.call(pdfDoc, "PageCount");

 

        // Export to HTML5, but the license needs to have that option

        Dispatch.call(pdfDoc, "ExportToHTML5", "c:\\temp\\page.html", HTML5OPTION.Html5ExportOptionDefault.value, "", 1, Pages);

 

        // Destroy pdfDoc object

        pdfDoc = null;

    }

}

$OPTIMIZE = @{

    NO_OPTIMIZATION = 0

    LINE_OPTIMIZATION = 1

    PARAGRAPH_OPTIMIZATION = 2

    TABLE_OPTIMIZATION = 3

}

 

$HTML5OPTION = @{

    Html5ExportOptionIncludeHeader = 1

    Html5ExportOptionEmbedImages = 2

    Html5ExportOptionUTF8Encoding = 4

    Html5ExportOptionUTF16Encoding = 8

    Html5ExportOptionDefault = 7

}

 

# Constants for Activation codes

$strLicenseTo  =  "Amyuni PDF Converter Evaluation"

$strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

#Declare a new cdintfex document if it does not exist in the form.

$pdfDoc = New-Object -ComObject CDIntfEx.Document.6.5

 

#The SetLicenseKey method should be called after creating an object of type 

#CDIntfEx.Document to activate the advanced methods that require the object 

#activation code to work properly

[System.__ComObject].InvokeMember('SetLicenseKey', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc, @($strLicenseTo, $strActivationCode))

 

#Open the document

[System.__ComObject].InvokeMember('Open', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,"c:\temp\test.pdf") 

 

#Optimize the document in Paragraph level

[System.__ComObject].InvokeMember('Optimize', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc, $OPTIMIZE::PARAGRAPH_OPTIMIZATION)

 

#Number Pages

$PAGES = [System.__ComObject].InvokeMember('PageCount', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc, $null)

 

#Export to HTML5, but the license needs to have that option

[System.__ComObject].InvokeMember('ExportToHTML5', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,

    @("c:\temp\page.html", $HTM5LOPTION::Html5ExportOptionDefault, "", 1, $PAGES))

 

#Destroy pdfDoc object

$pdfDoc = $null    

Const NO_OPTIMIZATION = 0

Const LINE_OPTIMIZATION = 1

Const PARAGRAPH_OPTIMIZATION = 2

Const TABLE_OPTIMIZATION = 3

 

Const acHtml5ExportOptionIncludeHeader = 1

Const acHtml5ExportOptionEmbedImages = 2

Const acHtml5ExportOptionUTF8Encoding = 4

Const acHtml5ExportOptionDefault = 7

Const acHtml5ExportOptionUTF16Encoding = 8

 

' Constants for Activation codes

Const strLicenseTo = "Amyuni PDF Converter Evaluation"

Const strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

' Declare a new cdintfex document if it does not exist in the form.

Dim pdfDoc 

Set pdfDoc = CreateObject("CDIntfEx.Document.6.5")

 

' The SetLicenseKey method should be called after creating an object of type 

' CDIntfEx.Document to activate the advanced methods that require the object 

' activation code to work properly

pdfDoc.SetLicenseKey strLicenseTo, strActivationCode

 

' Open the document

pdfDoc.Open "c:\temp\test.pdf"

 

' Optimize the document in Paragraph level

pdfDoc.Optimize PARAGRAPH_OPTIMIZATION

 

' Export to HTML5, but the license needs to have that option

pdfDoc.ExportToHTML5 "c:\temp\page.html", acHtml5ExportOptionDefault, "", 1, pdfDoc.PageCount

 

' Destroy pdfDoc object

Set pdfDoc = Nothing