IE9 environment. LODOP printing, when printing for the first time, the picture cannot be loaded, and the loading is incomplete.

IE9 environment. LODOP printing, when printing for the first time, the picture cannot be loaded, and the loading is incomplete.

In recent projects involving photo printing, the first printing in the IE9 environment will show that the picture cannot be printed , or only a part of it will be printed , but the second printing or switching the browser to Edge, it can be completely printed. question. The first thing that came to my mind was that the image was not loaded or was not fully loaded due to network reasons. Add a delay! This is the first method that comes to my mind.

But where is the delay added? I was still very confused at the time, so after various attempts:
this is the initial code:

success : function(html) {
                LODOP.PRINT_INIT("合格证打印"+rowsData.NAME+"--"+rowsData.CREDENTIALS_NO);
                if(hgzType == "1"){
                    LODOP.SET_PRINT_PAGESIZE(1,"210mm","297mm","");
                }else{
                    LODOP.SET_PRINT_PAGESIZE(2,"210mm","297mm","");
                }
                LODOP.ADD_PRINT_HTM(hgzTop?hgzTop:20,hgzLeft?hgzLeft:15, "100%","100%",html);
                LODOP.PRINT();
            }

Here is the first modified code:

success : function(html) {
                setTimeout(function () {
                    LODOP.PRINT_INIT("合格证打印"+rowsData.NAME+"--"+rowsData.CREDENTIALS_NO);
                    if(hgzType == "1"){
                        LODOP.SET_PRINT_PAGESIZE(1,"210mm","297mm","");
                    }else{
                        LODOP.SET_PRINT_PAGESIZE(2,"210mm","297mm","");
                    }
                    LODOP.ADD_PRINT_HTM(hgzTop?hgzTop:20,hgzLeft?hgzLeft:15, "100%","100%",html);
                    LODOP.PRINT();
                },3*1000);

            }

Tested again and found that it still doesn't work. The image loading is completed after the print control is called, which only delays the call to the print control, so I wonder what about the delay before printing starts? So there is a second change:

success : function(html) {
                LODOP.PRINT_INIT("合格证打印"+rowsData.NAME+"--"+rowsData.CREDENTIALS_NO);
                if(hgzType == "1"){
                    LODOP.SET_PRINT_PAGESIZE(1,"210mm","297mm","");
                }else{
                    LODOP.SET_PRINT_PAGESIZE(2,"210mm","297mm","");
                }
                LODOP.ADD_PRINT_HTM(hgzTop?hgzTop:20,hgzLeft?hgzLeft:15, "100%","100%",html);
                setTimeout(function () {
                    LODOP.PRINT();
                },3*1000);

            }

The original idea is that LODOP.PRINT() calls the print control. Is the image loading already in progress before LODOP.ADD_PRINT_HTM ? The test gave me a slap in the face right away. Still can't print the photo!

Then the only way is to find the LODOP documentation, but I found that there are not many discussions about LODOP on the Internet. Even if there are most of them, there are some tutorials. There are not many articles with problems. I found a good introduction to the various methods of LODOP. The article @ Qiuzhi Road is long , (but still haven't found the way I want).
Later, I found the answer in @ dqx-low-privileged Lodop, C-Lodop short Q&A (2) (but @dqx-low-privileged homepage is real... It makes people not want to go on shopping....).
In fact, LODOP comes with a delay task for delay loading hypertext:


LODOP.SET_PRINT_STYLEA(0,”HtmWaitMilSecs”,1000)


This is to delay the download of hypertext for 1000 milliseconds. The code after that is:

    success : function(html) {
                LODOP.PRINT_INIT("合格证打印"+rowsData.NAME+"--"+rowsData.CREDENTIALS_NO);
                if(hgzType == "1"){
                    LODOP.SET_PRINT_PAGESIZE(1,"210mm","297mm","");
                }else{
                    LODOP.SET_PRINT_PAGESIZE(2,"210mm","297mm","");
                }
                LODOP.ADD_PRINT_HTM(hgzTop?hgzTop:20,hgzLeft?hgzLeft:15, "100%","100%",html);
                LODOP.SET_PRINT_STYLEA(0,"HtmWaitMilSecs",1000);
                LODOP.PRINT();
            }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324643423&siteId=291194637