jzebra.appendHTML from Ajax

I use Java applet jzebra. When I get html code form ajax and try print, I get source html but not formating html. I try replace not need symbols

.replace(/(\r\n|\r|\n)/g, "\n");

But not help me

this my code

$(".bg-color-blueDark").click(function () {
        $.ajax({
            url: $(this).parent().attr("href"),
            success: function (result) {
                d.dialog();
                document.jzebra.findPrinter();
                var test = result.replace(/(\r\n|\r|\n)/g, "\n");
                //document.jzebra.appendHTML("<html><head><meta charset=\"windows-1251\" /><title>Receipt</title><style type=\"text/css\">body{font-family: verdana,arial,sans-serif;}td{border-bottom:solid 1px #000;}.style1{width: 87px;height: 91px;}</style></head><body><table style=\"width: 300px;\"><tr style=\"display:none\"><td style=\"width:70%\"></td><td style=\"width:30%\"></td></tr><tr><td colspan=\"2\" style=\"text-align:center\" ><img class=\"style1\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFcAAABbCAYAAAAGChkXAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAACxElEQVR4Xu3dTU7DMBAF4AYBFULAiiUX4hacgLNwBC7BgbgBCyT6IwpetCoQWns8bzzjvKzjif35dZIgtQyb72OxWs+W68/Z1cX5jIeewPCxXG3mZ6d6FVlpJzCk5NIDI3CCKcuqSYC4wBwQl7hAAWBpJheIG+JpYbh/+kOweXkEsuiUdo07hvp72Z6R3baFHNgEnXueThbLqrjELQUrPb+MSH62S1z5cnyNJC5wP9zhSj/i0nFAW77+Tga3Nn2147WhXTznIlA8PP8277kIWC/Pv82Si0Id+2i3SnGT5FrCtkyxOa417DbJLa5rittigfttwvr6ZrjWC/vvscpyHia4lgvKeVa1mg8c12ohOajWLQKOW7rons6H4npNrdUTBBS3pxRK1gLD9Z5ai/TCcCU73dsYCG6U1KLTC8HtLYHS9RBXKpcxjrgZSNJTiCuVyxinjhvtZoa8qanjZmzoZE4hLnCriUtcoACwtGpyo97MUDc1VVxgCEKWJi5w24gbATd6v0X0XSY3QnKBcwxbWiW5vbQE7dagghs2WuCJV+P2llrN9Fbjgjc/dPkq3F5Tq5XeKtzQsTKYvBi399RqpFeMa7Dx4S8hwp1KamvTW4w7Ndga4GLc8J9VwwUU4U41tdL0ZuNOHVYCnIVL2J+9JNfjKG4qdHM5N+xUMS6VA3zwu785BWJQ4GZ56HvFR5OLm1b/lYkL3GPiEhcoACzN5BIXKAAszeQCcZv9xg1wTW5KM7nArSAuENdFW0C8Zrf6uav9vWJygcklLnGBAsDSLpKb+qPW34xTHQ/9Nu2ZC9w0kbf3hUqGtOpoTMYNrlbatOp0hZsW8/r8ULWm2vFVFx8Z7Ca5aW53t9di4ASbxns6XLxEjIGUvFh4agX7a3GLu53kIWSvqLu5898k4hqJq56LW2abysQFuhOXuEABYGkmF4j7BclYl5+Hc7DAAAAAAElFTkSuQmCC\" alt=\"\" /></td></tr><tr><td colspan=\"2\" style=\"text-align:center\" ><p style=\"font-size:14px; padding:2px 2px 2px 2px;\">Система управления очередью решила одну из важнейших проблем современного мира, в котором нужно успеть сделать тысячи дел и не терять попусту свое время</p></td></tr><tr><td colspan=\"2\" style=\"text-align:center\" ><p style=\"font-size:30px; font-weight:bold; padding:7px 2px 7px 2px;\">QLogic</p></td></tr><tr><td colspan=\"2\" style=\"text-align:center\" ><p style=\"font-size:17px; font-weight:bold; font-style:italic; padding:5px 0px 5px 0px;\">Система управления очередью</p></td></tr><tr><td colspan=\"2\" style=\"text-align:center\" ><p style=\"font-size:65px; font-weight:bold\">A-1234</p></td></tr><tr><td colspan=\"2\" style=\"text-align:center\" ><p style=\"font-size:22px; font-weight:bold;  font-style:italic; padding:2px 2px 2px 2px;\">VIP - клиент</p></td></tr><tr><td colspan=\"2\"><ul style=\"font-size:12px; padding:8px 5px 0px 25px\"><li style=\"padding:2px 2px 2px 0px\">Предоставляемая услуга номер 1 Предоставляемая  Предоставляемая </li><li style=\"padding:2px 2px 2px 0px\">Предоставляемая услуга номер 2</li><li style=\"padding:2px 2px 2px 0px\">Предоставляемая услуга номер 3</li><li style=\"padding:2px 2px 2px 0px\">Предоставляемая услуга номер 4</li></ul></td></tr><tr><td><p style=\"font-size:13px; padding:2px 2px 2px 2px;\">Время регистрации:</p></td><td><p style=\"font-size:13px; font-weight:bold; padding:2px 2px 2px 2px; text-align:center;\">14:45:06</p></td></tr><tr><td><p style=\"font-size:13px; padding:2px 2px 2px 2px;\">Оператор:</p></td><td><p style=\"font-size:13px; font-weight:bold; padding:2px 2px 2px 2px; text-align:center;\">1, 2, 3</p></td></tr><tr><td><p style=\"font-size:13px; padding:2px 2px 2px 2px;\">Этаж:</p></td><td><p style=\"font-size:13px; font-weight:bold; padding:2px 2px 2px 2px; text-align:center;\">2</p></td></tr><tr><td><p style=\"font-size:13px; padding:2px 2px 2px 2px;\">Людей в очереди:</p></td><td><p style=\"font-size:13px; font-weight:bold; padding:2px 2px 2px 2px; text-align:center;\">21</p></td></tr><tr><td><p style=\"font-size:13px; padding:2px 2px 2px 2px;\">Время ожидания:</p></td><td><p style=\"font-size:13px; font-weight:bold; padding:2px 2px 2px 2px; text-align:center;\">14 мин</p></td></tr></table></body></html>");
                document.jzebra.appendHTML(test);
                document.jzebra.printHTML();
                monitorPrinting();
            }
        });
        return false;

    });

Answers


I find problem. If return value starts with space we haved this problem.


you can try for replace your code :

var data = data.split(yourText).join(yourReplaceText);

and for ajax code you can try with like this :

// PRINT DIRECT TO PRINTER

    var applet = document.jzebra;
    applet.findPrinter();
    applet.append(String.fromCharCode(15)); //condensed font

    Ext.Ajax.request({
        url: Rich.config.yourPathReport + yourUrlReport
        success: function (response) {

            var data = response.responseText;
            var title = "YOUR TEXT";

            var data = data.split(title).join(title2);

            applet.append(data);
            console.info(data);
            applet.print();

        },

        failure: function (response, options) {
            Ext.Msg.alert('Status', 'Failed Print, ' + response.getResponseHeader("Error Msg"));
        }
    });

Need Your Help

Hadoop - look for matching names in two customer lists

hadoop merge match multifile

I have two lists of people from different events; I would like to look for matching names of people amongst those lists, as well as matching companies. I understand that potentially there will be ...

Java Swing Applet---JFormattedTextField

java textfield jformattedtextfield

I'm writing my first Java Swing Applet, and wanted to include a JFormattedTextField that only allowed integers greater than 0.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.