Post on 21-Oct-2020
transcript
Software License Agreement HTML to Image Converter
For Win32/64
Version 13
2021
ALL RIGHTS RESERVED BY
SUB SYSTEMS, INC.
15450 FM 1325, #1215
Austin, TX 78728
512-733-2525
Software License Agreement
The Software is protected by copyright laws and international copyright treaties, as well asother intellectual property laws and treaties. The Software is licensed, not sold. ThisLICENSE AGREEMENT grants you the following rights:
A. This product is licensed per developer basis only. Each developer working with thispackage needs to purchase a separate license.
B. The purchaser has the right to modify and link the DLL functions into their application.Such an application is free of distribution royalties with these conditions: the targetapplication is not a stand-alone HTML to Image Converter; the target application uses thisproduct for one operating system platform only; and the source code (or part) of the editoris not distributed in any form.
C. The DESKTOP LICENSE allows for the desktop application development. Your desktopapplication using this product can be distributed royalty-free. Each desktop license allowsone developer to use this product on up to two development computers. A developer mustpurchase additional licenses to use the product on more than two development computers.
D. The SERVER LICENSE allows for the server application development. The serverlicenses must be purchased separately when using this product in a server application.Additionally, the product is licensed per developer basis. Only an UNLIMITED SERVERLICENSE allows for royalty-free distribution of your server applications using this product.
E. ENTERPRISE LICENSE: The large corporations with revenue more than $50 million andlarge government entities must purchase an Enterprise License. An Enterprise license isalso applicable if any target customer of your product using the Software have revenuemore than $500 million. Please contact us at info@subsystems.com for a quote for anEnterprise License.
F. Your license rights under this LICENSE AGREEMENT are non-exclusive. All rights notexpressly granted herein are reserved by Licensor.
G. You may not sell, transfer or convey the software license to any third party withoutLicensor's prior express written consent.
Page 1
H. The license remains valid for 12 months after the issue date. The subsequent yearlicense renewal cost is 40 percent of the license acquisition cost. The license includesstandard technical support, patches and new releases.
This software is designed keeping the safety and the reliability concerns as the mainconsiderations. Every effort has been made to make the product reliable and error free.However, Sub Systems, Inc. makes no warranties against any damage, direct or indirect,resulting from the use of the software or the manual and can not be held responsible for thesame. The product is provided 'as is' without warranty of any kind, either expressed orimplied, including but not limited to the implied warranties of suitability for a particularpurpose. The buyer assumes the entire risk of any damage caused by this software. In noevent shall Sub Systems, Inc. be liable for damage of any kind, loss of data, loss of profits,interruption of business or other financial losses arising directly or indirectly from the use ofthis product. Any liability of Sub Systems will be exclusively limited to refund of purchaseprice.
Sub Systems, Inc. offers a 30 day money back guarantee with the product. Must call for anRMA number before returning the product.
Page 2
Getting Started This chapter describes the contents of the software diskettes and provides a step by step
process of incorporating HTML to Image Converter into your application.
In This ChapterFilesLicense KeyIncorporating the DLL into Your ApplicationSample Conversion Code
Page 3
Files
The package contains the DLL and header files. The package also includes a set of files toconstruct a demo program. The demo program shows by example the process of linkingthe DLL to your program.
DLL Demo Files:
The following demo files are included in the c_demo.zip file.
DEMO.C Source code for the demo program
DEMO.H Include file for the demo program
DEMO.RC Resource source file for the demo program
DEMO.DEF Definition file for linking the demo program
DEMO.EXE Executable demo program
DEMO_DLG.H Dialog Identifiers for the demo program
DEMO_DLG.DLG Dialog templates for the demo program
DEMO_DLG.RES Compiled dialogs for the demo program
HIC.H The include file to include into a C/C++ application module thatcalls the HIC routine. It contains the constant definitions and theprototypes for the API functions.
His32.DLL The DLL file
His32.LIB Import library for the His32 DLL
ter28.dll Used internally by the His32.DLL
hts23.dll Used internally by the His32.DLL
HICC.DLL Wrapper DLL to used with an ASP page
Visual Basic Interface and Demo Files:
HIC.BAS Function declaration file.
DMO_VB.FRM Demo form file.
DMO_VB.BAS Demo variable declaration file.
DMO_VB.VPB Demo project file.
Page 4
License Key
Your License Key and License number are e-mailed to you after your order is processed.You would set the license information using the HisSetLicenseInfo static function. Thisshould be preferably done before creating the converter session to avoid pop-up nagscreens.
int HisSetLicnseInfo(LPBYTE LicenseKey, LPBYTE LicenseNumber, LPBYTECompanyName);
LicenseKey: Your license key is available in the product delivery email sent to youupon the purchase of the product. It consists of a string in the form of"xxxxx-yyyyy-zzzzz".
LicenseNumber: Your license number is also available in the product delivery email. Thelicense number string starts with a "srab" or "smo" prefix.
CompanyName: Your company name as specified in your order.
Return Value: This method returns 0 when successful. A non-zero return value indicatesan error condition. Here are the possible return values:
0 License application successful.
1 Invalid License Key.
2 Invalid License Number.
3 Ran out of available licenses. Please consider purchasing additional licenses.
Example:
result=HisSetLicenseInfo("xxxxx-yyyyy-zzzzz","srabnnnnn-n","Your Company Name")
Replace the 'xxxxx-yyyyy-zzzzz' by your license key, replace "srabnnnnn-n" with yourlicense number, and "Your Company Name" with your company name as specified in yourorder.
Note: HisSetLicenseInfo method should be called only once at the beginning of yourapplication. Calling this method for each conversion would degrade the conversionperformance.
Also, you can use the HisGetLicenseStatus function at anytime to retrieve the licensestatus.
Page 5
Incorporating the DLL into Your Application A C/C++ application should include the HIC.h file into the application module that needs to
call the His32 dll. It also should include the His32.LIB as the linker library. Please refer tothe demo application for an example.
A Visual Basic application needs to include the HIC.BAS file in the project. Please refer tothe DMO_VB project for an example.
Please also make sure that the His32.dll, hts23.dll and ter28.dll files are copied to adirectory available at run-time.
.
Page 6
Sample Conversion Code
First you would create a new conversion session:
dim id as long
Set the product license key and create a session id:
result=HisSetLicenseInfo("xxxxx-yyyyy-zzzzz",
"srabnnnnn-n","Your Company Name")
id = HisNewSession()
You would use the session id to call other conversion functions.
Here are sample code examples to convert HTML to Image format.
1. Convert an HTML file to an image file.
PageCount = HisLoadFile(id, "test.htm")
If (PageCount > 0) Then
PageNo = 1 'Get image for the first page of the document
result = HisImageToFile(id, "test.jpg", PageNo)
End If
2. Convert an HtmlString to a string containing image data:
Dim hMem as long
Dim PageCount as long
Dim ImageType as long
Dim OutString as string
Dim HtmlString as string
'load the document and return the number of pages
Page 7
'in the document
PageCount = HisLoadBuffer(id, HtmlString, Len(HtmlString))
If (PageCount > 0) Then
' get the output image type from a file name
ImageType = HisGetImageType(id, "test.jpg")
' set the output image type
call HisSetNumProp(id, HIPROP_IMAGE_TYPE, ImageType)
' return the page image in global memory handle
hMem = HisImageToBuffer(id, OutSize, PageNo)
If (hMem > 0) Then
' allocate space for the output string
OutString = Space$(OutSize + 1)
Call HisHandleToStr(OutString, OutSize, hMem)
End If
End if
After the conversion process, end the session by calling the HisEndSession function. Thisfrees up the memory used by the session.
HisEndSession(id)
Note: HTML to Image converter makes use of Windows' GdiPlus API. GdiPlus mustbe installed on a system to use HTML to Image Converter.
Page 8
Application Interface functions These API functions allow you to convert from HTML to Image format. Your application
must include the HIC.H file (c/c++), or HIC.BAS (VB) files. These files declare thesefunctions.
The following is a description of the HIC API functions in an alphabetic order:
In This ChapterHisEndSessionHisGetImageTypeHisGetLastMessageHisGetLicnseStatusHisGetPageImageHisLoadBufferHisImageToBufferHisImageToFileHisHandleToStrHisLoadFileHisNewSessionHisResetLastMessageHisSetFlagsHisSetBoolPropHisSetHdrFtrTextHisSetNumPropHisSetPageMarginHisSetPaperOrientHisSetPaperSizeHisSetTextProp
Page 9
HisEndSession
End a conversion session.
BOOL HisEndSession(id)
DWORD id; Session id.
Description: This function is called at the end of the conversion process to free up thesession related resources.
Return Value: The function returns TRUE when successful.
Page 10
HisGetImageType
Get the image type constant for to the requested file name.
int HisGetImageType(id, ImageFile)
DWORD id; // Session id
LPBYTE ImageFile; // image file name
Return value: This method returns Image-type constant corresponding to theextension of the given file.
Examples:
' get the image type for a file name
ImageType = HisGetImageType(id, "test.jpg")
' set the output image type
HisSetNumProp(id, HIPROP_IMAGE_TYPE, ImageType)
Page 11
HisGetLastMessage
Get the last message.
int HisGetLastMessage(id, HICMessage, DebugMessage);
DWORD id; Session id.
LPBYTE HICMessage; Returns the default user message text in English
LPBYTE DebugMsg; Returns any debug message associated with the lastmessage. The debug message need not be displayed tothe user.
Return Value: This function returns the last message generated by the editor. This value isvalid only if saving of the messages is enabled by setting the HPFLAG_RETURN_MSG_IDflag. This flag is set using the HisSetFlags function.
Page 12
HisGetLicnseStatus
Get the license status.
int HisGetLicnseStatus()
Return Value:
0 License application successful.
1 Invalid License Key.
2 Invalid License Number.
3 Ran out of available licenses. Please consider purchasing additional licenses.
4 The evaluation period has expired.
You can use the HisGetLicenseStatus function at anytime to retrieve the license status.
Page 13
HisGetPageImage
Return the image for the requested page number for the currently loadedHTML document.
HANDLE HisGetPageImage(PageNo)
DWORD id; Session id.
int PageNo; // Page number. This value should be between 1 andthe PageCount for the currently loaded HTMLdocument.
Return value: This function returns a metafile handle for a metafile image, or a bitmaphandle for other type of images. A null value indicates an error condition.
This function is useful if you wish to retrieve the image handle for further processingbefore saving to a disk file.
Examples:
PageCount=HisLoadFile(id,"test.htm");
HisSetNumProp(id, HIPROP_IMAGE_TYPE, PICT_JPG)
handle=HisGetPageImage(id, 1);
Page 14
HisLoadBuffer
Load html string and determine the number of pages in the html document..
int HisLoadBuffer(id, InString, InStringLen)
DWORD id; Session id.
LPBYTE InString; Input string containing HTML document.
int InStringLen; length of the input document string.
Return value: This function returns the number of pages in the html document. A value ofzero indicates an error condition.
Examples:
Dim HtmlString as string
PageCount = HisLoadBuffer(id,HtmlString, Len(HtmlString))
Page 15
HisImageToBuffer
Save the current image in a memory handle.
HGLOBAL HisImageToFile(id, OutFile, PageNo)
DWORD id; // Session id
LPLONG OutSize; // (output) size of the global memory block returned bythis function.
int PageNo; // Page number. This value should be between 1 andthe PageCount for the currently loaded HTMLdocument.
Return value: This method returns TRUE when successful.
Examples:
PageCount = HisLoadBuffer(id, HtmlString,Len(HtmlString))
If (PageCount > 0) Then
' set the output image type to Jpeg
call HisSetNumProp(id, HIPROP_IMAGE_TYPE, PICT_JPG)
' return the page image in global memory handle
hMem = HisImageToBuffer(id, OutSize, PageNo)
If (hMem > 0) Then
' allocate space for the output string
OutString = Space$(OutSize + 1)
Call HisHandleToStr(OutString, OutSize, hMem)
End If
End if
Page 16
HisImageToFile
Save the current image to the requested file name.
BOOL HisImageToFile(id, OutFile, PageNo)
DWORD id; // Session id
LPBYTE OutFile; // Output image file name
int PageNo; // Page number. This value should be between 1 andthe PageCount for the currently loaded HTMLdocument.
Return value: This method returns TRUE when successful.
Examples:
PageCount = HisLoadFile(id, "test.htm")
If (PageCount > 0) Then
PageNo = 1 'Get image for the first page of
'the document
result = HisImageToFile(id, "test.jpg", PageNo)
End If
Page 17
HisHandleToStr
Convert a global memory handle to a Visual Basic string.
BOOL HisHandleToStr(string, length, hMem)
LPBYTE string; pointer to a visual basic string
long length length of the string
HGLOBAL hMem; Global memory handle
Description: This function can be used to copy the contents of a global memory handle toa given visual basic string. The calling routine must expand the string to appropriate lengthbefore calling this function.
Example:
string=space(length)
HandleToStr(string,length,hMem)
The input global memory handle is freed up after copying its contents to the string.
Return Value: This function returns TRUE if successful.
Page 18
HisLoadFile
Load html file and determine the number of pages in the html document..
int HisLoadFile(id, InString, InStringLen)
DWORD id; Session id.
LPBYTE InFile; Input file containing HTML document.
int InStringLen; length of the input document string.
Return value: This function returns the number of pages in the html document. A value ofzero indicates an error condition.
Examples:
Dim HtmlString as string
PageCount = HisLoadFile(id,"test.htm")
Page 19
HisNewSession Create a new conversion session.
DWORD HisNewSession()
Description: This function needs to be called before calling any other conversion function.This function creates a new conversion session.
The HisEndSession must be called at the end to free up the session resources. All otherconversion functions are called between the calls to the HisNewSession andHisEndSession functions.
Return Value: The function returns a non-zero session-id when successful. A zero valueindicates a fail return.
Page 20
HisResetLastMessage
Reset the last editor message.
BOOL HisResetLastMessage(id)
DWORD id; Session id.
Description: This function can be called before calling any other function to reset the lasterror message.
Return Value: The function returns TRUE when successful.
See AlsoHisGetLastMessageHisSetFlags
Page 21
HisSetFlags
Set certain flags or retrieve the values of the flags.
DWORD HisSetFlags(id, set, flags)
DWORD id; Session id.
BOOL set; TRUE to set the given flags, FALSE to reset the givenflags
DWORD flags; Flags (bits) to set or reset. Currently, the following flagvalues are available:
HPFLAG_RETURN_MSG_ID Do not display the error messages. Save theerror code to be later retrieved using theHisGetLastMessage function.
Return value: This function returns the new value of all the flags. Call this function with the'flags' parameter set to zero to retrieve flag values without modifying it.
Page 22
HisSetBoolProp
Set a boolean property for the conversion.
BOOL HisSetBoolProp(id, prop, val)
DWORD id; Session id.
int prop; One of the following property type to set:
HIPROP_USE_WEB_BROWSER
Use this property to instruct the converter to usethe Internet Explorer control to render the htmlpage to convert to image. This option results inimages similar to as displayed by IE.
When this property is not set, the converter uses abuilt-in html renderer which might be suitable forhtml files that use simpler html formatting.
This property is set to TRUE by default.
HIPROP_SHRINK_TO_FIT Set to TRUE to eliminate the ending white spacesto shrink the image height. This property is onlyeffective for one page html documents.
LPBYTE val; The text value of the selected property.
Return value: This function returns TRUE when successful.
Page 23
HisSetHdrFtrText
Set header or footer text.
BOOL HisSetHdrFtrText(id, HdrFtrType, TextType, text)
DWORD id; Session id.
int HdrFtrType; Select header or footer to set:
HF_FIRST_HDR Header text to print on the first page.
HF_FIRST_FTR Footer text to print on the first page..
HF_HDR Regular header for all pages. When the firstpage header is also set, then the regularheader text is printed on all pages except thefirst page.
HF_FTR Regular footer for all pages. When the firstpage footer is also set, then the regular footertext is printed on all pages except the firstpage.
int TextType; Text type:
HFTYPE_TEXT Plain text.
HFTYPE_RTF RTF text.
HFTYPE_HTML Html text.
LPBYTE text; Header or footer text. The header/footer text must bespecified as plain text or RTF text depending upon thevalue passed for the 'TextType' parameter.
Comment: The function should be called before calling the conversion functions to set theheader or footer text. You can call this function multiple times to set various types ofheader or footer.
Return value: This function returns TRUE when successful.
Examples:
HisSetHdrFtrText(id, HF_FIRST_HDR, HFTYPE_TEXT,
"This is first page header.");
HisSetHdrFtrText(id, HF_FIRST_FTR, HFTYPE_TEXT,
"This is first page footer.");
Page 24
HisSetHdrFtrText(id,HF_HDR, HFTYPE_TEXT,
"This is regular page header.");
HisSetHdrFtrText(id,HF_FTR, HFTYPE_RTF,"{\\rtf1 \\qc
Page: {\\field{\\fldinst PAGE}{\\fldrslt 12}} of
{\\field{\\fldinst NUMPAGES}{\\fldrslt 12}}
\\par}" ); // rtf example to insert page: n of m string
Page 25
HisSetNumProp
Set a numeric property for the conversion.
BOOL HisSetNumProp(id, prop, val)
DWORD id; Session id.
int prop; One of the following property type to set:
HIPROP_IMAGE_RES Use this property to specify the resolution of an image.The default value is 96 dpi.
HIPROP_META_RES Use this property to specify the resolution of a metafileimage. The default value is 300
HIPROP_SIZE_PERCENT Use this property to change the size of the outputimage. The default value for this property is 100. Youcan specify a value small than 100 to obtain a smallerimage. Similarly you can specify a value greater than100 to obtain a larger image.
HIPROP_IMAGE_TYPE Use this property to request a particular type of image(default is Bitmap file):
PICT_BMP Bitmap image
PICT_EMF Enhanced metafile
PICT_TIF Tiff image
PICT_JPG Jpeg image
PICT_PNG PNG image
PICT_GIF GIF image
int val; The numeric value of the selected property.
Return value: This function returns TRUE when successful.
Page 26
HisSetPageMargin
Set the page margins for PDF output.
BOOL HisSetPageMargin(id, left, right, top, bottom)
DWORD id; Session id.
int left; Left margin in twip units (1440 twips = 1 inch)
int right; Right margin in twip units
int top; Top margin in twip units
int bottom Bottom margin in twip units
Return Value: The function returns TRUE when successful.
Comment: This function is used to override the default page margins when converting anHTML document to the PDF format. This function should be called before calling theHisConvertFile or HisConvertBuffer if you wish override the page margin values.
Page 27
HisSetPaperOrient
Set the page orientation for PDF output.
BOOL HisSetPaperOrient(id, orient)
DWORD id; Session id.
int orient; Orientation: DMORIENT_PORTRAIT orDMORIENT_LANDSCAPE
Return Value: The function returns TRUE when successful.
Comment: This function is used to override the default portrait orientation when convertingan HTML document to the PDF format. This function should be called before calling theHisConvertFile or HisConvertBuffer if you wish override the paper orientation.
Page 28
HisSetPaperSize
Set the page size for PDF output.
BOOL HisSetPaperSize(id, PageSize, PageWidth, PageHeight)
DWORD id; Session id.
int PageSize; Use one of the following Windows SDK definedconstants:
Constant Value
DMPAPER_LETTER 1
DMPAPER_LEGAL 5
DMPAPER_LEDGER 4
DMPAPER_TABLOID 3
DMPAPER_STATEMENT 6
DMPAPER_EXECUTIVE 7
DMPAPER_A3 8
DMPAPER_A4 9
DMPAPER_A5 11
DMPAPER_B4 12
DMPAPER_B5 13
If you need to use a paper size not listed above, pleaseset the PageSize argument to zero and specify thepage width and height using the next two arguments.
int PageWidth; The page width in twips units (1440 twips = 1 inch). Thisargument is ignored if the PageSize is set to one of thedefined page sizes listed above.
int PageHeight; The page height in twips units (1440 twips = 1 inch). Thisargument is ignored if the PageSize is set to one of thedefined page sizes listed above
Return Value: The function returns TRUE when successful.
Comment: This function is used to override the default letter size paper when converting anHTML document to the PDF format. This function should be called before calling theHisConvertFile or HisConvertBuffer if you wish override the paper size.
Page 29
HisSetTextProp
Set a text property for the conversion.
BOOL HisSetTextProp(id, prop, val)
DWORD id; Session id.
int prop; One of the following property type to set:
HIPROP_DOWNLOAD_DIR Folder to store temporary html pictures filesduring conversion.
LPBYTE val; The text value of the selected property.
Return value: This function returns TRUE when successful.
Page 30
ASP Interface This chapter describes the usage of the HTML to Image Converter within an ASP page.
The product includes an additional wrapper DLL called HICC.DLL which is used to accessthe converter within an ASP page. Please follow the following steps:
Copy ter28.dll, hts23.dll, and His32.dll and HICC.dll to the Windows system directory, orany other directory available at the run-time. Now register HICC.dll using the regsvr32system utility. The other dlls do not need registration. Now you are ready to use thisproduct within an ASP page.
Here is an example ASP page to show a conversion of Html string into an image:
if len(sHTML) > 0 then
PageCount = obj.LoadBuffer(CStr(sHTML))
result =obj.ImageToFile("c:\inetpub\wwwroot\dmohic\test.jpg",1)
End If
if PageCount = 0 then
ErrorMessage = obj.GetLastMessage
response.write(ErrorMessage)
end if
Set obj = Nothing
%>
----------------------------------------------------------------
When the above asp file is loaded, IE displays the generated image.
-------------------------------------------------------------------
The method names used by the HICC.dll are the same as the functions mentioned in theApplication Interface functions. However the 'His' prefix is not used by the HICC method
Page 32
names. For example, the HisConvertFile function is named as ConvertFile within theHICC.dll file.
Also, the constants values are prefixed with an 'VAL_' prefix. For example, the constantHIPROP_IMAGE_TYPE becomes VAL_HIPROP_IMAGE_TYPE.
Page 33
Software License AgreementGetting StartedFilesLicense KeyIncorporating the DLL into Your ApplicationSample Conversion Code
Application Interface functionsHisEndSessionHisGetImageTypeHisGetLastMessageHisGetLicnseStatusHisGetPageImageHisLoadBufferHisImageToBufferHisImageToFileHisHandleToStrHisLoadFileHisNewSessionHisResetLastMessageHisSetFlagsHisSetBoolPropHisSetHdrFtrTextHisSetNumPropHisSetPageMarginHisSetPaperOrientHisSetPaperSizeHisSetTextProp
ASP Interface