Cloud Print Controls

Source: Internet
Author: User

Mvc4+easyui-based Web development Framework Experience Summary (16)--Use the cloud print control C-LODOP print the page or set the customs waybill information

In the latest Mvc4+easyui Web development Framework, I integrated the online purchase Waybill processing of a module, which integrates the customer guide, waybill merger, arrival scan, close, warehouse, query and other modules of the operation, which involves some of the operation of the waybill set, However, since the introduction of LODOP is not compatible with chrome and other browsers, so have wanted to give up the control of printing, but they launched the "Cloud Print control C-lodop", and the previous interface is almost completely compatible, so in the framework also continue to use this control for related printing processing, including regular printing and waybill information, such as processing.

1, the installation of the control

This cloud control C-lodop (http://www.lodop.net/) is actually after the local installation, the hosting service provides JS service, after the installation of the Boot program interface as shown below.

This way through the server to provide JS service, than plug-in way much better, tested Chrome browser can also print smoothly, the original LODOP plug-in mode of printing is incompatible.

With their own JS initialization code, you can learn that the control is currently in a non-plug-in way to handle printing operations.

Allow other computer browsers to print natively (for example): var oscript = document.createelement ("script"); oscript.src = "/clodopfuncs.js"; var head = Document.head | | document.getElementsByTagName ("Head") [0] | | Document.documentelement;head.insertbefore (Oscript, head.firstchild);//Let the native browser print (more first): Oscript = Document.createelement ("script"); oscript.src = "http://localhost:8000/CLodopfuncs.js?priority=1"; var Head = Document.head | | document.getElementsByTagName ("Head") [0] | | Document.documentelement;head.insertbefore (Oscript, head.firstchild);//The back-fill port 8001 of the native browser (this approach may be error-free): Oscript = Document.createelement ("script"); oscript.src = "http://localhost:8001/CLodopfuncs.js?priority=2"; var Head = Document.head | | document.getElementsByTagName ("Head") [0] | | Document.documentelement;head.insertbefore (Oscript, head.firstchild);

The official example provides the Lodopfuncs.js file for building the print control, where the GETLODOP function is defined in the Lodopfuncs.js file to obtain the Print control object.

Check to see if the JS code for the Cloud Print control is installed as shown below.

<script language= "javascript" type= "Text/javascript" >        function Checkisinstall () {             try{              var lodop= Getlodop ();             if (Lodop. VERSION) {                 if (Lodop. cversion)                 alert ("currently has C-LODOP cloud print available!\n C-lodop version:" +lodop. Cversion+ "(Contains Lodop" +lodop. version+ ")");                  else                 alert ("This machine has successfully installed the LODOP control! \ n Version number: "+lodop." VERSION);}             ;         } catch (Err) {           }     

2, the use of cloud print control C-lodop

This control and the use of the original LODOP consistency, without modifying the original code can directly use the latest printing method, very good, about the use of this control, I described a lot of relevant use of the process.

such as the use of Web pages in WinForm, the case of "using nvelocity to generate content in several ways."

As well as on the Web page of the processing of the "Web Printing solution of the document set dozen", and "web printing solution of the general report printing", the use of the control of the operation is described in detail.

This control provides a very detailed variety of cases (http://www.lodop.net/demo.html), which can be referenced by learning to use.

In the previous introduction, I in the framework of the net purchase Waybill processing inside, continue to use this control for the processing of the set dozen, for example, we need to set up a similar interface content.

We designed a set of page content, as shown below.

The design of the content, we can convert them into the page inside the JS code as shown below.

    <script src= "/content/jquerytools/lodop/checkactivx.js" ></script> <script type= "Text/javascript" &        Gt var Lodop;            Declared as global variable function preview () {//print preview Lodop = Getlodop (); Lodop.            Print_inita (-1,-1, 824, 1129, "waybill set Dozen");            Createlicensedata (); Lodop.            Set_preview_window (2, 0, 0, 800, 600, ""); Lodop.            Set_print_pagesize (1, 0, 0, "A4"); Lodop.        PREVIEW ();        };            function Setup () {//print maintenance Lodop = Getlodop (); Lodop.            Print_inita (-1,-1, 824, 1129, "waybill set Dozen");            Createlicensedata (); Lodop.        Print_setup ();        };            function design () {//print design Lodop = Getlodop (); Lodop.            Print_inita (-1,-1, 824, 1129, "waybill set Dozen");            Createlicensedata (); Lodop.        Print_design ();        };                function Createlicensedata () {if (Printid! = undefined && Printid! = ") {     Use synchronous mode to make the linkage control display properly           $.ajaxsettings.async = false;                                        First, the user sends an asynchronous request to the background implementation method $.getjson ("/billdetail/findbyid?id=" + Printid, function (info) { Lodop.                    Add_print_setup_bkimg ("= 1) {//Then confirm sending the information of the asynchronous request to the background to delete the data $.messager.confirm ("Batch print Confirmation", "Are you sure you want to print the selected records in bulk?") ", function (action) {if (action) {for (var i = 0; i < rows.length;                            i++) {Lodop = Getlodop (); Lodop.                            Print_init (""); Lodop.                            Set_print_pagesize (1, 0, 0, "A4");                            Printid = rows[i].id;                            Createlicensedata (); Lodop.                        PRINT ();            }                    }                });            } else {$.messager.alert ("prompt", "Please select data you want to print in bulk");            }}//Print Maintenance function Printsetup () {var row = $ ("#gridDetail"). DataGrid ("getselected");                if (row) {var index = $ (' #gridDetail '). DataGrid (' Getrowindex ', row);                Printid = row.id;            Setup (); }} </script>

One of the printing interface, also used in the two-dimensional code printing processing operations, so it is convenient to directly use barcode gun directly read, the following code:

                    Lodop. Add_print_barcode (441, 262, "128C", info. Fenyundanhao);                    Lodop. Add_print_barcode (684, 441, 262, "128C", info. Fenyundanhao);

Then in the main page set the Print Operation function button to handle, the following is our Easyui based Web framework interface effect.

The print preview screen looks like this, and when actually printing, we can set the background image not to print.

If it is regular printing, then their interface is very close to what we see in the page, as shown below.

The reference code is shown below.

    @* add support for LODOP controls *@ <script type= "Text/javascript" > var Lodop;            Declared as global variable function Preview () {//original print createlicensedata (); Lodop.            Set_show_mode ("Preview_in_browse", 1); Lodop.        PREVIEW ();        };            function PrintA () {createlicensedata (); Lodop.        PRINTA ();        };            function Setup () {//original print maintenance Createlicensedata (); Lodop.        Print_setup ();        };            function design () {//original print design Createlicensedata (); Lodop.        Print_design ();        };            function Createlicensedata () {Lodop = Getlodop (); Lodop.            Print_init ("Policies and regulations"); var strbodystyle = "<link type= ' text/css ' rel= ' stylesheet ' href= '/content/themes/default/style.css '/><style ><!--Table {border:1;border:1;} th {background-color: #F1F1F3;p adding-left:5px;border:1}--></style>            "; var strformhtml = Strbodystyle + "<body>" + document.getelementByid ("Printcontent"). InnerHTML + "</body>"; Lodop.            Add_print_htm (610, strformhtml); Lodop.        PREVIEW ();            } function SaveAs () {var id = $ (' #ID2 '). Val ();        window.open ('/information/exportwordbyid?id= ' + ID); } </script>

The above is based on the new version of the Cloud print control C-lodop the use of effects and code, we hope to help.

Cloud Print Controls

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.