@softvision/webpdf-wsclient-typescript
Version:
A simplified and optimized API client library for the webPDF server
132 lines • 8.64 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Ocr = void 0;
const index_1 = require("./../index");
class Ocr {
constructor(data) {
let checkResolutionDefault = true;
this.checkResolution = typeof (data === null || data === void 0 ? void 0 : data.checkResolution) !== "undefined" ? data === null || data === void 0 ? void 0 : data.checkResolution : checkResolutionDefault;
let failOnWarningDefault = false;
this.failOnWarning = typeof (data === null || data === void 0 ? void 0 : data.failOnWarning) !== "undefined" ? data === null || data === void 0 ? void 0 : data.failOnWarning : failOnWarningDefault;
let forceEachPageDefault = false;
this.forceEachPage = typeof (data === null || data === void 0 ? void 0 : data.forceEachPage) !== "undefined" ? data === null || data === void 0 ? void 0 : data.forceEachPage : forceEachPageDefault;
let imageDpiDefault = 200;
this.imageDpi = typeof (data === null || data === void 0 ? void 0 : data.imageDpi) !== "undefined" ? data === null || data === void 0 ? void 0 : data.imageDpi : imageDpiDefault;
let jpegQualityDefault = 75;
this.jpegQuality = typeof (data === null || data === void 0 ? void 0 : data.jpegQuality) !== "undefined" ? data === null || data === void 0 ? void 0 : data.jpegQuality : jpegQualityDefault;
let languageDefault = "eng";
this.language = typeof (data === null || data === void 0 ? void 0 : data.language) !== "undefined" ? data === null || data === void 0 ? void 0 : data.language : languageDefault;
let normalizePageRotationDefault = false;
this.normalizePageRotation = typeof (data === null || data === void 0 ? void 0 : data.normalizePageRotation) !== "undefined" ? data === null || data === void 0 ? void 0 : data.normalizePageRotation : normalizePageRotationDefault;
let ocrModeDefault = "pageSegments";
this.ocrMode = typeof (data === null || data === void 0 ? void 0 : data.ocrMode) !== "undefined" ? data === null || data === void 0 ? void 0 : data.ocrMode : ocrModeDefault;
this.optimization = index_1.ImageOptimization.fromJson(data === null || data === void 0 ? void 0 : data.optimization);
let outputFormatDefault = "pdf";
this.outputFormat = typeof (data === null || data === void 0 ? void 0 : data.outputFormat) !== "undefined" ? data === null || data === void 0 ? void 0 : data.outputFormat : outputFormatDefault;
this.page = index_1.OcrPage.fromJson(data === null || data === void 0 ? void 0 : data.page);
this.pdfa = index_1.Pdfa.fromJson(data === null || data === void 0 ? void 0 : data.pdfa);
}
static getCheckResolutionDefault() {
return true;
}
static getCheckResolutionDescription() {
return "If \"true,\" then the DPI resolution of the output file will be checked. Resolutions of less than 200 DPI are rejected in this check because as a rule, they do not produce good results for character recognition.";
}
static getFailOnWarningDefault() {
return false;
}
static getFailOnWarningDescription() {
return "If \"true\", character recognition will fail even in the event of warnings that do not prevent recognition, but that make it very unlikely for a meaningful result to be generated.";
}
static getForceEachPageDefault() {
return false;
}
static getForceEachPageDescription() {
return "If a PDF document contains text content on any page, the web service will refuse to run character recognition again. If, however, a value of \"true\" is passed for this option, all the pages in the document will be considered individually and character recognition will be run on all pages that do not contain text (layers) so that a new layer with text will be generated for them.";
}
static getImageDpiDefault() {
return 200;
}
static getImageDpiDescription() {
return "Used to set the minimum resolution images will be embedded with in resulting PDF documents. When a value of 0 is set for this parameter, the images shall be embedded using resolutions and dimensions as close as possible to the original source images.";
}
static getImageDpiMin() {
return 0;
}
static getImageDpiMax() {
return 9600;
}
static getJpegQualityDefault() {
return 75;
}
static getJpegQualityDescription() {
return "A percentage that sets the compression ratio and influences the quality of JPEG images, that shall be embedded in resulting PDF documents. Higher values will result in less compressed images of higher quality.";
}
static getJpegQualityMin() {
return 0;
}
static getJpegQualityMax() {
return 100;
}
static getLanguageDefault() {
return "eng";
}
static getLanguageDescription() {
return "Used to specify the language for the output document (PDF\/image). The language must be defined for the character recognition operation (OCR) so that the \"special characters\" of the respective language (e.g. \"\u00FC\u00E4\u00F6\" in German) can be recognized better. At present, the following languages are supported:\n\n* eng = English\n* fra = French\n* spa = Spanish\n* deu = German\n* ita = Italian";
}
static getNormalizePageRotationDefault() {
return false;
}
static getNormalizePageRotationDescription() {
return "If \"true\", then, for the recognition of a rotated text, the system will attempt to rotate the page in such a way that the text in the document will not appear to be rotated and will be shown \"upright.\"";
}
static getOcrModeDefault() {
return "pageSegments";
}
static getOcrModeDescription() {
return "Specifies the mode used to find structured text on the pages. Depending on which mode is chosen, different requirements are set for the text and different assumptions are made about the text.\n\n* pageSegments = The text on the page is clearly structured and decomposable into clear paragraphs and layout segments. Overlapping of text elements\/lines does not occur. Headings and thus texts with deviating text sizes and font set, could be present.\n* column = The text is arranged on the pages in several, more or less uniform columns, next to each other. Font and text size are mostly uniform.\n* unfiltered = No assumptions are made about the text, any letters that can be found are recognized as such, regardless of whether they can be assigned to a text column, or line, or even a word. Font size and typeface can vary absolutely and texts are not necessarily arranged in clearly recognizable columns or according to a fixed layout. Texts and lines can overlap. (This mode usually recognizes more text (especially with more complex layouts), but usually also generates the most error detections, since no result is sorted out due to its deviation from the norm.";
}
static getOptimizationDescription() {
return "";
}
static getOutputFormatDefault() {
return "pdf";
}
static getOutputFormatDescription() {
return "Different output formats can be created during character recognition. Generally, the document is generated as a PDF document, but the output can also be as an ASCII document or an XML document if desired (HOCR).\n\n* text = Text\n* hocr = XML (hOCR)\n* pdf = PDF";
}
static getPageDescription() {
return "";
}
static getPdfaDescription() {
return "";
}
static fromJson(data) {
if (data === undefined || data === null) {
return data;
}
return new Ocr(data);
}
toJson() {
var _a, _b, _c;
return {
'checkResolution': this.checkResolution,
'failOnWarning': this.failOnWarning,
'forceEachPage': this.forceEachPage,
'imageDpi': this.imageDpi,
'jpegQuality': this.jpegQuality,
'language': this.language,
'normalizePageRotation': this.normalizePageRotation,
'ocrMode': this.ocrMode,
'optimization': (_a = this.optimization) === null || _a === void 0 ? void 0 : _a.toJson(),
'outputFormat': this.outputFormat,
'page': (_b = this.page) === null || _b === void 0 ? void 0 : _b.toJson(),
'pdfa': (_c = this.pdfa) === null || _c === void 0 ? void 0 : _c.toJson(),
};
}
clone() {
return Ocr.fromJson(this.toJson());
}
}
exports.Ocr = Ocr;
//# sourceMappingURL=Ocr.js.map