The ExportToHTMLEx method exports PDF document to HTML format, and adds some additional options.
Sub ExportToHTMLEx(FileName As String, Options As ACPDFCREACTIVEX.acHtmlExportOptions, imageNamingInfo As String, downsamplingResolution As Integer)
void ExportToHTMLEx(string FileName, ACPDFCREACTIVEX.acHtmlExportOptions options, string imageNamingInfo, int downsamplingResolution)
HRESULT ExportToHTMLEx(BSTR FileName, enum acHtmlExportOptions Options, BSTR imageNamingInfo, long downsamplingResolution)
FileName
Name of the file with .html extension to export to
Options
Option |
Value |
Description |
---|---|---|
acHtmlExportOptionLayers |
1 |
Multiple pages in a single HTML file using layers |
acHtmlExportOptionSinglePage |
2 |
All pages in a single HTML file. |
acHtmlExportOptionMultiplePages |
3 |
Each page in a separate HTML file. |
acHtmlExportOptionVectorGraphics |
4 |
Accurately convert vector graphics. |
acHtmlExportOptionForceImagesToJpg |
8 |
Force all images to Jpg. |
acHtmlExportOptionForceImagesToPng |
16 |
Force all images to Png. |
imageNamingInfo
It contains the image folder name, then the background folder name, and then the image prefix, all separated by "|" (refer to Remarks).
downsamplingResolution
It specifies a resolution to which all images will be down-sampled. When set to 0, no down-sampling is performed.
By default, ExportToHTML Method only uses html' s very limited support for vector graphics and this renders disappointing conversions for documents which use a lot of vector graphics. In order to accurately convert pages full of graphics, it' s very important to add the acHtmlExportOptionVectorGraphics flag. For example, to export a document accurately to a single html page the options should be set to:
Options = acHtmlExportOptionSinglePage | acHtmlExportOptionVectorGraphics
Failing to combine with the second option results in a weak conversion.
The ExportToHTMLEx Method also allows the user to force all images to either jpg or png:
acHtmlExportOptionForceImagesToJpg.
acHtmlExportOptionForceImagesToPng.
The parameter imageNamingInfo consists of a string containing the image folder name, then the background folder name and then the image prefix, all separated by a vertical bar(|). So basically if the user wants the image directory to be called "images", the background folder named "bg" and wants every image to be preceded by the prefix "img" then the image naming info string should be set to "images|bg|img"
If the user wants all images to be placed in the same folder, then he/she must provide the same name for both the images and backgrounds folder.
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.
This method uses the PageSequence or PageSecuenceStr attributes from Document Object to determine which pages are going to be exported.
<Flags>
Public Enum OPTIMIZATION_LEVEL
NO_OPTIMIZATION = 0
LINE_OPTIMIZATION = 1
PARAGRAPH_OPTIMIZATION = 2
TABLE_OPTIMIZATION = 3
End Enum
Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Creator Evaluation"
Const strActivationCode As String = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"
' Initializing PDFCreativeX Object
Dim pdf As ACPDFCREACTIVEX.PDFCreactiveX = New ACPDFCREACTIVEX.PDFCreactiveX()
' Set license key
pdf.SetLicenseKey(strLicenseTo, strActivationCode)
' Open an existent PDF file
Dim fileName As String = "c:\temp\PDFdocument.pdf"
Dim password As String = ""
pdf.Open(fileName, password)
' Recommended optimization to export the file
Dim level As Integer = OPTIMIZATION_LEVEL.PARAGRAPH_OPTIMIZATION
pdf.OptimizeDocument(level)
' Exporting
Dim outFileName As String = "c:\temp\file.html"
Dim options As ACPDFCREACTIVEX.acHtmlExportOptions = ACPDFCREACTIVEX.acHtmlExportOptions.acHtmlExportOptionSinglePage Or
ACPDFCREACTIVEX.acHtmlExportOptions.acHtmlExportOptionForceImagesToJpg Or
ACPDFCREACTIVEX.acHtmlExportOptions.acHtmlExportOptionVectorGraphics
Dim imageNamingInfo As String = "images|backgrounds|pre"
Dim downsamplingResolution As Integer = 72
pdf.ExportToHTMLEx(outFileName, options, imageNamingInfo, downsamplingResolution)
End Sub
[Flags]
public enum OPTIMIZATION_LEVEL
{
NO_OPTIMIZATION = 0,
LINE_OPTIMIZATION = 1,
PARAGRAPH_OPTIMIZATION = 2,
TABLE_OPTIMIZATION = 3
}
static void Sample()
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Creator Evaluation";
const string strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC";
// Initializing PDFCreativeX Object
ACPDFCREACTIVEX.PDFCreactiveX pdf = new ACPDFCREACTIVEX.PDFCreactiveX();
// Set license key
pdf.SetLicenseKey(strLicenseTo, strActivationCode);
// Open an existent PDF file
string fileName = @"c:\temp\PDFdocument.pdf";
string password = "";
pdf.Open(fileName, password);
// Recommended optimization to export the file
int level = (int)OPTIMIZATION_LEVEL.PARAGRAPH_OPTIMIZATION;
pdf.OptimizeDocument(level);
// Exporting
string outFileName = @"c:\temp\file.html";
ACPDFCREACTIVEX.acHtmlExportOptions options = ACPDFCREACTIVEX.acHtmlExportOptions.acHtmlExportOptionSinglePage |
ACPDFCREACTIVEX.acHtmlExportOptions.acHtmlExportOptionForceImagesToJpg |
ACPDFCREACTIVEX.acHtmlExportOptions.acHtmlExportOptionVectorGraphics;
string imageNamingInfo = "images|backgrounds|pre";
int downsamplingResolution = 72;
pdf.ExportToHTMLEx(outFileName, options, imageNamingInfo, downsamplingResolution);
}
#include <iostream>
#import "c:\users\amyuni\pdfcreactivex.dll" no_namespace
using namespace std;
enum OPTIMIZATION_LEVEL
{
NO_OPTIMIZATION = 0,
LINE_OPTIMIZATION = 1,
PARAGRAPH_OPTIMIZATION = 2,
TABLE_OPTIMIZATION = 3
};
int main()
{
// Constants for Activation codes
bstr_t strLicenseTo = "Amyuni PDF Creator Evaluation";
bstr_t strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC";
// Initialize the COM subsystem
CoInitialize(0);
// IPDFCreactiveXPtr is a smart pointer type defined in pdfcreactivex.tlh,
// the type library header file generated by the #import instruction above
IPDFCreactiveXPtr pdf;
// Create the PDFCreactiveX instance
pdf.CreateInstance(__uuidof(PDFCreactiveX));
// set license key
pdf->SetLicenseKey(_bstr_t(strLicenseTo), _bstr_t(strActivationCode));
// Open an existent PDF file
_bstr_t fileName = "c:\\temp\\PDFdocument.pdf";
_bstr_t password = "";
pdf->Open(fileName, password);
// Recommended optimization to export the file
int level = (int)PARAGRAPH_OPTIMIZATION;
pdf->OptimizeDocument(level);
// Exporting
bstr_t outFileName = "c:\\temp\\file.html";
acHtmlExportOptions options = (acHtmlExportOptions)(acHtmlExportOptionSinglePage |
acHtmlExportOptionForceImagesToJpg |
acHtmlExportOptionVectorGraphics);
bstr_t imageNamingInfo = "images|backgrounds|pre";
int downsamplingResolution = 72;
pdf->ExportToHTMLEx(outFileName, options, imageNamingInfo, downsamplingResolution);
// destroy objects
pdf = NULL;
return 0;
}
' acHtmlExportOptions
Const acHtmlExportOptionForceImagesToJpg = 8
Const acHtmlExportOptionForceImagesToPng = 16
Const acHtmlExportOptionLayers = 1
Const acHtmlExportOptionMultiplePages = 3
Const acHtmlExportOptionSinglePage = 2
Const acHtmlExportOptionVectorGraphics = 4
' Optimization level
Const NO_OPTIMIZATION = 0
Const LINE_OPTIMIZATION = 1
Const PARAGRAPH_OPTIMIZATION = 2
Const TABLE_OPTIMIZATION = 3
' Constants for Activation codes
Const strLicenseTo = "Amyuni PDF Creator Evaluation"
Const strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"
' Initializing PDFCreativeX Object
Dim pdf
Set pdf = CreateObject("PDFCreactiveX.PDFCreactiveX.6.5")
' Set license key
pdf.SetLicenseKey strLicenseTo, strActivationCode
' Open an existent PDF file
Dim fileName
fileName = "c:\temp\PDFdocument.pdf"
Dim password
password = ""
pdf.Open fileName, password
' Table optimization is recommended to export the file to HTML
Dim level
level = PARAGRAPH_OPTIMIZATION
pdf.OptimizeDocument level
' Exporting
Dim outFileName
outFileName = "c:\temp\file.xls"
Dim options
options = acHtmlExportOptionSinglePage Or acHtmlExportOptionForceImagesToJpg Or acHtmlExportOptionVectorGraphics
Dim imageNamingInfo
imageNamingInfo = "images|backgrounds|pre"
Dim downsamplingResolution
downsamplingResolution = 72
pdf.ExportToHTMLEx outFileName, options, imageNamingInfo, downsamplingResolution
' destroy objects
Set pdf = Nothing