简体   繁体   中英

How to generate XML for label to print in Javascript using DYMO Connect for Desktop

I manage to print a label from DYMO Connect for Desktop v1.3.1. Now I am trying to print the same label using Javascript. The example PrintMeThatLabel.js is a great example. It contains three different label designs in XML. However, I would like to use the design I created wtih DYMO Connect for Desktop. When I try to use the Dymo file (which is an XML file with extension ".dymo") that was saved with DYMO Connect, I get the following error message if I load it with dymo.label.framework.openLabelXml() :

{"message":"An error has occurred.","exceptionMessage":"'Element' is an invalid XmlNodeType. Line 22, position 4.","exceptionType":"System.Xml.XmlException","stackTrace":"   at System.Xml.XmlReader.ReadEndElement()\r\n   at DYMO.LabelAPI.DYMOLabel`1.Deserialize(XmlReader reader)\r\n   at DYMO.CrossPlatform.Common.Helpers.SerializationHelper.Deserialize[T](XmlReader reader)\r\n   at DYMO.LabelAPI.LabelHelper.ReadAndOpenLabel(XmlReader reader)\r\n   at DYMO.LabelAPI.LabelHelper.OpenLabel(XmlReader reader)\r\n   at DymoSDK.Implementations.DymoLabel.LoadLabelFromXML(String xmlContent)\r\n   at DYMOWebApi.Windows.Controllers.DymoDLSSDKController.GetListLabelsFromSetXML(String labelXml, String labelSetXml)\r\n   at DYMOWebApi.Windows.Controllers.DymoDLSSDKController.PrintLabel2(FormDataCollection formDataCollection)\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"}: 
    at Td (DYMO.Label.Framework.3.0.js:61)
    at ae (DYMO.Label.Framework.3.0.js:66)
    at be.printLabel2 (DYMO.Label.Framework.3.0.js:67)
    at Object.printLabel2 (DYMO.Label.Framework.3.0.js:101)
    at oe (DYMO.Label.Framework.3.0.js:126)
    at qe (DYMO.Label.Framework.3.0.js:129)
    at Y.G (DYMO.Label.Framework.3.0.js:74)
    at printLabel (207:608)
    at startupCode (207:617)
    at DYMO.Label.Framework.3.0.js:110

If I use openLabelFile instead of openLabelXml I get this error in the console:

Uncaught Error: "Illegal characters in path."

"Illegal characters in path.": 
    at Td (DYMO.Label.Framework.3.0.js:61)
    at ae (DYMO.Label.Framework.3.0.js:66)
    at be.openLabelFile (DYMO.Label.Framework.3.0.js:67)
    at Object.openLabelFile (DYMO.Label.Framework.3.0.js:101)
    at Object.openLabelFile (DYMO.Label.Framework.3.0.js:122)
    at printLabel (207:595)
    at startupCode (207:617)
    at DYMO.Label.Framework.3.0.js:110
    at e (DYMO.Label.Framework.3.0.js:115)
    at cd.<anonymous> (DYMO.Label.Framework.3.0.js:62)

The XML in the file from DYMO Connect looks very different from the XML of the label designs in PrintMeThatLabel.js . Can anyone help me?

I had the same problem as you this morning!

The newest javascript framework is not compatible with label templates created with Dymo Connect. You need to create it with the previous software. Version 8.3.1 works.

Watch out though, both softwares installed and your code won't recognize the printer. You'll need to uninstall both softwares and re-install Dymo Connect.

Hope this helps! Yan

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM