Dymo SDK print in js scrambled.

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dymo SDK print in js scrambled.相关的知识,希望对你有一定的参考价值。

我有一个网页要打印地址标签,以前在老的DYMO SDK上可以正常工作,现在用DYMO Connect SDK从文本框中打印出的行数顺序不同。例如下面的一个aspx文本框Line 1Line 2Line 3Line 4。

打印如下:第3行(空行)第1行第2行和第4行一起打印。

下面是我打印时使用的javascript

    function prtLabel() {
    var textTextArea = document.getElementById('txtLabelText');
    try {
        // open label
        dymo.label.framework.init();

        var labelXml = '<?xml version="1.0" encoding="utf-8"?>
                    <DieCutLabel Version="8.0" Units="twips">
                        <PaperOrientation>Landscape</PaperOrientation>
                        <Id>Address</Id>
                        <PaperName>30330 Return Address</PaperName>
                         <DrawCommands>
                            <RoundRectangle X="0" Y="0" Width="1581" Height="5040" Rx="270" Ry="270" />
                        </DrawCommands>
                        <ObjectInfo>
                            <AddressObject>
                                <Name>Address</Name>
                                <ForeColor Alpha="255" Red="0" Green="0" Blue="0" />
                                <BackColor Alpha="0" Red="255" Green="255" Blue="255" />
                                <LinkedObjectName></LinkedObjectName>
                                <Rotation>Rotation0</Rotation>
                                <IsMirrored>False</IsMirrored>
                                <IsVariable>True</IsVariable>
                                <HorizontalAlignment>Left</HorizontalAlignment>
                                <VerticalAlignment>Middle</VerticalAlignment>
                                <TextFitMode>ShrinkToFit</TextFitMode>
                                <UseFullFontHeight>True</UseFullFontHeight>
                                <Verticalized>False</Verticalized>
                                <StyledText>
                                    <Element>
                                        <String>DYMO
3 Glenlake Parkway
Atlanta, GA 30328</String>
                                        <Attributes>
                                            <Font Family="Arial" Size="10" Bold="False" Italic="False" Underline="False" Strikeout="False" />
                                            <ForeColor Alpha="255" Red="0" Green="0" Blue="0" />
                                        </Attributes>
                                    </Element>
                                </StyledText>
                                <ShowBarcodeFor9DigitZipOnly>False</ShowBarcodeFor9DigitZipOnly>
                                <BarcodePosition>BelowAddress</BarcodePosition>
                                <LineFonts>
                                    <Font Family="Arial" Size="10" Bold="False" Italic="False" Underline="False" Strikeout="False" />
                                    <Font Family="Arial" Size="10" Bold="False" Italic="False" Underline="False" Strikeout="False" />
                                    <Font Family="Arial" Size="10" Bold="False" Italic="False" Underline="False" Strikeout="False" />
                                    <Font Family="Arial" Size="10" Bold="False" Italic="False" Underline="False" Strikeout="False" />
                                </LineFonts>
                            </AddressObject>
                            <Bounds X="332" Y="150" Width="5760" Height="1260" />
                        </ObjectInfo>
                    </DieCutLabel>';
        var label = dymo.label.framework.openLabelXml(labelXml);

        // set label text
        label.setObjectText("Address", textTextArea.value);

        // select printer to print on
        // for simplicity sake just use the first LabelWriter printer
        var printers = dymo.label.framework.getPrinters();

        if (printers.length === 0) {
            throw "No DYMO printers are installed. Install DYMO printers.";
        }

        var printerName = "";
        for (var i = 0; i < printers.length; ++i) {
            var printer = printers[i];
            if (printer.printerType === "LabelWriterPrinter") {
                printerName = printer.name;
                break;
            }
        }

        if (printerName == "")
            throw "No LabelWriter printers found. Install LabelWriter printer";

        // finally print the label
        label.print(printerName);

        //close the window
        closeprtwin();
    }
    catch (e) {
        alert(e.message || e);
        closewin();
    }

}

function closeprtwin() {
    window.open('', '_self', '');
    window.close();
}
答案

你用的是什么版本?

你有没有试过 "收缩到合适 "的属性?

你可以尝试在DYMO Connect上编辑,然后传输到XML文件中,然后打印出来,确保一切正常。

以上是关于Dymo SDK print in js scrambled.的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 MagTek 读卡器设备的 sdk for android?

Android Studio sdk use in unity

SDK location not found. Define location with sdk.dir in the local.properties

Flutter android studio in mac 显示 Please configure Android SDK in Logcat

SDK接入之Android Google Play内支付(in-app Billing)接入

Google Sign In SDK 实例化 VC 为 nil