In an article that introduced the "Ordinary Report Printing Function of Web Printing Solutions" mentioned earlier, the printing control Lodop is quite convenient to make the set. At least the position adjustment interface does not need to be done by yourself. As for the position, it also provides an automatic save function, so you don't need to pay attention to it.
General set-ups include several parts of operations: print preview, print maintenance, and print design.
Print preview and print maintenance are aimed at end users. Print maintenance refers to the content that cannot be modified and deleted, but the position can be adjusted, providing the possibility of adjusting the position for printing of different printers of different sizes.
Print design is for developers. At the beginning, we need to use this function to design the interface for setting up the set, which is to roughly place the location of each content based on the background picture of the set up the certificate.
The general implementation code is as follows:
<script language="javascript">var LODOP=document.getElementById("LODOP");//This line of statement is to comply with the DTD specification CheckLodop();</script><script language="javascript" type="text/javascript"> function Preview2() { CreateDataBill();LODOP.PREVIEW(); }; function Setup2() { CreateDataBill();LODOP.PRINT_SETUP(); }; function Design2() { CreateDataBill();LODOP.PRINT_DESIGN();}; function RealPrint() { CreateDataBill();if (LODOP.PRINTA()) alert("The actual printing command has been issued!"); else alert("Print abstain from printing!"); }; function CreateDataBill() {LODOP.SET_PRINT_PAPER(10,10,762,533,"Print control function demonstration_Lodop function_Mobile company invoice set");LODOP.ADD_PRINT_TEXT(126,150,100,20,"Guo Degang");LODOP.SET_PRINT_STYLEA(1,"FontC olor",16711680);LODOP.ADD_PRINT_TEXT(151,150,100,20,"13954885177");LODOP.SET_PRINT_STYLEA(2,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(125,5 84,99,20,"Invoice Print (1st Time)");LODOP.SET_PRINT_STYLEA(3,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(465,140,198,20,"Lubaqi Shibayuan Triangle Zero Minute");LODOP.SET_PRINT_STYLE A(4,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(465,599,70,20,"678.30");LODOP.SET_PRINT_STYLEA(5,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(49 6,408,59,20,"H112063");LODOP.SET_PRINT_STYLEA(6,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(191,58,100,20,"Domestic Roaming Call");LODOP.SET_PRINT_STYLEA(7, "FontColor",16711680);LODOP.ADD_PRINT_TEXT(191,217,100,20,"584.00");LODOP.SET_PRINT_STYLEA(8,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(222,5 8,100,20,"value-added business expenses");LODOP.SET_PRINT_STYLEA(9,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(222,217,100,20,"48.30");LODOP.SET_PRINT_STYLEA(10,"Fon tColor",16711680);LODOP.ADD_PRINT_TEXT(251,58,100,20,"Charge");LODOP.SET_PRINT_STYLEA(11,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(251,217,100, 20,"50.00");LODOP.SET_PRINT_STYLEA(12,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(280,58,100,20,"Promotional Fee");LODOP.SET_PRINT_STYLEA(13,"FontColor", 16711680);LODOP.ADD_PRINT_TEXT(280,217,100,20,"4.00");LODOP.SET_PRINT_STYLEA(14,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(98,101,150,20,"101 081005747319387");LODOP.SET_PRINT_STYLEA(15,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(97,307,150,20,"October 19, 2008 10:28:38");LODOP.SET_PRINT_ STYLEA(16,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(152,584,103,20,"138860016786");LODOP.SET_PRINT_STYLEA(17,"FontColor",16711680);LODOP.ADD _PRINT_TEXT(95,571,112,20,"06775516");LODOP.SET_PRINT_STYLEA(18,"FontName","System");LODOP.SET_PRINT_STYLEA(18,"FontColor",16711680);LODOP.A DD_PRINT_TEXT(496,135,183,20,"September 2008(20080901-20080930)");LODOP.SET_PRINT_STYLEA(19,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(496,572,112, 20,"-Wangfujing Central Store Camp");LODOP.SET_PRINT_STYLEA(20,"FontColor",16711680);LODOP.ADD_PRINT_TEXT(311,217,100,20,"678.30");LODOP.SET_PRINT_STYLEA(21,"Font Color",16711680);LODOP.ADD_PRINT_TEXT(311,58,100,20,"Total Cost");LODOP.SET_PRINT_STYLEA(22,"FontColor",16711680);LODOP.ADD_PRINT_SETUP_BKIMG("<img src=Report/Certificate Background.jpg' />");LODOP.SET_SHOW_MODE ("BKIMG_IN_PREVIEW",1);}</script>Most of the contents are relatively easy to understand. Different functions call different functions Preview for preview, Setup for maintenance, and Design for design.
When printing, please note that the following code is required to set the background image to display (the background is not printed when printing).
LODOP.ADD_PRINT_SETUP_BKIMG("<img src=Report/Certificate Background.jpg' />");LODOP.SET_SHOW_MODE ("BKIMG_IN_PREVIEW",1); //Whether the background image is included when printing the previewIn addition, since the content of the report is written in the HTML page, when setting the content dynamically, you can use a script to read interface elements as the data source, and second, you can automatically generate script code through the background code and output it to the front page to see what you need.
The preview interface for set-up is roughly shown in the figure below, where the blue part is the content that needs to be printed, and the background image is a template for invoices.
The following code is to obtain the corresponding content through scripts. This situation is suitable for scenarios where some printed content may be modified on the interface.
LODOP.ADD_PRINT_TEXT(95, 695, 250, 52, document.getElementById("txtCompanyName").innerText); //Office name LODOP.SET_PRINT_STYLEA(1, "FontSize", 14);LODOP.SET_PRINT_STYLEA(1, "Bold", 1);var licenseDate = document.getElementById("txtLicenseDate").value; //The validity period of the certificate var licenseYear = "";var licenseMonth = "";var licenseDate licenseDay = "";if (licenseDate != null && licenseDate != "") {licenseYear = licenseDate.split("-")[0];licenseMonth = licenseDate.split("-")[1];licenseDay = (licenseDate.split("-")[2]).substr(0, 2);}LODOP.ADD_PRINT_TEXT(396, 190, 46, 22, validateYear); //The end of the validity period LODOP.SET_PRINT_STYLEA(6, "FontSize", 11);LODOP.SET_PRINT_STYLEA(6, "Bold", 1);LODOP.ADD_PRINT_TEXT(396, 253, 30, 22, validateMonth); //Expiration period end month LODOP.SET_PRINT_STYLEA(7, "FontSize", 11);LODOP.SET_PRINT_STYLEA(7, "Bold", 1);LODOP.ADD_PRINT_TEXT(396, 304, 32, 22, validateDay); //Expiration date LODOP.SET_PRINT_STYLEA(8, "FontSize", 11);LODOP.SET_PRINT_STYLEA(8, "Bold", 1);Finally, it is attached with its design interface, where the code generation function can generate content layout display for static HTML, and it can be used in dynamic pages after making certain modifications and adjustments. A very useful feature.
The above is the implementation idea of the web printing solution for certificate set introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!