Skip to content

Commit f61ba47

Browse files
committed
DCS: Adds examples for passing custom configs
The Document Conversion Service behavior can be customized by passing in various properties as part of the conversion request. See documentation for more details and exact config property names.
1 parent 823ad56 commit f61ba47

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,16 @@ var document_conversion = watson.document_conversion({
303303
document_conversion.convert({
304304
// (JSON) ANSWER_UNITS, NORMALIZED_HTML, or NORMALIZED_TEXT
305305
file: fs.createReadStream('sample-docx.docx'),
306-
conversion_target: document_conversion.conversion_target.ANSWER_UNITS
306+
conversion_target: document_conversion.conversion_target.ANSWER_UNITS,
307+
// Add custom configuration properties or omit for defaults
308+
word: {
309+
heading: {
310+
fonts: [
311+
{ level: 1, min_size: 24 },
312+
{ level: 2, min_size: 16, max_size: 24 }
313+
]
314+
}
315+
}
307316
}, function (err, response) {
308317
if (err) {
309318
console.error(err);

test/test.document_conversion.v1-experimental.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ describe('document_conversion', function() {
2121

2222
var payload = {
2323
conversion_target: 'ANSWER_UNITS',
24+
word: {
25+
heading: {
26+
fonts: [
27+
{ level: 1, min_size: 24 },
28+
{ level: 2, min_size: 16, max_size: 24 }
29+
]
30+
}
31+
},
2432
file: fs.createReadStream(__dirname + '/resources/sampleWORD.docx'),
2533
};
2634

@@ -68,5 +76,11 @@ describe('document_conversion', function() {
6876
assert.equal(req.method, 'POST');
6977
assert(req.formData);
7078
});
79+
80+
it('should send extra config params', function() {
81+
var req = servInstance.convert(payload, noop);
82+
var config = JSON.parse(req.formData.config.value);
83+
assert(config.word.heading.fonts);
84+
});
7185
});
7286
});

test/test.integration-all-services.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,15 @@ describe('integration-all-services', function() {
591591
it('convertFile()', function(done) {
592592
document_conversion.convert({
593593
file: fs.createReadStream(__dirname + '/resources/sampleWORD.docx'),
594-
conversion_target: 'ANSWER_UNITS'
594+
conversion_target: 'ANSWER_UNITS',
595+
word: {
596+
heading: {
597+
fonts: [
598+
{ level: 1, min_size: 24 },
599+
{ level: 2, min_size: 16, max_size: 24 }
600+
]
601+
}
602+
}
595603
}, failIfError.bind(failIfError, done));
596604
});
597605
});

0 commit comments

Comments
 (0)