Make batch printing easy with LODOP print controls

Source: Internet
Author: User
Tags javascript extension

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:

  1. xmlns="http://www.w3.org/1999/xhtml">
  2. <meta http-equiv= "content-type" Content="text/html; Charset=utf-8 " />
  3. <title> Untitled document </title>
  4. <script language="javascript" src="Lodopfuncs.js"></ script>
  5. <body>
  6. <form id="Form1">
  7. 11111
  8. </form>
  9. <a href="Javascript:prn1_preview ()"> print Preview </a><br/>
  10. <a href="Javascript:prn1_print ()"> Direct printing </a>
  11. <script language="javascript" type="Text/javascript">    
  12. var lodop; //declared as a global variable
  13. function prn1_preview() {
  14. createoneformpage();
  15. Lodop.     PREVIEW();
  16. };
  17. function prn1_print() {
  18. createoneformpage();
  19. Lodop.     PRINT();
  20. };
  21. function createoneformpage() {
  22. Lodop=Getlodop();
  23. Lodop. Print_init("Print control function Demo _lodop function _ Table single");
  24. Lodop. Set_print_style("FontSize");
  25. Lodop. Set_print_style("Bold",1);
  26.         lodop.add_print_text (50,231,260,39, ""
  27. Lodop. Add_print_htm (a),document. getElementById("Form1"). InnerHTML);
  28. };
  29. </script>
  30. </body>
Copy Code

Should be able to understand, through the ID operation, if the implementation of printing style import, the code is as follows:

  1. function createoneformpage() {
  2. Lodop=Getlodop();
  3. var strstylecss="<link href= ' print.css ' type= ' text/css ' rel= ' stylesheet ' >";
  4. var strformhtml=strstylecss+"<body>"+document. getElementById("Form1"). InnerHTML+"</body>";
  5. Lodop. Print_init("Print admission ticket");
  6. Lodop. Add_print_htm(0,0,"100%","100%",strformhtml);
  7. };
Copy Code

Ps:lodop A4 paper, print area size is 758px*1090px

Make batch printing easy with LODOP 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.