Import Ruty
This commit is contained in:
BIN
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
+51
@@ -0,0 +1,51 @@
|
||||
var rtf = require('../lib/rtf'),
|
||||
Format = require('../lib/format'),
|
||||
Colors = require('../lib/colors'),
|
||||
RGB = require('../lib/rgb'),
|
||||
fs = require('fs');
|
||||
var myDoc = new rtf(),
|
||||
red_underline = new Format(),
|
||||
blue_strike = new Format(),
|
||||
green_bold = new Format(),
|
||||
maroon_super = new Format(),
|
||||
gray_sub = new Format(),
|
||||
lime_indent = new Format(),
|
||||
custom_blue = new Format();
|
||||
|
||||
red_underline.color = Colors.RED;
|
||||
red_underline.underline = true;
|
||||
red_underline.fontSize = 20;
|
||||
myDoc.writeText("Red underlined", red_underline);
|
||||
myDoc.addLine();
|
||||
blue_strike.color = Colors.RED;
|
||||
blue_strike.strike = true;
|
||||
myDoc.writeText("Strikeout Blue", blue_strike);
|
||||
myDoc.addLine();
|
||||
green_bold.color = Colors.GREEN;
|
||||
green_bold.bold = true;
|
||||
myDoc.writeText("Bold Green", green_bold);
|
||||
myDoc.addLine();
|
||||
maroon_super.color = Colors.MAROON;
|
||||
maroon_super.superScript = true;
|
||||
myDoc.writeText("Superscripted Maroon", maroon_super);
|
||||
myDoc.addLine();
|
||||
gray_sub.color = Colors.GRAY;
|
||||
gray_sub.subScript = true;
|
||||
myDoc.writeText("Subscripted Gray", gray_sub);
|
||||
myDoc.addLine();
|
||||
lime_indent.color = Colors.LIME;
|
||||
lime_indent.backgroundColor = Colors.Gray;
|
||||
lime_indent.leftIndent = 50;
|
||||
myDoc.writeText("Left indented Lime", lime_indent);
|
||||
myDoc.addLine();
|
||||
custom_blue.color = new RGB(3, 80, 150);
|
||||
myDoc.writeText("Custom blue color", custom_blue);
|
||||
|
||||
myDoc.createDocument(
|
||||
function(err, output){
|
||||
console.log(output);
|
||||
fs.writeFile('formatting.rtf', output, function (err) {
|
||||
if (err) return console.log(err);
|
||||
});
|
||||
}
|
||||
);
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
var rtf = require('../lib/rtf'),
|
||||
Format = require('../lib/format'),
|
||||
Colors = require('../lib/colors'),
|
||||
fs = require('fs');
|
||||
var myDoc = new rtf(),
|
||||
format = new Format();
|
||||
|
||||
format.color = Colors.ORANGE;
|
||||
myDoc.writeText("Happy Halloween", format);
|
||||
myDoc.addPage();
|
||||
myDoc.addLine();
|
||||
myDoc.addTab();
|
||||
myDoc.writeText("Trick or treat!");
|
||||
myDoc.createDocument(
|
||||
function(err, output){
|
||||
console.log(output);
|
||||
fs.writeFile('halloween.rtf', output, function (err) {
|
||||
if (err) return console.log(err);
|
||||
});
|
||||
}
|
||||
);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
var rtf = require('../lib/rtf'),
|
||||
fs = require('fs'),
|
||||
ImageElement = require('../lib/elements/image');
|
||||
|
||||
var myDoc = new rtf();
|
||||
|
||||
myDoc.elements.push(new ImageElement('examples/dog.jpg'));
|
||||
|
||||
myDoc.createDocument(
|
||||
function(err, output){
|
||||
//console.log(output); //that's a little much to output to the console
|
||||
fs.writeFile('image.rtf', output, function (err) {
|
||||
if (err) return console.log(err);
|
||||
});
|
||||
}
|
||||
);
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
var rtf = require('../lib/rtf'),
|
||||
TableElement = require('../lib/elements/table'),
|
||||
fs = require('fs');
|
||||
var myDoc = new rtf(),
|
||||
table = new TableElement(),
|
||||
table2 = new TableElement();
|
||||
|
||||
//add rows
|
||||
table.addRow(["I'm a table row", "with two columns"]);
|
||||
table.addRow(["This is the second row", "and the second column"]);
|
||||
|
||||
myDoc.addTable(table);
|
||||
|
||||
//You can manually set the data *overwrites any data in the table
|
||||
table2.setData([
|
||||
["Name", "Price", "Sold"],
|
||||
["Rubber Ducky", "$10.00", "22"],
|
||||
["Widget", "$99.99", "42"],
|
||||
["Sproket", "$5.24", "11"]
|
||||
]);
|
||||
//adding a row to an existing data set
|
||||
table2.addRow(["Banana", "$0.12", "1"]);
|
||||
|
||||
myDoc.createDocument(
|
||||
function(err, output){
|
||||
console.log(output);
|
||||
fs.writeFile('table-sample.rtf', output, function (err) {
|
||||
if (err) return console.log(err);
|
||||
});
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user