javascriptxmldymo

Putting subcells in cells dymo XML Javascript API


I am trying to make an XML for a continuous label (I have to use their cell layout) with the Javascript API.

Here's what I have:

<ContinuousLabel Version="8.0" Units="twips">
<PaperOrientation>Portrait</PaperOrientation>
<Id>Continuous</Id>
<PaperName>30270 Continuous</PaperName>
<LengthMode>Auto</LengthMode>
<LabelLength>0</LabelLength>
<RootCell>
<Length>0</Length>
<LengthMode>Auto</LengthMode>
<SubcellsOrientation>Vertical</SubcellsOrientation>
<Subcells>
<Cell>
<TextObject>
<Name>TEXT</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>False</IsVariable>
<HorizontalAlignment>Center</HorizontalAlignment>
<VerticalAlignment>Middle</VerticalAlignment>
<TextFitMode>ShrinkToFit</TextFitMode>
<UseFullFontHeight>True</UseFullFontHeight>
<Verticalized>False</Verticalized>
<StyledText>
<Element>
<String>Hello World</String>
<Attributes>
<Font Family="Lucida Grande" Size="13" Bold="False" Italic="False" Underline="False" Strikeout="False"/>
<ForeColor Alpha="255" Red="0" Green="0" Blue="0"/>
</Attributes>
</Element>
</StyledText>
</TextObject>
<Length>0</Length>
<LengthMode>Auto</LengthMode>
</Cell>
</SubCells>
</RootCell>
</ContinuousLabel>

I am able to add more cells to the subcell tag however I need to create rows and columns (along with header and footer)

Their documentation says the rootcells contain cells(subcells) and cells can contain label objects or other subcells (they have very little information on their xml) I found their .net framework documentation which as far as I understand constructs the xml (if you are using .net) and their IContinuousLabelCell has a property subcells. however I cannot figure out how to add my own subcells to a cell other then the root cell.

I have been trying to figure this out for two days now and nothing I have found has helped me.

So you can see what I am trying to accomplish:http://jsfiddle.net/snymax/fu5hum81/22/

I have broken the different objects into functions to make it a little simpler in the fiddle

I'm sure this is a lot simpler then I am making it and if not does anyone know of another way I can print a custom receipt to a dymo labelwriter 450


Solution

  • I found the xml schema for dymo and figured it out

    RootCell is a Cell tag with a special name, it can do anything a normal cell can and vice versa However RootCell is a required tag inside the continuouslabel tag

    also if the cell is going to contain more cells it cannot contain objects also its properties must come before the Subcells tag

    if the cell is going to contain objects it cannot contain the subcell property and must have the cell properties listed after the object

    so heres a quick example

    var xml = '<ContinuousLabel Version="8.0" Units="twips">\
    <PaperOrientation>Portrait</PaperOrientation>\
    <Id>Continuous</Id>\
    <PaperName>30270 Continuous</PaperName>\
    <LengthMode>Auto</LengthMode>\
    <LabelLength>0</LabelLength>\
    <RootCell>\
    <Length>0</Length>\
    <LengthMode>Auto</LengthMode>\
    <BorderWidth>0</BorderWidth>\
    <BorderStyle>Solid</BorderStyle>\
    <BorderColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    <SubcellsOrientation>Vertical</SubcellsOrientation>\
    <Subcells>\
    '<Cell>\
    <Length>0</Length>\
    <LengthMode>Auto</LengthMode>\
    <BorderWidth>0</BorderWidth>\
    <BorderStyle>Solid</BorderStyle>\
    <BorderColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    <SubcellsOrientation>Horizontal</SubcellsOrientation>\
    <Subcells>\
    <Cell>\
    <TextObject>\
    <Name>QTY</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>False</IsVariable>\
    <HorizontalAlignment>Center</HorizontalAlignment>\
    <VerticalAlignment>Middle</VerticalAlignment>\
    <TextFitMode>ShrinkToFit</TextFitMode>\
    <UseFullFontHeight>True</UseFullFontHeight>\
    <Verticalized>False</Verticalized>\
    <StyledText>\
    <Element>\
    <String>' + obj.qty + '</String>\
    <Attributes>\
    <Font Family="Lucida Grande" Size="13" Bold="False" Italic="False" Underline="False" Strikeout="False"/>\
    <ForeColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Attributes>\
    </Element>\
    </StyledText>\
    </TextObject>\
    <Length>0</Length>\
    <LengthMode>Auto</LengthMode>\
    <BorderWidth>0</BorderWidth>\
    <BorderStyle>Solid</BorderStyle>\
    <BorderColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Cell>\
    <Cell>\
    <TextObject>\
    <Name>NAME</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>False</IsVariable>\
    <HorizontalAlignment>Center</HorizontalAlignment>\
    <VerticalAlignment>Middle</VerticalAlignment>\
    <TextFitMode>ShrinkToFit</TextFitMode>\
    <UseFullFontHeight>True</UseFullFontHeight>\
    <Verticalized>False</Verticalized>\
    <StyledText>\
    <Element>\
    <String>' + obj.name +'</String>\
    <Attributes>\
    <Font Family="Lucida Grande" Size="13" Bold="False" Italic="False" Underline="False" Strikeout="False"/>\
    <ForeColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Attributes>\
    </Element>\
    </StyledText>\
    </TextObject>\
    <Length>0</Length>\
    <LengthMode>Auto</LengthMode>\
    <BorderWidth>0</BorderWidth>\
    <BorderStyle>Solid</BorderStyle>\
    <BorderColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Cell>\
    <Cell>\
    <TextObject>\
    <Name>PRICE</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>False</IsVariable>\
    <HorizontalAlignment>Center</HorizontalAlignment>\
    <VerticalAlignment>Middle</VerticalAlignment>\
    <TextFitMode>ShrinkToFit</TextFitMode>\
    <UseFullFontHeight>True</UseFullFontHeight>\
    <Verticalized>False</Verticalized>\
    <StyledText>\
    <Element>\
    <String>' + obj.price + '</String>\
    <Attributes>\
    <Font Family="Lucida Grande" Size="13" Bold="False" Italic="False" Underline="False" Strikeout="False"/>\
    <ForeColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Attributes>\
    </Element>\
    </StyledText>\
    </TextObject>\
    <Length>0</Length>\
    <LengthMode>Auto</LengthMode>\
    <BorderWidth>0</BorderWidth>\
    <BorderStyle>Solid</BorderStyle>\
    <BorderColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Cell>\
    </Subcells>\
    </Cell>';
    '<Cell>\
    <Length>0</Length>\
    <LengthMode>Auto</LengthMode>\
    <BorderWidth>0</BorderWidth>\
    <BorderStyle>Solid</BorderStyle>\
    <BorderColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    <SubcellsOrientation>Horizontal</SubcellsOrientation>\
    <Subcells>\
    <Cell>\
    <TextObject>\
    <Name>QTY</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>False</IsVariable>\
    <HorizontalAlignment>Center</HorizontalAlignment>\
    <VerticalAlignment>Middle</VerticalAlignment>\
    <TextFitMode>ShrinkToFit</TextFitMode>\
    <UseFullFontHeight>True</UseFullFontHeight>\
    <Verticalized>False</Verticalized>\
    <StyledText>\
    <Element>\
    <String>' + obj.qty + '</String>\
    <Attributes>\
    <Font Family="Lucida Grande" Size="13" Bold="False" Italic="False" Underline="False" Strikeout="False"/>\
    <ForeColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Attributes>\
    </Element>\
    </StyledText>\
    </TextObject>\
    <Length>0</Length>\
    <LengthMode>Auto</LengthMode>\
    <BorderWidth>0</BorderWidth>\
    <BorderStyle>Solid</BorderStyle>\
    <BorderColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Cell>\
    <Cell>\
    <TextObject>\
    <Name>NAME</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>False</IsVariable>\
    <HorizontalAlignment>Center</HorizontalAlignment>\
    <VerticalAlignment>Middle</VerticalAlignment>\
    <TextFitMode>ShrinkToFit</TextFitMode>\
    <UseFullFontHeight>True</UseFullFontHeight>\
    <Verticalized>False</Verticalized>\
    <StyledText>\
    <Element>\
    <String>' + obj.name +'</String>\
    <Attributes>\
    <Font Family="Lucida Grande" Size="13" Bold="False" Italic="False" Underline="False" Strikeout="False"/>\
    <ForeColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Attributes>\
    </Element>\
    </StyledText>\
    </TextObject>\
    <Length>0</Length>\
    <LengthMode>Auto</LengthMode>\
    <BorderWidth>0</BorderWidth>\
    <BorderStyle>Solid</BorderStyle>\
    <BorderColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Cell>\
    <Cell>\
    <TextObject>\
    <Name>PRICE</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>False</IsVariable>\
    <HorizontalAlignment>Center</HorizontalAlignment>\
    <VerticalAlignment>Middle</VerticalAlignment>\
    <TextFitMode>ShrinkToFit</TextFitMode>\
    <UseFullFontHeight>True</UseFullFontHeight>\
    <Verticalized>False</Verticalized>\
    <StyledText>\
    <Element>\
    <String>' + obj.price + '</String>\
    <Attributes>\
    <Font Family="Lucida Grande" Size="13" Bold="False" Italic="False" Underline="False" Strikeout="False"/>\
    <ForeColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Attributes>\
    </Element>\
    </StyledText>\
    </TextObject>\
    <Length>0</Length>\
    <LengthMode>Auto</LengthMode>\
    <BorderWidth>0</BorderWidth>\
    <BorderStyle>Solid</BorderStyle>\
    <BorderColor Alpha="255" Red="0" Green="0" Blue="0"/>\
    </Cell>\
    </Subcells>\
    </Cell>';
    </Subcells>\
    </Cell>\
    </Subcells>\
    </RootCell>\
    </ContinuousLabel>'
    

    this is showing 2 rows of 3 columns I might just be the only person interested in the solution but we have found that dymo printers are cheaper and easier to use then most others on the market.

    just so you guys have it heres the xml schema for their labels and continuous labels:http://www.labelwriter.com/software/dls/sdk/LabelFile.xsd