dymo-connect-framework
dymo-connect-framework copied to clipboard
getLabelXml() problem
I noticed this while opening an 8.7.x label or connect label in the connect 1.3.2 framework using JavaScript. I was testing for a 450 Twin Turbo LabelWriter. I believe that the regular expression used during retrieval of the label XML is incorrect as the XML comes back invalid. This was actually causing me a CORS error during printing.
var label = dymo.label.framework.openLabelFile(labelFileName);
var labelXml = label.getLabelXml();
The problem occurs here:
dymo.xml.serialize = function(node)
{
function fix (node) {
return node.replaceAll(/<Color (.+)\/>/g, "<Color $1> </Color>");
}
return fix(goog.dom.xml.serialize(node));
};
If the regular expression is changed so that it will now stop at the end of the tag and it is no longer eager, the sample code works:
return node.replaceAll(/<Color ([^>]+?)\/>/g, "<Color $1> </Color>");
To test this, simply create an eclipse / circle shape on the label. Here is the label XML that was causing me problems:
<?xml version="1.0" encoding="utf-8"?>
<DesktopLabel Version="1">
<DYMOLabel Version="3">
<Description>DYMO Label</Description>
<Orientation>Portrait</Orientation>
<LabelName>30270 Continuous</LabelName>
<InitialLength>1</InitialLength>
<BorderStyle>SolidLine</BorderStyle>
<DYMORect>
<DYMOPoint>
<X>0.1173611</X>
<Y>0.3708333</Y>
</DYMOPoint>
<Size>
<Width>2.205555</Width>
<Height>0.5</Height>
</Size>
</DYMORect>
<BorderColor>
<SolidColorBrush>
<Color A="1" R="0" G="0" B="0"></Color>
</SolidColorBrush>
</BorderColor>
<BorderThickness>0</BorderThickness>
<Show_Border>False</Show_Border>
<ContinuousLayoutManager>
<RotationBehavior>ClearObjects</RotationBehavior>
<LabelObjects>
<ShapeObject>
<Name>SHAPE</Name>
<Brushes>
<BackgroundBrush>
<SolidColorBrush>
<Color A="0" R="1" G="1" B="1"></Color>
</SolidColorBrush>
</BackgroundBrush>
<BorderBrush>
<SolidColorBrush>
<Color A="1" R="0" G="0" B="0"></Color>
</SolidColorBrush>
</BorderBrush>
<StrokeBrush>
<SolidColorBrush>
<Color A="1" R="0" G="0" B="0"></Color>
</SolidColorBrush>
</StrokeBrush>
<FillBrush>
<SolidColorBrush>
<Color A="0" R="1" G="1" B="1"></Color>
</SolidColorBrush>
</FillBrush>
</Brushes>
<Rotation>Rotation0</Rotation>
<OutlineThickness>1</OutlineThickness>
<IsOutlined>False</IsOutlined>
<BorderStyle>SolidLine</BorderStyle>
<Margin>
<DYMOThickness Left="0" Top="0" Right="0" Bottom="0" />
</Margin>
<StrokeWidth>1</StrokeWidth>
<DashPattern>SolidLine</DashPattern>
<ShapeType>Ellipse</ShapeType>
<ObjectLayout>
<DYMOPoint>
<X>0.1173611</X>
<Y>0.3708333</Y>
</DYMOPoint>
<Size>
<Width>2.205555</Width>
<Height>0.5</Height>
</Size>
</ObjectLayout>
</ShapeObject>
</LabelObjects>
</ContinuousLayoutManager>
</DYMOLabel>
<LabelApplication>Blank</LabelApplication>
<DataTable>
<Columns></Columns>
<Rows></Rows>
</DataTable>
</DesktopLabel>
This is related to issue #10 still unfixed since 18 Nov 2020.