Recently in a printing program, to achieve batch printing function, in the online search for many days, but also in the TP website Consulting Daniel, to everyone's proposal I have carried out a study, summarized as follows:
There are two ways you can achieve batch printing:
One is the use of professional reporting procedures, to achieve a very complex needs, but the study report is also a very painful thing, I concentrate on the study of the day did not make any progress, maybe I was too food. This method recommends the sharp wave report, free good use.
The second is the use of JS plug-in implementation, but also on the internet to find a lot, and finally thank HUNDUNCN, he suggested that I use LODOP (see: http://www.thinkphp.cn/topic/12938.html), due to html+css very familiar with, So it's not hard to get started, it's really good.
LODOP (Standard sound: Lao DAO, commonly known as: Dew Belly) is a professional Web control, which can be used to clip output page content, and can be used to directly implement complex printing program code. Controls are powerful, yet simple to use, and all calls are like JavaScript extension statements. Official website: http://www.lodop.net/, the program downloaded from the official website has many examples, but also very comprehensive.
Here's the code:
- xmlns="http://www.w3.org/1999/xhtml">
- <meta http-equiv= "content-type" Content="text/html; Charset=utf-8 " />
- <title> Untitled document </title>
- <script language="javascript" src="Lodopfuncs.js"></ script>
- <body>
- <form id="Form1">
- 11111
- </form>
- <a href="Javascript:prn1_preview ()"> print Preview </a><br/>
- <a href="Javascript:prn1_print ()"> Direct printing </a>
- <script language="javascript" type="Text/javascript">
- var lodop; //declared as a global variable
- function prn1_preview() {
- createoneformpage();
- Lodop. PREVIEW();
- };
- function prn1_print() {
- createoneformpage();
- Lodop. PRINT();
- };
- function createoneformpage() {
- Lodop=Getlodop();
- Lodop. Print_init("Print control function Demo _lodop function _ Table single");
- Lodop. Set_print_style("FontSize");
- Lodop. Set_print_style("Bold",1);
- lodop.add_print_text (50,231,260,39, ""
- Lodop. Add_print_htm (a),document. getElementById("Form1"). InnerHTML);
- };
- </script>
- </body>
Copy Code
Should be able to understand, through the ID operation, if the implementation of printing style import, the code is as follows:
- function createoneformpage() {
- Lodop=Getlodop();
- var strstylecss="<link href= ' print.css ' type= ' text/css ' rel= ' stylesheet ' >";
- var strformhtml=strstylecss+"<body>"+document. getElementById("Form1"). InnerHTML+"</body>";
- Lodop. Print_init("Print admission ticket");
- Lodop. Add_print_htm(0,0,"100%","100%",strformhtml);
- };
Copy Code
Ps:lodop A4 paper, print area size is 758px*1090px
Make batch printing easy with LODOP print controls