Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: Add syntax highlighting #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ npm i dymojs

### usage

```
```javascript
const Dymo = require('dymojs'),
dymo = new Dymo();

// Assign Label XML information to a labelXml variable, see below

dymo.print('DYMO LabelWriter 450', labelXml);
```

render a label preview

```
```javascript
dymo.renderLabel(labelXml).then(imageData => {
// returns imageData as base64 encoded png.
// use <img src="data:image/png;base64,${imageData}"/>
Expand All @@ -42,18 +44,16 @@ dymo.renderLabel(labelXml).then(imageData => {
```

### how do I get the xml for a label?
Open the free `DYMO Label` software and design a label. When you have designed one save it. The file it saves is an XML document like the one below. Simply pass that XML or (hint hint) a version of that XML that you did some string replacement on to the print function with a printer name and you are printing labels.
Open the free `DYMO Label` software and design a label. When you have designed one, save it. The file it saves is an XML document like the one below. Simply pass that XML or (hint hint) a version of that XML that you did some string replacement on to the print function with a printer name and you are printing labels.

### working example that prints a test label
This example will print TEST123 on a shipping size label (2 1/8" x 4") to a printer named 'DYMO LabelWriter 450'.
This example will print TEST123 on a shipping size label (2 1/8" x 4") to a printer named `DYMO LabelWriter 450`.

```
```javascript
const Dymo = require('dymojs'),
dymo = new Dymo();

dymo.print('DYMO LabelWriter 450', labelXml);

var labelXml = `
let labelXml = `
<?xml version="1.0" encoding="utf-8"?>
<DieCutLabel Version="8.0" Units="twips">
<PaperOrientation>Landscape</PaperOrientation>
Expand Down Expand Up @@ -99,5 +99,7 @@ var labelXml = `
</ObjectInfo>
</DieCutLabel>
`;

dymo.print('DYMO LabelWriter 450', labelXml);
```