OCRmyPDF-DotNet 1.0.6

dotnet add package OCRmyPDF-DotNet --version 1.0.6
NuGet\Install-Package OCRmyPDF-DotNet -Version 1.0.6
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OCRmyPDF-DotNet" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OCRmyPDF-DotNet --version 1.0.6
#r "nuget: OCRmyPDF-DotNet, 1.0.6"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OCRmyPDF-DotNet as a Cake Addin
#addin nuget:?package=OCRmyPDF-DotNet&version=1.0.6

// Install OCRmyPDF-DotNet as a Cake Tool
#tool nuget:?package=OCRmyPDF-DotNet&version=1.0.6

OCRmyPDF-DotNet

Este é um pequeno wrapper, feito em .NET 8/C#, para o projeto OCRmyPDF.

Instalação

Após a instalação, é necessário fazer algunas validações:

Ambiente Windows

Ambiente Linux

Imagem Docker

Caso deseje criar uma imagem Docker, será necessário adicionar o seguinte código ao seu Dockerfile:

RUN apt-get update && \
    apt-get install -y python3.11 python3-pip

RUN apt install -y ocrmypdf

RUN apt-get install -y tesseract-ocr-eng tesseract-ocr-por tesseract-ocr-spa tesseract-ocr-fra

ENV PATH="/usr/bin:${PATH}"

RUN ln -sf /usr/bin/python3.11 /usr/bin/python && \
    ln -sf /usr/bin/python3.11 /usr/bin/python3

Uso/Exemplos

O método principal, StartProcess, espera a seguinte entidade:

public class Request
{
    public string PythonVersion { get; set; } = string.Empty;
    public string PythonHome { get; set; } = string.Empty;
    public string PythonDLL { get; set; } = string.Empty;
    public string InputFile { get; set; } = string.Empty;
    public string OutputFile { get; set; } = string.Empty;
    public string Language { get; set; } = "eng";
    public bool RedoOCR { get; set; } = false;
}
  • A propriedade PythonVersion é a versão do Python que será utilizada. Caso não seja informada, será retornado um erro de versão não encontrada;
  • A propriedade PythonHome é a instalação do Python que será utilizada, apenas para ambiente Windows. Caso não seja informada, será utilizada o valor padrão C:\Program Files\Python\Python e a versão enviada no PythonVersion;
  • A propriedade PythonDLL é a DLL/SO que será utilizada. Caso não seja informada será utilizada a DLL/SO padrão do Python, para ambiente Windows é o python3.11.dll, exemplo, e para ambiente Linux é o /usr/lib/x86_64-linux-gnu/libpython3.11.so, exemplo;
  • A propriedade InputFile será o arquivo a ser processado;
  • A propriedade OutputFile será o arquivo processado e retornado;
  • A propriedade Language é a linguagem do arquivo (pt/eng/etc...);
  • A propriedade RedoOCR será utilizada quando o arquivo já é selecionável, mas ainda assim é necessário ser refeito o OCR;
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6 186 4/22/2024
1.0.5 85 4/22/2024
1.0.4 98 4/16/2024
1.0.3 82 4/14/2024
1.0.2 82 4/13/2024
1.0.1 77 4/13/2024
1.0.0 83 4/11/2024