public void Can_easily_construct_with_no_options_set()
        {
            var options = new OcrOptions();

            Assert.AreEqual("english", options.Language);
            Assert.IsNull(options.DefaultDpi);
        }
        public void Can_construct_with_a_custom_language()
        {
            var options = new OcrOptions
            {
                Language = "russian",
            };

            Assert.AreEqual("russian", options.Language);
            Assert.IsNull(options.DefaultDpi);
        }
        public void Can_easily_construct_with_custom_default_dpi()
        {
            var options = new OcrOptions
            {
                DefaultDpi = new DpiOptions(x: 72, y: 120),
            };

            Assert.IsNotNull(options.DefaultDpi);
            Assert.AreEqual(72, options.DefaultDpi.X);
            Assert.AreEqual(120, options.DefaultDpi.Y);
        }
Ejemplo n.º 4
0
        public WFwOcrClient(OcrOptions ocr, ILogger <WFwOcrClient> l)
        {
            ocrOptions = ocr;
            logger     = l;
            Credential cred = new Credential
            {
                SecretId  = ocr.SecretId,
                SecretKey = ocr.SecretKey
            };

            client = new OcrClient(cred, "ap-guangzhou");
        }
 /// <summary>
 /// Perform OCR on pages from a collection of source documents, producing a PDF.
 /// <para>
 /// Convenience wrapper for <see cref="ConvertAsync(IEnumerable{ConversionSourceDocument}, DestinationOptions)" />, returning a single <see cref="ConversionResult" />.
 /// </para>
 /// </summary>
 /// <param name="sourceDocuments">Collection of source documents whose pages should be combined, in order, to form the output.</param>
 /// <param name="options">OCR options.</param>
 /// <returns>ConversionResult for the created PDF.</returns>
 /// <seealso cref="ConvertAsync(IEnumerable{ConversionSourceDocument}, DestinationOptions)" />
 public async Task <ConversionResult> OcrToPdfAsync(IEnumerable <ConversionSourceDocument> sourceDocuments, OcrOptions options)
 {
     return((await this.ConvertAsync(sourceDocuments, new DestinationOptions(DestinationFileFormat.Pdf)
     {
         PdfOptions = new PdfDestinationOptions
         {
             Ocr = options,
         },
     })).Where(x => x.IsSuccess).Single());
 }
 /// <summary>
 /// Perform OCR on pages of a single source document, producing a PDF.
 /// <para>
 /// Convenience wrapper for <see cref="ConvertAsync(IEnumerable{ConversionSourceDocument}, DestinationOptions)" />, returning a single <see cref="ConversionResult" />.
 /// </para>
 /// </summary>
 /// <param name="sourceDocument">Information about the source document to use as input.</param>
 /// <param name="options">OCR options.</param>
 /// <returns>ConversionResult for the created PDF.</returns>
 /// <seealso cref="ConvertAsync(ConversionSourceDocument, DestinationOptions)" />
 public Task <ConversionResult> OcrToPdfAsync(ConversionSourceDocument sourceDocument, OcrOptions options) =>
 this.OcrToPdfAsync(new ConversionSourceDocument[] { sourceDocument }, options);
 /// <summary>
 /// Perform OCR on a local file, producing a searchable PDF.
 /// <para>
 /// Convenience wrapper for <see cref="ConvertAsync(IEnumerable{ConversionSourceDocument}, DestinationOptions)" />, returning a single <see cref="ConversionResult" />.
 /// </para>
 /// </summary>
 /// <param name="localFilePath">Path to a local file to use as input.</param>
 /// <param name="options">OCR options.</param>
 /// <returns>ConversionResult for the created PDF.</returns>
 /// <seealso cref="ConvertAsync(string, DestinationOptions)" />
 public Task <ConversionResult> OcrToPdfAsync(string localFilePath, OcrOptions options) =>
 this.OcrToPdfAsync(new ConversionSourceDocument(localFilePath), options);