diff --git a/src/lib/api/transform.ts b/src/lib/api/transform.ts index 2c8c9984..1044ed05 100644 --- a/src/lib/api/transform.ts +++ b/src/lib/api/transform.ts @@ -408,6 +408,14 @@ export interface TransformOptions { orientation?: EUrlscreenshotOrientation; device?: string; } | true; + pdfinfo?: { + colorinfo?: boolean + } | true; + pdfconvert?: { + pageorientation?: string + pageformat?: string + pages?: (string | number)[] + }; } /** diff --git a/src/schema/transforms.schema.spec.ts b/src/schema/transforms.schema.spec.ts index 7d059fab..717bf837 100644 --- a/src/schema/transforms.schema.spec.ts +++ b/src/schema/transforms.schema.spec.ts @@ -251,4 +251,89 @@ describe('Transforms Schema', () => { })); }); }); + + describe('Pdfinfo', () => { + it('should validate correct params with bool value', () => { + assert.ok(validate({ + pdfinfo: true, + })); + }); + + it('should validate correct params with color info', () => { + assert.ok(validate({ + pdfinfo: { + colorinfo: true, + }, + })); + }); + }); + + describe('Pdfconvert', () => { + describe('Pages', () => { + [[1,2], ['1-', 3], ['-2']].forEach((val) => { + it(`should validate on correct page "${val}"`, () => { + assert.ok(validate({ + pdfconvert: { + pages: val, + }, + })); + }); + }); + + it('should return error on fail page "1a"', () => { + assertFail(validate({ + pdfconvert: { + pages: '1a', + }, + })); + }); + + }); + + describe('Page orientation', () => { + it('should pass on correct orientation "landscape"', () => { + assert.ok(validate({ + pdfconvert: { + pageorientation: 'landscape', + }, + })); + }); + + it('should pass on correct orientation "portrait"', () => { + assert.ok(validate({ + pdfconvert: { + pageorientation: 'portrait', + }, + })); + }); + + it('should fail on wrong orientation "landscape1"', () => { + assertFail(validate({ + pdfconvert: { + pageorientation: 'landscape1', + }, + })); + }); + }); + + describe('Page format', () => { + ['a2', 'a3', 'a4', 'a5', 'b4', 'b5', 'letter', 'legal', 'tabloid'].forEach((val) => { + it(`should when correct page format is provided ${val}`, () => { + assert.ok(validate({ + pdfconvert: { + pageformat: val, + }, + })); + }); + }); + + it('should fail on wrong page format ie a22', () => { + assertFail(validate({ + pdfconvert: { + pageformat: 'a22', + }, + })); + }); + }); + }); }); diff --git a/src/schema/transforms.schema.ts b/src/schema/transforms.schema.ts index f9642860..73ea776b 100644 --- a/src/schema/transforms.schema.ts +++ b/src/schema/transforms.schema.ts @@ -22,6 +22,26 @@ export const TransformSchema = { type: 'object', additionalProperties: false, definitions: { + pageFormatDef: { + '$id': '#pageFormatDef', + type: 'string', + enum: ['a2', 'a3', 'a4', 'a5', 'b4', 'b5', 'letter', 'legal', 'tabloid'], + }, + pageRangeDef: { + '$id': '#pageRangeDef', + type: 'array', + uniqueItems: true, + items: [{ + oneOf: [{ + type: 'integer', + minimum: 1, + }, { + type: 'string', + pattern: '^(\\d+(?:-\\d+)?)$|^(-\\d+)$|^(\\d+-)$', + errorMessage: 'Param should be provided in one of the following formats: "1,2,3,5", "1-3", "1-", "-2" ', + }], + }], + }, facesDef: { '$id': '#facesDef', oneOf: [{ @@ -954,7 +974,7 @@ export const TransformSchema = { }, pageformat: { type: 'string', - enum: ['a3', 'a4', 'a5', 'b4', 'b5', 'letter', 'legal', 'tabloid'], + enum: ['a2', 'a3', 'a4', 'a5', 'b4', 'b5', 'letter', 'legal', 'tabloid'], }, pageorientation: { type: 'string', @@ -1256,5 +1276,40 @@ export const TransformSchema = { }, required: ['policy', 'signature'], }, + pdfinfo: { + oneOf: [{ + type: 'boolean', + }, { + type: 'object', + properties: { + colorinfo: { + type: 'boolean', + }, + }, + }], + }, + pdfconvert: { + type: 'object', + additionalProperties: false, + properties: { + pageorientation: { + type: 'string', + enum: ['portrait', 'landscape'], + }, + pageformat: { + '$ref': '#pageFormatDef', + }, + pages: { + '$ref': '#pageRangeDef', + }, + }, + oneOf: [{ + required: ['pageorientation'], + }, { + required: ['pageformat'], + }, { + required: ['pages'], + }], + }, }, };