LODOP for printing functions

Source: Internet
Author: User

Lodopfuncs.js:

varcreatedoklodop7766=NULL;functionGetlodop (oobject,oembed) {/************************** This function determines which page element to use as the Lodop object depending on the browser type: IE series, ie kernel series browser with Oobject, other browsers (Firefox series, Chrome series,  Opera series, Safari series, etc.) using oembed, if the page does not have related object elements, create a new one or use the last one, avoiding duplicate builds. The 64-bit browser points to the 64-bit installer install_lodop64.exe. **************************/        varStrhtminstall= "<br><font color= ' #FF00FF ' > Print control not installed! Click here <a href= '/install_lodop32.exe ' target= ' _self ' > Perform installation </a&gt, refresh the page or re-enter after installation. </font> "; varstrhtmupdate= "<br><font color= ' #FF00FF ' > Print controls need to be upgraded! Click here <a href= '/install_lodop32.exe ' target= ' _self ' > Perform upgrade &LT;/A&GT, please re-enter after upgrade. </font> "; varStrhtm64_install= "<br><font color= ' #FF00FF ' > Print controls not installed! Click here <a href= '/install_lodop64.exe ' target= ' _ Self ' > Perform installation </a&gt, please refresh the page or re-enter after installation. </font> "; varstrhtm64_update= "<br><font color= ' #FF00FF ' > Print controls need to be upgraded! Click here <a href= '/install_lodop64.exe ' target= ' _ Self ' > Perform upgrade &LT;/A&GT, please re-enter after upgrade. </font> "; varstrhtmfirefox= "<br><br><font color= ' #FF00FF ' > (Note: If you have installed LODOP legacy attachment Npactivexplugin, use the" tools " Add-ons, extensions, remove it first) </font>; varStrhtmchrome= "<br><br><font color= ' #FF00FF ' > (if previously normal, only due to a browser upgrade or reinstall problem, you need to re-perform the above installation) </font>"; varLodop; Try{             //===== Judging Browser type: ===============         varIsie = (navigator.userAgent.indexOf (' MSIE ') >=0) | | (Navigator.userAgent.indexOf (' Trident ') >=0); varIs64ie = Isie && (navigator.userAgent.indexOf (' x64 ') >=0); //===== If the page has LODOP to use directly, no new: ==========         if(oobject!=undefined | | oembed!=undefined) {                     if(Isie) Lodop=Oobject; ElseLodop=oembed; } Else {          if(createdoklodop7766==NULL) {Lodop=document.createelement ("Object"); Lodop.setattribute ("width", 0); Lodop.setattribute ("Height", 0); Lodop.setattribute ("Style", "position:absolute;left:0px;top:-100px;width:0px;height:0px;"); if(Isie) Lodop.setattribute ("ClassID", "Clsid:2105c259-1e0c-4534-8141-a753534cb4ca"); ElseLodop.setattribute ("type", "Application/x-print-lodop");                  Document.documentElement.appendChild (LODOP); CreatedOKLodop7766=Lodop; } ElseLodop=CreatedOKLodop7766;         }; //===== Determine if the LODOP plug-in has been installed, no installation or low version prompts to download the installation: ==========         if((lodop==NULL)|| (typeof(Lodop. VERSION) = = "Undefined")) {                 if(Navigator.userAgent.indexOf (' Chrome ') >=0) Document.documentElement.innerHTML=strhtmchrome+Document.documentElement.innerHTML; if(Navigator.userAgent.indexOf (' Firefox ') >=0) Document.documentElement.innerHTML=strhtmfirefox+Document.documentElement.innerHTML; if(Is64ie) document.write (Strhtm64_install);Else                 if(Isie) document.write (Strhtminstall);ElseDocument.documentElement.innerHTML=strhtminstall+Document.documentElement.innerHTML; returnLodop; } Else          if(Lodop. version< "6.1.9.8") {                 if(Is64ie) document.write (strhtm64_update);Else                 if(Isie) document.write (strhtmupdate);ElseDocument.documentElement.innerHTML=strhtmupdate+Document.documentElement.innerHTML; returnLodop;         }; //===== The following blank position is suitable for calling unified functions (such as registration code, language selection, etc.): = = = =Lodop. Set_licenses ("," "," "," ""); //============================================================                  returnLodop; } Catch(err) {if(is64ie) Document.documentElement.innerHTML= "Error:" +strhtm64_install+document.documentelement.innerhtml;ElseDocument.documentElement.innerHTML= "Error:" +strhtminstall+Document.documentElement.innerHTML; returnLodop; };}

Second.js:

functionprintcontent (ttl,type,defaw,w) {varHtmlstr= "<! DOCTYPE html> "+document.getelementsbytagname (" html ") [0].innerhtml+" ; Lodop = Getlodop (); Lodop. Print_init (TTL);    //top left width height, paging according to height    //Lodop. Add_print_url (0,0,600, "98%", URL);//[url need to log in, Add_print_url can't log in]    if(w) {Lodop. Add_print_htm (0,0,w, "100%", HTMLSTR); Lodop. Set_print_stylea (0, "Horient", 2); }Else{        if(defaw== ' FIXED ') {Lodop. Add_print_htm (0,0,680, "100%", HTMLSTR); Lodop. Set_print_stylea (0, "Horient", 2); }Else{// AllLodop. Add_print_htm (0,0, "100%", "100%", HTMLSTR); }    }        if(type== ' PRINT ') {Lodop. Set_show_mode ("Np_no_result",true);//lodop6.198 will be effective later . Lodop.    PRINT (); }Else if(type== ' SELECT '){        if(Lodop. Select_printer () >=0) {Lodop. Set_show_mode ("Np_no_result",true); Lodop.        PRINT (); }    }Else if(type== ' PREVIEW ') {Lodop. Set_show_mode ("Np_no_result",true); Lodop.    PREVIEW (); }}functionIeprint (ieobjid,type) {varHkey_root = "HKEY_CURRENT_USER"varHkey_path = "\\software\\Microsoft\\Internet explorer\\pagesetup\\"; varHead,foot,top,bottom,left,right; Try{        varWsh=NewActiveXObject ("Wscript.Shell"); //Get default value        /** head = Wsh.regread (hkey_root+hkey_path+ "header");//Header foot = Wsh.regread (hkey_root+hkey_path+ "Footer") ;//Footer bottom = Wsh.regread (hkey_root+hkey_path+ "Margin_bottom");//Bottom margin left = Wsh.regread (hkey_root+hkey_pat H + "Margin_left");//left Margin right = Wsh.regread (hkey_root+hkey_path+ "margin_right");//Margin top = Wsh.regread (HKE y_root+hkey_path+ "Margin_top");//page margin **/        //SetWsh.regwrite (hkey_root+hkey_path+ "header", "" "); Wsh.regwrite (Hkey_root+hkey_path+ "Footer", "" "); Wsh.regwrite (Hkey_root+hkey_path+ "Margin_bottom", "0.1"); Wsh.regwrite (Hkey_root+hkey_path+ "Margin_left", "0.1"); Wsh.regwrite (Hkey_root+hkey_path+ "Margin_right", "0.1"); Wsh.regwrite (Hkey_root+hkey_path+ "Margin_top", "0.1"); }Catch(OE) {//alert ("Setting the header footer and print margins fails, register Wscript.Shell and set the browser security level to low, or set it manually in the browser's print-to page settings.") ");    }        varieobj=document.getElementById (Ieobjid); if(type== ' PRINT ') {IEOBJ.EXECWB (6,1); }Else if(type== ' SELECT ') {IEOBJ.EXECWB (6,6); }Else if(type== ' PREVIEW ') {IEOBJ.EXECWB (7,1); }    /** Printing has a delay, restore settings will result in the previous setup effectiveness, first do not restore try{var wsh=new activexobject ("Wscript.Shell");        Restore Wsh.regwrite (hkey_root+hkey_path+ "header", head);        Wsh.regwrite (hkey_root+hkey_path+ "footer", foot);        Wsh.regwrite (hkey_root+hkey_path+ "Margin_bottom", bottom);        Wsh.regwrite (hkey_root+hkey_path+ "Margin_left", left);        Wsh.regwrite (hkey_root+hkey_path+ "Margin_right", right);    Wsh.regwrite (hkey_root+hkey_path+ "Margin_top", top);    }catch (OE) {//alert (OE); }    **/}

Implementation page (main code):

<script language= "JavaScript" >

Printcontent ("title", "${enterpriseinfo.doprint}", "${enterpriseinfo.printwidth}");

</script>

Pay attention to the official website first download: Install_lodop32.exe and Install_lodop64.exe.

Here's made a second.js modification. Can not use this JS.

Reference official website: http://www.mtsoftware.cn/demo.html

LODOP for printing functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.