Along with the DLL files, two projects are included as examples, one for calling the DLL from Visual C++ and other from Delphi.
The projects are for Visual C++ 6 and Delphi 3 to give programmers the options to open them with older versions of both compilers, but they can easily been opened by any newer version.
These projects are not complex, but are intended for programmers with at least minimum experience.
All the same options that HTMLPrints reads from the .ini file can be set using the DLL. If any options is not specified, the same default values than HTMLPrint used when no .ini file is available will be applied.
Also, if the wait option is set to 1, the DLL will wait for HTMLPrint run termination after calling it, giving back an error number. If wait is 0, far less feedback (less errors are trapped) will be provided.
Note: Calling a DLL from a service can be difficult. We don't grant that these DLLs will work when called from Windows services.
Functions:
|
C |
Pascal (Delphi) |
|
|
|
Download both DLL and Visual C++ 6 example Project at: |
Download both DLL and Delphi 3 example Project at: |
Notes:
True=1; False=0; Undefined=-1.
Any null pointer, or integer with a -1 value parameter will be left undefined. All undefined parameters will be not modified from either the default ones or the settings loaded from a .ini file using load_template.
Related options are grouped together. Enter all variable names in lowercase (in Delphi it doesn't matter).
The C and Delphi DLL files are different, although they have the same file name, do not interchange them.
|
Functions |
Parameters |
|
|
start. The error numbers list below show the values that are returned by start. This is the only mandatory function, all other ones are optional. |
exe; |
HTMLPrint file name. |
|
p1; |
Parameter one, pointing to HTML or image file to be printed. | |
|
p3 |
Parameter three, indicating page range. Can be left blank to print all pages. | |
|
wait |
If wait is True the DLL will wait for HTMLPrint run termination after calling it, giving back an error number. If wait is not True less only errors 2, 3 and 4 may be returned. | |
|
options |
orientation |
|
|
printer pnmatch defprinter
|
Each printer can be identified with its name or a number between 0 and
the number of installed printers -1. So if there are 4 printers the printer
number may be 0, 1, 2 or 3. If defprinter is ON, no matter which printer is selected by printer, the default system printer will be used. If pnmatch is True any partial printer name matching will select the first printer in the printer list that matches with printer, otherwise, printer has to be exactly equal to the printer name to be selected. | |
|
printerpapersize |
Both PrinterBin
and PrinterPaperSize can be set by specifying a part of the full
name. | |
|
copies |
Sets how many copies are printed. | |
|
printimages |
If False, images will not be printed. | |
|
tableback |
If False, table background colors will not be printed. | |
|
mono |
If True, monochrome printers will always print black. | |
|
manually |
If True HTMLPrint will show a Setup Printer Dialog and will start visibly. | |
|
printFileName |
This option may be useful when using printer drivers that generate files instead actually printing. If False the file will be named accordingly to the document title, otherwise it will have the same filename than the document, but with different file extension. | |
|
nopath |
This option is handy if all the images are in the same directory than the HTML file, but the images references point to another paths. When nopath=True the images paths will be ignored. | |
|
down, tm |
Only if Down is True online images will be printed. tm (timeout)
indicates the number of milliseconds that the connection should wait for
the image become readable. | |
|
kdelay, delay |
Delay between printing files: kdelay can be 0 (None), 1 (Max. num. sp. jobs) or 2 (Milliseconds):
Therefore, according to the type of delay specified, the value assigned to Delay will indicate either the number of jobs in Windows spooler or milliseconds. Delay can have any value between 0 and 99999. | |
|
hfspace |
HFSpace sets the separation between the header/footer and the page text. It is measured in pixels. | |
|
duplex |
0 = Use printer settings 1 = Simplex 2 = LongEdge 3 = ShortEdge | |
|
margins |
left, top, right, bottom, |
The Bottom margin cannot be set in the TRIAL version. If mm is True LEFT, TOP, RIGHT and BOTTOM margins must be set in millimeters, without fractions, otherwise the may be set in decimal inches. To set the margins in millimeters select Set margin in millimeters, otherwise select Set margin in inches; depending on the selected option USE_MILLIMETERS will be ON or OFF. |
|
marginwidth, marginheight |
marginwidth and
marginheight
are Screen margins and are
expressed in pixels. Although Screen margin are specified in pixels, they will be recalculated to the printer resolution. Therefore the 10 pixels margin on the screen (at 96 DPI) will be scaled to 62 pixels on a 600 DPI printer. | |
|
footer_header |
header, footer, nhfp, nffp |
If nhfp or nffp are True, the first page footer or header will not be printed at all. Notice that the TRIAL version always prints all footers, including the first one. Use header and footer to specify the HTML content to be printed. |
|
dir_list |
rfl, list |
If rfl (ReadFromList)
is True, HTMLPrint will
print all pages listed in the List
file, instead printing the filename passed as a parameter. Nevertheless
a filename always must be passed as a first argument, no matter if it
is not going to be printed, otherwise HTMLPrint will start as a visible
program. |
|
concatenate, joint |
This two options only work with HTMLPrint 5, since the new list format in v6 precludes them. Concatenate and Joint only work when printing files from a List file. If Concatenate is True and
several pages are included in the list all pages will be concatenated
into a single file before printing, separated by <PAGE>
tags. If both Concatenate and Joint are True the pages will be separated by <P> tags, without any page break between different documents. If Concatenate is False, Joint will have no effect at all. When HTML documents are concatenated all them will share
the same title and filename than the first page list document, and only
the options set in the document <HEAD>
section will take effect. Warning: Do not concatenate more pages that the amount your system can handle! | |
|
autopdir, runinv dirhtml, dirimages |
If the directory specified in dirhtml or dirimages exists, HTMLPrint will print all the HTML or image files in
that directory instead the file passed as first parameter. The HTML files will be automatically
erased after they are sent to the printing queue. Only HTML files will be erased,
not any related images. Note: HTMLPrint will run invisibly only when both RunInv is True and you start HTMLPrint with at least one parameter in the command line. When printing files in a directory, you even can pass a nonexistent file as parameter, because the program will just print the files placed in the designated directory instead that file. | |
|
image_metafile Note: Metafiles only will be saved correctly under Windows 2000/XP/2003/Vista or newer. |
pn |
If pn=0, the HTML Document will print normally, if =1 Bitmaps will be generated, if =2, JPEGs will be saved and if =3 metafiles will be generated. If used for margins set pn to 0; |
|
imdir, width, height_scale, split, autoscale, jpgq
|
When printing images you'll get your printout as a collection of BMPs or JPEGs files that you can view, store, modify, and print with other applications, without producing piles of scribbling-paper. A directory with the same name than the file being printed will created inside the imdir, there images will be generated for each document page and named image_1, image_2 and so on. The file extension will be wither .BMP or .JPG, depending on your selection. If imdir doesn't exists it will be created, but if it is not specified, HTMLPRINT directory will be used instead. If a subdirectory with the name of the file being printed already exists, a number will be appended to the directory name to avoid overwriting the files in the existing directory. Width sets the width to which the HTML is to be formatted. Text would typically wrap at this width; if the document contents can't be successfully wrapped to the specified width, it will be increased automatically. If split is True Height_scale sets the images splitting height, with a limit of 4000 pixels. Depending on the HTML Document height, several images may be generated, or one single image will be enough. Different from metafiles generation, the images do not correspond to printing pages in the HTML document, but the document is split based only the height_scale value. If split is False Height_scale sets the scale (in percent). If after scaling the document, it still doesn't fit in 4000 pixels the image will include only the first part of the document. On the contrary, if autoscale is True the scaling will be automatically adjusted, so the documents will be reduced as needed to fit them in 4000 pixels. Jpgq sets the level of the JPEG compression, and so the quality of the generated images. It is not possible to create images with more than 4000 pixels of height. | |
|
metaw, metadir |
Metaw sets the metafiles width in pixels. When printing metafiles you'll get your printout as a collection of metafiles that you can view, store, modify, and print with other applications, without producing piles of scribbling-paper. After creating the metafiles you can use HTMLPrint or any application supporting them to view the metafiles. A directory with the same name than the file being printed will created inside the metadir, there metafiles will be generated for each document page and named page_1.wmf, page_2.wmf and so on. If metadir doesn't exists it will be created, but if it is not specified, HTMLPRINT directory will be used instead. If a subdirectory with the name of the file being printed already exists, a number will be appended to the directory name to avoid overwriting the files in the existing directory. | |
|
apppath |
If apppath is True, the file name original path will be appended to the directory where the images or metafiles are saved. Example: if the file is c:\myfiles\dir1\retro.htm, the directory to be created will be named cmyfilesdir1retro.htm | |
|
defaultfont |
name, size |
Font size must be set in points without fractions. If the HTML page has any tag specifying font formatting, it will invalidate the .ini file font settings. |
|
load_template |
fname |
fname indicates .ini file where the settings are already saved. After loading the settings from a configuration file, if you want to modify only a few of them, pass null pchar's or -1 integer values as parameters to left the corresponding options unmodified. Always include file full path. |