I have the following code, after multiple iterations. None of which work. I got this based on examples directly from DYMO as well as other questions posted here. Still nothing is working. When I click the buttons, no reaction whatsoever.
<input id="btnUnitPrint" type="button" value="Print Unit Label" onclick = "printunitLabel()"/><br />
<input id="btnOrderPrint" type="button" value="Print Order Label" onclick = "printorderLabel()"/><br />
<script type="text/javascript">
function printunitLabel() {
var printer = dymo.label.framework.getLabelWriterPrinters()[0].modelName;
printerName = printer.name;
var label = DYMO.Label.Framework.Label.Open("UnitLabel.label");
var company = document.getElementById('<%= txtcompany.Text %>').value;
var customer = document.getElementById('<%= txtcustomer.Text %>').value;
var serial = document.getElementById('<%= txtserial.Text %>').value;
var unit = document.getElementById('<%= txtunit_manuf.Text + txtunit_model.Text %>').value;
var warranty = document.getElementById('<%= ddlWarranty.Text %>').value;
label.SetObjectText("lblcompany", company);
label.SetObjectText("lblcustomer", customer);
label.SetObjectText("lblserial", serial);
label.SetObjectText("lblunit", unit);
label.SetObjectText("txtWarranty", warranty);
label.print(printerName);
}
function printorderLabel() {
var printer = dymo.label.framework.getLabelWriterPrinters()[0].modelName;
printerName = printer.name;
var label = DYMO.Label.Framework.Label.Open("OrderLabel.label");
var company = document.getElementById('<%= txtcompany.Text %>').value;
var customer = document.getElementById('<%= txtcustomer.Text %>').value;
var order = document.getElementById('<%= txtorder_id.Text %>').value;
label.SetObjectText("lblcompany", company);
label.SetObjectText("lblcustomer", customer);
label.SetObjectText("lblorder", order);
label.Print(printer);
label.print(printerName);
}
</script>
UPDATE, this panel contains all of the variables I am looking to pass to the label template.
<asp:Panel ID="confirmation_panel" runat="server" Height="457px" Style="margin-right: 0px" Width="1040px" BorderStyle="Double" BorderWidth="2px">
<br />
<table style="width: 469px; height: 385px;">
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblorder_id" runat="server" Text="Order ID:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtorder_id" runat="server" ReadOnly="True" Width="231px" Height="22px" ></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblunit_id" runat="server" Text="Unit ID:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtunit_id" runat="server" ReadOnly="True" Width="231px" Height="22px" ></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="Label5" runat="server" Text="Company Name:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtcompany" runat="server" ReadOnly="True" Width="231px" Height="22px" NullDisplayText=""></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="Label6" runat="server" Text="Client Name:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtcustomer" runat="server" ReadOnly="True" Width="231px" Height="22px" ></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblunit_manuf" runat="server" Text="Unit Manufacturer:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtunit_manuf" runat="server" ReadOnly="True" Width="231px" Height="22px" ></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblunit_model" runat="server" Text="Unit Model:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtunit_model" runat="server" ReadOnly="True" Width="231px" Height="22px" ForeColor="Red"></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblserial" runat="server" Text="Serial Number:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtserial" runat="server" ReadOnly="True" Width="231px" Height="22px" ForeColor="Red"></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblWUserial" runat="server" Text="Whole Unit Serial Number:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtWUserial" runat="server" ReadOnly="True" Width="231px" Height="22px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblwarranty" runat="server" Text="Warranty Status:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:DropDownList ID="ddlWarranty" Width="231px" Height="22px" runat="server">
<asp:ListItem>Warranty Expired</asp:ListItem>
<asp:ListItem>Warranty Active</asp:ListItem>
<asp:ListItem>N/A</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</asp:Panel>
I've tried to look at the most recent documentation, but there is so little and it all seems very outdated. Below here I've made an example of what your form (basically) should look like, wrapped in a
<form>
element.You are going to need the latest version of the
dymo.label.framework.js
framework to load the functionality of DYMO into the browser.The code below basically does the same thing as what you tried above with the key difference that it is now asynchronous, meaning it won't block the code when it tries to calculate expensive tasks, which is good!
The creation of the
label
withdymo.label.framework.open
is still kind of a guess. I've seen examples withdymo.label.framework.openLabelXml
and one with an image so it is up to you which one is appropriate for you. Again with limited documentation it is hard to know what it does.The example below is based on this article on the DYMO dev site. I hope that this will