Print an Image from the Web

There is a PrintDIBPageEx method in the BiPrint.ocx to print DIBs from an HTML page. There are properties for specifying the printing. For example the scaling factor can be specified by the PrintingScaleLeft, PrintingScaleTop, PrintingScaleRight, PrintingScaleBottom properties.

 

[JavaScript]

 

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>

<HTML>

<HEAD>

<TITLE> Using Black Ice ActivwX control with HTML form tag </TITLE>

<SCRIPT language="JavaScript">

            var PageNum=0;

            var FilePath="http://www.blackice.com/DOCIMG_HTML_SAMPLE/test.tif";

            var LocalFile="c:\\test.tif";

 

            function OnLoad()

            {

                        BIDISP.ScaleMode = 5;

                        BIDISP.ScrollBars = 3;

                        BIDISP.ZoomWithKeyboard=1;

                        BIDISP.Zoom = 0;

                        BITIFF.DownloadImageFileURL(FilePath, LocalFile);

            }

 

            function OnPrint()

            {

                        if (BIDISP.hDib > 0)

                        {

                                    BIPRINT.PrepareToPrint(0, "test", 1, 1, true, false, false, true, false, false, false, true, false);

                                    BIPRINT.PrintingScaleLeft = 1;

                                    BIPRINT.PrintingScaleTop = 1;

                                    BIPRINT.PrintingScaleRight = 1;

                                    BIPRINT.PrintingScaleBottom = 1;

                                    BIPRINT.PrintDIBPageEx(BIDISP.hDib, 0, 0, 0);

                                    BIPRINT.EndPrint();

                        }

            }

 

            function MM_reloadPage(init)

            {  //reloads the window if Nav4 resized

              if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

                        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

              else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

            }

            MM_reloadPage(true);

 

</SCRIPT>

</HEAD>

 

<BODY>

 

<P align="center"><strong><font size="+3">Using Black Ice OCX control with HTML FORM tag</font></strong>

</P>

 

<P>

            <TABLE width="645" height="372" border="1" align="center">

              <TR>

                        <TD width="100%" colspan="2" rowspan="3">

                       

                          <object id="BIDISP" width="100%" height="100%" classid="CLSID:19B50C95-6BB5-4DFD-B20C-5B9A61FA1C0D" CODEBASE="http://www.blackice.com/DOCIMG_HTML_SAMPLE/tiff.cab">

                          </object>      

                         

                          <object id="BITIFF" width=1 height=1 classid="CLSID:2324B5B7-D3EF-464C-BB35-06EFF8F11EB3" CODEBASE="http://www.blackice.com/DOCIMG_HTML_SAMPLE/tiff.cab">

                          </object>

 

                           <object id="BIPRINT" width=1 height=1 classid="CLSID:3D806C87-EE83-46D6-AB30-12D62715D8A1" CODEBASE="http://www.blackice.com/DOCIMG_HTML_SAMPLE/tiff.cab">

                          </object>

                         

                          <SCRIPT>

                                    function BITIFF::URLDownloadImageFileComplete()

                                    {

                                                var hDib = BITIFF.LoadTiffIntoDIB(LocalFile, 0, false);

                                                BIDISP.hDib = hDib;

                                    }

                         </SCRIPT>

                        </TD>

                        </TR>

            </TABLE>

</P>

 

<P>

            <FORM>

                        <input type="button" value="Dispay Image" onClick="OnLoad()">

                        <input type="button" value="Print Image" onClick="OnPrint()">

            </FORM>

</P>

 

</BODY>

</HTML>